release.yml 4.4 KB

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