release.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. name: Release
  2. on:
  3. pull_request:
  4. branches:
  5. - release/current
  6. - release/*.*.*
  7. types: [closed]
  8. jobs:
  9. create-github-release:
  10. runs-on: ubuntu-latest
  11. if: github.event.pull_request.merged == true
  12. outputs:
  13. RELEASED_VERSION: ${{ steps.package-json.outputs.packageVersion }}
  14. steps:
  15. - uses: actions/checkout@v3
  16. with:
  17. ref: ${{ github.event.pull_request.base.ref }}
  18. - uses: actions/setup-node@v3
  19. with:
  20. node-version: '16'
  21. cache: 'yarn'
  22. cache-dependency-path: '**/yarn.lock'
  23. - name: Install dependencies
  24. run: |
  25. npx lerna bootstrap
  26. - name: Bump versions
  27. run: |
  28. yarn bump-versions:patch
  29. sh ./apps/app/bin/github-actions/update-readme.sh
  30. - name: Retrieve information from package.json
  31. uses: myrotvorets/info-from-package-json-action@1.2.0
  32. id: package-json
  33. - name: Update Changelog
  34. uses: stefanzweifel/changelog-updater-action@v1
  35. with:
  36. latest-version: v${{ steps.package-json.outputs.packageVersion }}
  37. release-notes: ${{ github.event.pull_request.body }}
  38. - name: Update README.md for docker image
  39. working-directory: ./apps/app
  40. run: |
  41. sh ./bin/github-actions/update-readme.sh
  42. env:
  43. RELEASED_VERSION: ${{ steps.package-json.outputs.packageVersion }}
  44. - name: Commit, Tag and Push
  45. uses: stefanzweifel/git-auto-commit-action@v4
  46. with:
  47. branch: ${{ github.event.pull_request.base.ref }}
  48. commit_message: Release v${{ steps.package-json.outputs.packageVersion }}
  49. tagging_message: v${{ steps.package-json.outputs.packageVersion }}
  50. - uses: ncipollo/release-action@v1
  51. with:
  52. body: ${{ github.event.pull_request.body }}
  53. tag: v${{ steps.package-json.outputs.packageVersion }}
  54. token: ${{ secrets.GITHUB_TOKEN }}
  55. - name: Delete drafts
  56. uses: hugo19941994/delete-draft-releases@v1.0.0
  57. env:
  58. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  59. create-pr-for-next-rc:
  60. needs: create-github-release
  61. runs-on: ubuntu-latest
  62. steps:
  63. - uses: actions/checkout@v3
  64. with:
  65. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  66. - uses: actions/setup-node@v3
  67. with:
  68. node-version: '16'
  69. cache: 'yarn'
  70. cache-dependency-path: '**/yarn.lock'
  71. - name: Install dependencies
  72. run: |
  73. npx lerna bootstrap
  74. - name: Bump versions for next RC
  75. run: |
  76. yarn bump-versions:rc
  77. yarn bump-versions:slackbot-proxy
  78. - name: Retrieve information from package.json
  79. uses: myrotvorets/info-from-package-json-action@1.2.0
  80. id: package-json
  81. - name: Commit
  82. uses: github-actions-x/commit@v2.9
  83. with:
  84. github-token: ${{ secrets.GITHUB_TOKEN }}
  85. push-branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
  86. commit-message: 'Bump version'
  87. name: GitHub Action
  88. - name: Create PR
  89. uses: repo-sync/pull-request@v2
  90. with:
  91. source_branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
  92. destination_branch: master
  93. pr_title: Prepare v${{ steps.package-json.outputs.packageVersion }}
  94. pr_label: exclude from changelog,prepare next version
  95. pr_body: "An automated PR generated by create-pr-for-next-rc"
  96. github_token: ${{ secrets.GITHUB_TOKEN }}
  97. determine-tags:
  98. needs: create-github-release
  99. runs-on: ubuntu-latest
  100. outputs:
  101. TAGS: ${{ steps.meta.outputs.tags }}
  102. TAGS_GHCR: ${{ steps.meta-ghcr.outputs.tags }}
  103. steps:
  104. - uses: actions/checkout@v3
  105. - name: Retrieve information from package.json
  106. uses: myrotvorets/info-from-package-json-action@1.2.0
  107. id: package-json
  108. - name: Docker meta for docker.io
  109. uses: docker/metadata-action@v4
  110. id: meta
  111. with:
  112. images: docker.io/weseek/growi
  113. sep-tags: ','
  114. tags: |
  115. type=raw,value=latest
  116. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}
  117. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}
  118. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  119. - name: Docker meta for ghcr.io
  120. uses: docker/metadata-action@v4
  121. id: meta-ghcr
  122. with:
  123. images: ghcr.io/weseek/growi
  124. sep-tags: ','
  125. tags: |
  126. type=raw,value=latest
  127. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}
  128. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}
  129. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  130. build-image:
  131. needs: create-github-release
  132. uses: weseek/growi/.github/workflows/reusable-app-build-image.yml@master
  133. with:
  134. source-version: refs/tags/v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  135. image-name: weseek/growi
  136. tag-temporary: latest
  137. secrets:
  138. AWS_ROLE_TO_ASSUME_FOR_OIDC: ${{ secrets.AWS_ROLE_TO_ASSUME_FOR_OIDC }}
  139. publish-image:
  140. needs: [determine-tags, build-image]
  141. uses: weseek/growi/.github/workflows/reusable-app-create-manifests.yml@master
  142. with:
  143. tags: ${{ needs.determine-tags.outputs.TAGS }}
  144. registry: docker.io
  145. image-name: weseek/growi
  146. tag-temporary: latest
  147. secrets:
  148. DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  149. publish-image-ghcr:
  150. needs: [determine-tags, build-image]
  151. uses: weseek/growi/.github/workflows/reusable-app-create-manifests.yml@master
  152. with:
  153. tags: ${{ needs.determine-tags.outputs.TAGS_GHCR }}
  154. registry: ghcr.io
  155. image-name: weseek/growi
  156. tag-temporary: latest
  157. secrets:
  158. DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  159. post-publish:
  160. needs: [create-github-release, publish-image, publish-image-ghcr]
  161. runs-on: ubuntu-latest
  162. steps:
  163. - uses: actions/checkout@v3
  164. with:
  165. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  166. - name: Update Docker Hub Description
  167. uses: peter-evans/dockerhub-description@v3
  168. with:
  169. username: wsmoogle
  170. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  171. repository: weseek/growi
  172. readme-filepath: ./apps/app/docker/README.md
  173. - name: Slack Notification
  174. uses: weseek/ghaction-release-slack-notification@master
  175. with:
  176. channel: '#release'
  177. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  178. created_tag: 'v${{ needs.create-github-release.outputs.RELEASED_VERSION }}'
  179. - name: Check whether workspace is clean
  180. run: |
  181. STATUS=`git status --porcelain`
  182. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi