release.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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@v3
  50. with:
  51. go-version-file: "go.mod"
  52. - name: Update Docs
  53. run: make docs.publish DOCS_VERSION=${{ github.event.inputs.version }} DOCS_ALIAS=latest
  54. env:
  55. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  56. promote:
  57. name: Promote Container Image
  58. runs-on: ubuntu-latest
  59. strategy:
  60. matrix:
  61. include:
  62. - tag_suffix: "" # distroless image
  63. - tag_suffix: "-ubi" # ubi image
  64. - tag_suffix: "-ubi-boringssl" # ubi image
  65. permissions:
  66. id-token: write
  67. contents: write
  68. env:
  69. SOURCE_TAG: main${{ matrix.tag_suffix }}
  70. RELEASE_TAG: ${{ github.event.inputs.version }}${{ matrix.tag_suffix }}
  71. steps:
  72. - name: Checkout
  73. uses: actions/checkout@v3
  74. with:
  75. fetch-depth: 0
  76. - name: Setup Go
  77. uses: actions/setup-go@v3
  78. with:
  79. go-version-file: "go.mod"
  80. - name: Find the Go Cache
  81. id: go
  82. run: |
  83. echo "::set-output name=build-cache::$(go env GOCACHE)"
  84. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  85. - name: Cache the Go Build Cache
  86. uses: actions/cache@v3
  87. with:
  88. path: ${{ steps.go.outputs.build-cache }}
  89. key: ${{ runner.os }}-build-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  90. - name: Cache Go Dependencies
  91. uses: actions/cache@v3
  92. with:
  93. path: ${{ steps.go.outputs.mod-cache }}
  94. key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  95. - name: Login to Docker
  96. uses: docker/login-action@v2
  97. with:
  98. registry: ghcr.io
  99. username: ${{ secrets.GHCR_USERNAME }}
  100. password: ${{ secrets.GHCR_TOKEN }}
  101. - name: Promote Container Image
  102. run: make docker.promote
  103. - name: Build release manifests
  104. run: make manifests
  105. - name: Sign promoted image
  106. id: sign
  107. uses: ./.github/actions/sign
  108. with:
  109. image-name: ${{ env.IMAGE_NAME }}
  110. image-tag: ${{ env.RELEASE_TAG }}
  111. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  112. GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
  113. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  114. - name: Update Release
  115. uses: softprops/action-gh-release@v1
  116. with:
  117. tag_name: ${{ github.event.inputs.version }}
  118. files: |
  119. provenance.${{ env.RELEASE_TAG }}.intoto.jsonl
  120. sbom.${{ env.RELEASE_TAG }}.spdx.json
  121. bin/deploy/manifests/external-secrets.yaml
  122. env:
  123. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"