release.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  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. env:
  37. VERSION: ${{ github.event.inputs.version }}
  38. CHANGELOG: ${{ steps.build_changelog.outputs.changelog }}
  39. run: |
  40. echo "Image: \`ghcr.io/${GITHUB_REPOSITORY}:${VERSION}\`" >> .changelog
  41. echo "${CHANGELOG}" >> .changelog
  42. - name: Update Release
  43. uses: softprops/action-gh-release@v1
  44. with:
  45. tag_name: ${{ github.event.inputs.version }}
  46. body_path: .changelog
  47. env:
  48. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  49. - name: Setup Go
  50. uses: actions/setup-go@v3
  51. with:
  52. go-version-file: "go.mod"
  53. - name: Update Docs
  54. run: make docs.publish DOCS_VERSION=${{ github.event.inputs.version }} DOCS_ALIAS=latest
  55. env:
  56. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  57. promote:
  58. name: Promote Container Image
  59. runs-on: ubuntu-latest
  60. permissions:
  61. id-token: write
  62. contents: read
  63. steps:
  64. - name: Checkout
  65. uses: actions/checkout@v3
  66. with:
  67. fetch-depth: 0
  68. - name: Setup Go
  69. uses: actions/setup-go@v3
  70. with:
  71. go-version-file: "go.mod"
  72. - name: Find the Go Cache
  73. id: go
  74. run: |
  75. echo "::set-output name=build-cache::$(go env GOCACHE)"
  76. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  77. - name: Cache the Go Build Cache
  78. uses: actions/cache@v3
  79. with:
  80. path: ${{ steps.go.outputs.build-cache }}
  81. key: ${{ runner.os }}-build-publish-artifacts-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  82. restore-keys: ${{ runner.os }}-build-publish-artifacts-${{ github.sha }}-
  83. - name: Cache Go Dependencies
  84. uses: actions/cache@v3
  85. with:
  86. path: ${{ steps.go.outputs.mod-cache }}
  87. key: ${{ runner.os }}-pkg-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  88. restore-keys: ${{ runner.os }}-pkg-${{ github.sha }}-
  89. - name: Login to Docker
  90. uses: docker/login-action@v2
  91. if: env.GHCR_USERNAME != ''
  92. with:
  93. registry: ghcr.io
  94. username: ${{ secrets.GHCR_USERNAME }}
  95. password: ${{ secrets.GHCR_TOKEN }}
  96. - name: Promote Container Image
  97. if: env.GHCR_USERNAME != ''
  98. run: make docker.promote
  99. env:
  100. RELEASE_TAG: ${{ github.event.inputs.version }}
  101. SOURCE_TAG: main
  102. - name: Set up crane
  103. if: env.GHCR_USERNAME != ''
  104. run: go install github.com/google/go-containerregistry/cmd/crane@v0.8.0
  105. - name: Install cosign
  106. if: env.GHCR_USERNAME != ''
  107. uses: sigstore/cosign-installer@v2.6.0
  108. - name: Sign Container Image
  109. if: env.GHCR_USERNAME != ''
  110. run: make docker.sign
  111. env:
  112. RELEASE_TAG: ${{ github.event.inputs.version }}
  113. SOURCE_TAG: main
  114. COSIGN_EXPERIMENTAL: true