release.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. - name: Create Release
  25. uses: softprops/action-gh-release@v1
  26. with:
  27. tag_name: ${{ github.event.inputs.version }}
  28. env:
  29. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  30. - name: Build Changelog
  31. id: build_changelog
  32. uses: mikepenz/release-changelog-builder-action@v4
  33. with:
  34. configuration: "changelog.json"
  35. toTag: ${{ github.event.inputs.version }}
  36. commitMode: true
  37. env:
  38. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  39. - name: create changelog file
  40. run: |
  41. echo "Image: \`${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}\`" >> .changelog
  42. echo "Image: \`${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi\`" >> .changelog
  43. echo "Image: \`${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi-boringssl\`" >> .changelog
  44. echo "${{ steps.build_changelog.outputs.changelog }}" >> .changelog
  45. - name: Update Release
  46. uses: softprops/action-gh-release@v1
  47. with:
  48. tag_name: ${{ github.event.inputs.version }}
  49. body_path: .changelog
  50. env:
  51. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  52. - name: Setup Go
  53. uses: actions/setup-go@v4
  54. with:
  55. go-version-file: "go.mod"
  56. - name: Configure Git
  57. run: |
  58. git config user.name "$GITHUB_ACTOR"
  59. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  60. - name: Update Docs
  61. if: github.ref == 'refs/heads/main'
  62. run: make docs.publish DOCS_VERSION=${{ github.event.inputs.version }} DOCS_ALIAS=latest
  63. env:
  64. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  65. promote:
  66. name: Promote Container Image
  67. runs-on: ubuntu-latest
  68. strategy:
  69. matrix:
  70. include:
  71. - tag_suffix: "" # distroless image
  72. - tag_suffix: "-ubi" # ubi image
  73. - tag_suffix: "-ubi-boringssl" # ubi image
  74. permissions:
  75. id-token: write
  76. contents: write
  77. env:
  78. SOURCE_TAG: ${{ github.event.inputs.source_ref }}${{ matrix.tag_suffix }}
  79. RELEASE_TAG: ${{ github.event.inputs.version }}${{ matrix.tag_suffix }}
  80. steps:
  81. - name: Checkout
  82. uses: actions/checkout@v3
  83. with:
  84. fetch-depth: 0
  85. - name: Setup Go
  86. uses: actions/setup-go@v4
  87. with:
  88. go-version-file: "go.mod"
  89. - name: Find the Go Cache
  90. id: go
  91. run: |
  92. echo "::set-output name=build-cache::$(go env GOCACHE)"
  93. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  94. - name: Cache the Go Build Cache
  95. uses: actions/cache@v3
  96. with:
  97. path: ${{ steps.go.outputs.build-cache }}
  98. key: ${{ runner.os }}-build-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  99. - name: Cache Go Dependencies
  100. uses: actions/cache@v3
  101. with:
  102. path: ${{ steps.go.outputs.mod-cache }}
  103. key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  104. - name: Login to Docker
  105. uses: docker/login-action@v2
  106. with:
  107. registry: ghcr.io
  108. username: ${{ secrets.GHCR_USERNAME }}
  109. password: ${{ secrets.GHCR_TOKEN }}
  110. - name: Promote Container Image
  111. run: make docker.promote
  112. - name: Build release manifests
  113. run: |
  114. # temporarily patch the version so we generate manifests with the new version
  115. yq e -i '.version = "${{ github.event.inputs.version }}"' ./deploy/charts/external-secrets/Chart.yaml
  116. yq e -i '.appVersion = "${{ github.event.inputs.version }}"' ./deploy/charts/external-secrets/Chart.yaml
  117. make manifests
  118. - name: Sign promoted image
  119. id: sign
  120. uses: ./.github/actions/sign
  121. with:
  122. image-name: ${{ env.IMAGE_NAME }}
  123. image-tag: ${{ env.RELEASE_TAG }}
  124. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  125. GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
  126. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  127. - name: Update Release
  128. uses: softprops/action-gh-release@v1
  129. with:
  130. tag_name: ${{ github.event.inputs.version }}
  131. files: |
  132. provenance.${{ env.RELEASE_TAG }}.intoto.jsonl
  133. sbom.${{ env.RELEASE_TAG }}.spdx.json
  134. bin/deploy/manifests/external-secrets.yaml
  135. env:
  136. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"