release.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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: Setup Go
  70. uses: actions/setup-go@v2
  71. with:
  72. go-version: ${{ env.GO_VERSION }}
  73. - name: Find the Go Cache
  74. id: go
  75. run: |
  76. echo "::set-output name=build-cache::$(go env GOCACHE)"
  77. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  78. - name: Cache the Go Build Cache
  79. uses: actions/cache@v3
  80. with:
  81. path: ${{ steps.go.outputs.build-cache }}
  82. key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }}
  83. restore-keys: ${{ runner.os }}-build-publish-artifacts-
  84. - name: Cache Go Dependencies
  85. uses: actions/cache@v3
  86. with:
  87. path: ${{ steps.go.outputs.mod-cache }}
  88. key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
  89. restore-keys: ${{ runner.os }}-pkg-
  90. - name: Login to Docker
  91. uses: docker/login-action@v1
  92. if: env.GHCR_USERNAME != ''
  93. with:
  94. registry: ghcr.io
  95. username: ${{ secrets.GHCR_USERNAME }}
  96. password: ${{ secrets.GHCR_TOKEN }}
  97. - name: Promote Container Image
  98. if: env.GHCR_USERNAME != ''
  99. run: make docker.promote
  100. env:
  101. RELEASE_TAG: ${{ github.event.inputs.version }}
  102. SOURCE_TAG: main
  103. - name: Set up crane
  104. if: env.GHCR_USERNAME != ''
  105. run: go install github.com/google/go-containerregistry/cmd/crane@v0.8.0
  106. - name: Install cosign
  107. if: env.GHCR_USERNAME != ''
  108. uses: sigstore/cosign-installer@main
  109. with:
  110. cosign-release: 'v1.6.0'
  111. - name: Sign Container Image
  112. if: env.GHCR_USERNAME != ''
  113. run: make docker.sign
  114. env:
  115. RELEASE_TAG: ${{ github.event.inputs.version }}
  116. SOURCE_TAG: main
  117. COSIGN_EXPERIMENTAL: 1