release.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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'
  11. required: true
  12. default: 'main'
  13. env:
  14. IMAGE_NAME: ghcr.io/${{ github.repository }}
  15. permissions:
  16. contents: read
  17. jobs:
  18. check-docs-for-release:
  19. name: Check Docs for release
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: read
  23. steps:
  24. - name: Harden the runner (Audit all outbound calls)
  25. uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
  26. with:
  27. egress-policy: audit
  28. - name: Checkout
  29. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
  30. with:
  31. fetch-depth: 0
  32. - name: Resolve and validate ref
  33. id: resolve_ref
  34. env:
  35. SOURCE_REF: ${{ github.event.inputs.source_ref }}
  36. run: |
  37. set -e
  38. # Try to fetch the ref from remote
  39. if git fetch origin "$SOURCE_REF"; then
  40. # Remote ref exists, use it
  41. RESOLVED_SHA=$(git rev-parse "origin/$SOURCE_REF")
  42. elif git rev-parse --verify "$SOURCE_REF" >/dev/null 2>&1; then
  43. # Local ref exists (e.g., a tag)
  44. RESOLVED_SHA=$(git rev-parse "$SOURCE_REF")
  45. else
  46. echo "Error: ref '$SOURCE_REF' not found"
  47. exit 1
  48. fi
  49. echo "Resolved to SHA: $RESOLVED_SHA"
  50. echo "sha=$RESOLVED_SHA" >> $GITHUB_OUTPUT
  51. - name: Checkout validated ref
  52. run: git checkout ${{ steps.resolve_ref.outputs.sha }}
  53. - name: check-docs
  54. env:
  55. DOCS_VERSION: ${{ github.event.inputs.version }}
  56. run: |
  57. make docs.check
  58. release:
  59. name: Create Release
  60. runs-on: ubuntu-latest
  61. permissions:
  62. contents: write # to create a release and push new docs
  63. steps:
  64. - name: Harden the runner (Audit all outbound calls)
  65. uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
  66. with:
  67. egress-policy: audit
  68. - name: Checkout
  69. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
  70. with:
  71. fetch-depth: 0
  72. - name: Resolve and validate ref
  73. id: resolve_ref
  74. env:
  75. SOURCE_REF: ${{ github.event.inputs.source_ref }}
  76. run: |
  77. set -e
  78. # Try to fetch the ref from remote
  79. if git fetch origin "$SOURCE_REF"; then
  80. # Remote ref exists, use it
  81. RESOLVED_SHA=$(git rev-parse "origin/$SOURCE_REF")
  82. elif git rev-parse --verify "$SOURCE_REF" >/dev/null 2>&1; then
  83. # Local ref exists (e.g., a tag)
  84. RESOLVED_SHA=$(git rev-parse "$SOURCE_REF")
  85. else
  86. echo "Error: ref '$SOURCE_REF' not found"
  87. exit 1
  88. fi
  89. echo "Resolved to SHA: $RESOLVED_SHA"
  90. echo "sha=$RESOLVED_SHA" >> $GITHUB_OUTPUT
  91. - name: Checkout validated ref
  92. run: git checkout ${{ steps.resolve_ref.outputs.sha }}
  93. - name: Create Release
  94. uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
  95. with:
  96. tag_name: ${{ github.event.inputs.version }}
  97. target_commitish: ${{ github.event.inputs.source_ref }}
  98. generate_release_notes: true
  99. body: |
  100. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}`
  101. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi`
  102. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi-boringssl`
  103. env:
  104. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  105. - name: Configure Git
  106. env:
  107. TOKEN: ${{ secrets.GITHUB_TOKEN }}
  108. run: |
  109. git config user.name "$GITHUB_ACTOR"
  110. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  111. git remote set-url origin "https://x-access-token:${{ env.TOKEN }}@github.com/${{ github.repository }}.git"
  112. - name: Update Docs
  113. if: github.ref == 'refs/heads/main'
  114. env:
  115. DOCS_VERSION: ${{ github.event.inputs.version }}
  116. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  117. run: make docs.publish DOCS_ALIAS=latest
  118. promote:
  119. name: Promote Container Image
  120. runs-on: ubuntu-latest
  121. strategy:
  122. matrix:
  123. include:
  124. - tag_suffix: "" # distroless image
  125. - tag_suffix: "-ubi" # ubi image
  126. - tag_suffix: "-ubi-boringssl" # ubi image
  127. permissions:
  128. contents: write #to update the github release
  129. id-token: write #for keyless sign
  130. packages: write #to update packages with added SBOMs.
  131. env:
  132. SOURCE_TAG: ${{ github.event.inputs.source_ref }}${{ matrix.tag_suffix }}
  133. RELEASE_TAG: ${{ github.event.inputs.version }}${{ matrix.tag_suffix }}
  134. steps:
  135. - uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
  136. with:
  137. egress-policy: audit
  138. - name: Checkout
  139. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
  140. with:
  141. fetch-depth: 0
  142. - name: Setup Go
  143. uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
  144. id: setup-go
  145. with:
  146. go-version-file: "go.mod"
  147. - name: Download Go modules
  148. run: go mod download
  149. - name: Login to Docker
  150. uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
  151. with:
  152. registry: ghcr.io
  153. username: ${{ github.actor }}
  154. password: ${{ secrets.GITHUB_TOKEN }}
  155. - name: Promote Container Image
  156. run: make docker.promote
  157. - name: Build release manifests
  158. env:
  159. RELEASE_VERSION: ${{ github.event.inputs.version }}
  160. run: |
  161. # temporarily patch the version so we generate manifests with the new version
  162. yq e -i ".version = \"$RELEASE_VERSION\"" ./deploy/charts/external-secrets/Chart.yaml
  163. yq e -i ".appVersion = \"$RELEASE_VERSION\"" ./deploy/charts/external-secrets/Chart.yaml
  164. make manifests
  165. - name: Sign promoted image
  166. id: sign
  167. uses: ./.github/actions/sign
  168. with:
  169. image-name: ${{ env.IMAGE_NAME }}
  170. image-tag: ${{ env.RELEASE_TAG }}
  171. - name: Update Release
  172. uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
  173. with:
  174. tag_name: ${{ github.event.inputs.version }}
  175. files: |
  176. provenance.${{ env.RELEASE_TAG }}.intoto.jsonl
  177. sbom.${{ env.RELEASE_TAG }}.spdx.json
  178. bin/deploy/manifests/external-secrets.yaml
  179. env:
  180. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"