release.yml 3.6 KB

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