release.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. name: Create Release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: 'version to release, e.g. v1.5.13'
  7. required: true
  8. default: 'v0.1.0'
  9. source_ref:
  10. description: 'source ref to publish from. E.g.: main or release-x.y'
  11. required: true
  12. default: 'main'
  13. env:
  14. IMAGE_NAME: ghcr.io/${{ github.repository }}
  15. jobs:
  16. release:
  17. name: Create Release
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Checkout
  21. uses: actions/checkout@v3
  22. with:
  23. fetch-depth: 0
  24. ref: ${{ github.event.inputs.source_ref }}
  25. - name: Create Release
  26. uses: softprops/action-gh-release@v1
  27. with:
  28. tag_name: ${{ github.event.inputs.version }}
  29. target_commitish: ${{ github.event.inputs.source_ref }}
  30. generate_release_notes: true
  31. body: |
  32. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}`
  33. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi`
  34. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi-boringssl`
  35. env:
  36. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  37. - name: Setup Go
  38. uses: actions/setup-go@v4
  39. with:
  40. go-version-file: "go.mod"
  41. - name: Configure Git
  42. run: |
  43. git config user.name "$GITHUB_ACTOR"
  44. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  45. - name: Update Docs
  46. if: github.ref == 'refs/heads/main'
  47. run: make docs.publish DOCS_VERSION=${{ github.event.inputs.version }} DOCS_ALIAS=latest
  48. env:
  49. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  50. promote:
  51. name: Promote Container Image
  52. runs-on: ubuntu-latest
  53. strategy:
  54. matrix:
  55. include:
  56. - tag_suffix: "" # distroless image
  57. - tag_suffix: "-ubi" # ubi image
  58. - tag_suffix: "-ubi-boringssl" # ubi image
  59. permissions:
  60. id-token: write
  61. contents: write
  62. env:
  63. SOURCE_TAG: ${{ github.event.inputs.source_ref }}${{ matrix.tag_suffix }}
  64. RELEASE_TAG: ${{ github.event.inputs.version }}${{ matrix.tag_suffix }}
  65. steps:
  66. - name: Checkout
  67. uses: actions/checkout@v3
  68. with:
  69. fetch-depth: 0
  70. - name: Setup Go
  71. uses: actions/setup-go@v4
  72. with:
  73. go-version-file: "go.mod"
  74. - name: Find the Go Cache
  75. id: go
  76. run: |
  77. echo "::set-output name=build-cache::$(go env GOCACHE)"
  78. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  79. - name: Cache the Go Build Cache
  80. uses: actions/cache@v3
  81. with:
  82. path: ${{ steps.go.outputs.build-cache }}
  83. key: ${{ runner.os }}-build-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  84. - name: Cache Go Dependencies
  85. uses: actions/cache@v3
  86. with:
  87. path: ${{ steps.go.outputs.mod-cache }}
  88. key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  89. - name: Login to Docker
  90. uses: docker/login-action@v2
  91. with:
  92. registry: ghcr.io
  93. username: ${{ secrets.GHCR_USERNAME }}
  94. password: ${{ secrets.GHCR_TOKEN }}
  95. - name: Promote Container Image
  96. run: make docker.promote
  97. - name: Build release manifests
  98. run: |
  99. # temporarily patch the version so we generate manifests with the new version
  100. yq e -i '.version = "${{ github.event.inputs.version }}"' ./deploy/charts/external-secrets/Chart.yaml
  101. yq e -i '.appVersion = "${{ github.event.inputs.version }}"' ./deploy/charts/external-secrets/Chart.yaml
  102. make manifests
  103. - name: Sign promoted image
  104. id: sign
  105. uses: ./.github/actions/sign
  106. with:
  107. image-name: ${{ env.IMAGE_NAME }}
  108. image-tag: ${{ env.RELEASE_TAG }}
  109. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  110. GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
  111. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  112. - name: Update Release
  113. uses: softprops/action-gh-release@v1
  114. with:
  115. tag_name: ${{ github.event.inputs.version }}
  116. files: |
  117. provenance.${{ env.RELEASE_TAG }}.intoto.jsonl
  118. sbom.${{ env.RELEASE_TAG }}.spdx.json
  119. bin/deploy/manifests/external-secrets.yaml
  120. env:
  121. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"