release.yml 5.3 KB

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