release.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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@v2
  16. with:
  17. ref: ${{ github.event.pull_request.base.ref }}
  18. - uses: actions/setup-node@v2
  19. with:
  20. node-version: '14'
  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. node ./bin/github-actions/bump-versions -i patch
  29. sh ./packages/app/bin/github-actions/update-readme.sh
  30. - name: Retrieve information from package.json
  31. uses: myrotvorets/info-from-package-json-action@1.1.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: ./packages/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@v2
  64. with:
  65. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  66. - uses: actions/setup-node@v2
  67. with:
  68. node-version: '14'
  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. node ./bin/github-actions/bump-versions -i prerelease
  77. node ./bin/github-actions/bump-versions -i prerelease -d packages/slackbot-proxy --preid slackbot-proxy --update-dependencies false
  78. - name: Retrieve information from package.json
  79. uses: myrotvorets/info-from-package-json-action@1.1.0
  80. id: package-json
  81. - name: Commit
  82. uses: github-actions-x/commit@v2.8
  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
  95. pr_body: "An automated PR generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
  96. github_token: ${{ secrets.GITHUB_TOKEN }}
  97. build-image:
  98. needs: create-github-release
  99. runs-on: ubuntu-latest
  100. strategy:
  101. matrix:
  102. flavor: [default, nocdn]
  103. steps:
  104. - uses: actions/checkout@v2
  105. with:
  106. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  107. lfs: true
  108. - name: Setup suffix
  109. id: suffix
  110. run: |
  111. [[ ${{ matrix.flavor }} = "nocdn" ]] && suffix="-nocdn" || suffix=""
  112. echo "::set-output name=SUFFIX::$suffix"
  113. - name: Docker meta
  114. id: meta
  115. uses: docker/metadata-action@v3
  116. with:
  117. images: weseek/growi,ghcr.io/weseek/growi
  118. flavor: |
  119. suffix=${{ steps.suffix.outputs.SUFFIX }}
  120. tags: |
  121. type=raw,value=latest
  122. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}
  123. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}
  124. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  125. - name: Login to docker.io registry
  126. run: |
  127. echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
  128. - name: Login to GitHub Container Registry
  129. uses: docker/login-action@v1
  130. with:
  131. registry: ghcr.io
  132. username: wsmoogle
  133. password: ${{ secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  134. - name: Set up Docker Buildx
  135. uses: docker/setup-buildx-action@v1
  136. - name: Cache Docker layers
  137. uses: actions/cache@v2
  138. with:
  139. path: /tmp/.buildx-cache
  140. key: ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-${{ github.sha }}
  141. restore-keys: |
  142. ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-
  143. ${{ runner.os }}-buildx-app-
  144. - name: Build and push
  145. uses: docker/build-push-action@v2
  146. with:
  147. context: .
  148. file: ./packages/app/docker/Dockerfile
  149. platforms: linux/amd64
  150. push: true
  151. build-args: |
  152. flavor=${{ matrix.flavor }}
  153. cache-from: type=local,src=/tmp/.buildx-cache
  154. cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
  155. tags: ${{ steps.meta.outputs.tags }}
  156. - name: Move cache
  157. run: |
  158. rm -rf /tmp/.buildx-cache
  159. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  160. - name: Update Docker Hub Description
  161. uses: peter-evans/dockerhub-description@v2
  162. with:
  163. username: wsmoogle
  164. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  165. repository: weseek/growi
  166. readme-filepath: ./packages/app/docker/README.md
  167. - name: Slack Notification
  168. uses: weseek/ghaction-release-slack-notification@master
  169. with:
  170. channel: '#release'
  171. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  172. created_tag: 'v${{ needs.create-github-release.outputs.RELEASED_VERSION }}${{ steps.suffix.outputs.SUFFIX }}'
  173. - name: Check whether workspace is clean
  174. run: |
  175. STATUS=`git status --porcelain`
  176. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi