release.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. - name: Setup suffix
  108. id: suffix
  109. run: |
  110. [[ ${{ matrix.flavor }} = "nocdn" ]] && suffix="-nocdn" || suffix=""
  111. echo "::set-output name=SUFFIX::$suffix"
  112. - name: Docker meta
  113. id: meta
  114. uses: docker/metadata-action@v3
  115. with:
  116. images: weseek/growi,ghcr.io/weseek/growi
  117. flavor: |
  118. suffix=${{ steps.suffix.outputs.SUFFIX }}
  119. tags: |
  120. type=raw,value=latest
  121. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}
  122. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}
  123. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  124. - name: Login to docker.io registry
  125. run: |
  126. echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
  127. - name: Login to GitHub Container Registry
  128. uses: docker/login-action@v1
  129. with:
  130. registry: ghcr.io
  131. username: wsmoogle
  132. password: ${{ secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  133. - name: Set up Docker Buildx
  134. uses: docker/setup-buildx-action@v1
  135. - name: Cache Docker layers
  136. uses: actions/cache@v2
  137. with:
  138. path: /tmp/.buildx-cache
  139. key: ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-${{ github.sha }}
  140. restore-keys: |
  141. ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-
  142. ${{ runner.os }}-buildx-app-
  143. - name: Build and push
  144. uses: docker/build-push-action@v2
  145. with:
  146. context: .
  147. file: ./packages/app/docker/Dockerfile
  148. platforms: linux/amd64
  149. push: true
  150. cache-from: type=local,src=/tmp/.buildx-cache
  151. cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
  152. tags: ${{ steps.meta.outputs.tags }}
  153. - name: Move cache
  154. run: |
  155. rm -rf /tmp/.buildx-cache
  156. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  157. - name: Update Docker Hub Description
  158. uses: peter-evans/dockerhub-description@v2
  159. with:
  160. username: wsmoogle
  161. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  162. repository: weseek/growi
  163. readme-filepath: ./packages/app/docker/README.md
  164. - name: Slack Notification
  165. uses: weseek/ghaction-release-slack-notification@master
  166. with:
  167. channel: '#release'
  168. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  169. created_tag: 'v${{ needs.create-github-release.outputs.RELEASED_VERSION }}${{ steps.suffix.outputs.SUFFIX }}'
  170. - name: Check whether workspace is clean
  171. run: |
  172. STATUS=`git status --porcelain`
  173. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi