release.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. GO_VERSION: '1.17'
  12. jobs:
  13. release:
  14. name: Create Release
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Checkout
  18. uses: actions/checkout@v3
  19. with:
  20. fetch-depth: 0
  21. - name: Create Release
  22. uses: softprops/action-gh-release@v1
  23. with:
  24. tag_name: ${{ github.event.inputs.version }}
  25. env:
  26. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  27. - name: Build Changelog
  28. id: build_changelog
  29. uses: mikepenz/release-changelog-builder-action@v2
  30. with:
  31. configuration: "changelog.json"
  32. toTag: ${{ github.event.inputs.version }}
  33. commitMode: true
  34. env:
  35. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  36. - name: create changelog file
  37. env:
  38. VERSION: ${{ github.event.inputs.version }}
  39. CHANGELOG: ${{ steps.build_changelog.outputs.changelog }}
  40. run: |
  41. echo "Image: \`ghcr.io/${GITHUB_REPOSITORY}:${VERSION}\`" >> .changelog
  42. echo "${CHANGELOG}" >> .changelog
  43. - name: Update Release
  44. uses: softprops/action-gh-release@v1
  45. with:
  46. tag_name: ${{ github.event.inputs.version }}
  47. body_path: .changelog
  48. env:
  49. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  50. - name: Setup Go
  51. uses: actions/setup-go@v2
  52. with:
  53. go-version: ${{ env.GO_VERSION }}
  54. - name: Update Docs
  55. run: make docs.publish DOCS_VERSION=${{ github.event.inputs.version }} DOCS_ALIAS=latest
  56. env:
  57. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  58. promote:
  59. name: Promote Container Image
  60. runs-on: ubuntu-latest
  61. permissions:
  62. id-token: write
  63. contents: read
  64. steps:
  65. - name: Checkout
  66. uses: actions/checkout@v3
  67. with:
  68. fetch-depth: 0
  69. - name: Login to Docker
  70. uses: docker/login-action@v1
  71. if: env.GHCR_USERNAME != ''
  72. with:
  73. registry: ghcr.io
  74. username: ${{ secrets.GHCR_USERNAME }}
  75. password: ${{ secrets.GHCR_TOKEN }}
  76. - name: Promote Container Image
  77. if: env.GHCR_USERNAME != ''
  78. run: make docker.promote
  79. env:
  80. RELEASE_TAG: ${{ github.event.inputs.version }}
  81. SOURCE_TAG: main
  82. - name: Set up crane
  83. if: env.GHCR_USERNAME != ''
  84. run: go install github.com/google/go-containerregistry/cmd/crane@v0.8.0
  85. - name: Install cosign
  86. if: env.GHCR_USERNAME != ''
  87. uses: sigstore/cosign-installer@main
  88. with:
  89. cosign-release: 'v1.6.0'
  90. - name: Sign Container Image
  91. if: env.GHCR_USERNAME != ''
  92. run: make docker.sign
  93. env:
  94. RELEASE_TAG: ${{ github.event.inputs.version }}
  95. SOURCE_TAG: main
  96. COSIGN_EXPERIMENTAL: 1