release.yml 6.9 KB

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