release.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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@0.0.2
  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. - name: Retrieve information from package.json
  78. uses: myrotvorets/info-from-package-json-action@0.0.2
  79. id: package-json
  80. - name: Commit
  81. uses: github-actions-x/commit@v2.8
  82. with:
  83. github-token: ${{ secrets.GITHUB_TOKEN }}
  84. push-branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
  85. commit-message: 'Bump version'
  86. name: GitHub Action
  87. - name: Create PR
  88. uses: repo-sync/pull-request@v2
  89. with:
  90. source_branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
  91. destination_branch: master
  92. pr_title: Prepare v${{ steps.package-json.outputs.packageVersion }}
  93. pr_label: exclude from changelog
  94. pr_body: "An automated PR generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
  95. github_token: ${{ secrets.GITHUB_TOKEN }}
  96. build-image:
  97. needs: create-github-release
  98. runs-on: ubuntu-latest
  99. strategy:
  100. matrix:
  101. flavor: [default, nocdn]
  102. steps:
  103. - uses: actions/checkout@v2
  104. with:
  105. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  106. - name: Setup suffix
  107. id: suffix
  108. run: |
  109. [[ ${{ matrix.flavor }} = "nocdn" ]] && suffix="-nocdn" || suffix=""
  110. echo "::set-output name=SUFFIX::$suffix"
  111. - name: Docker meta
  112. id: meta
  113. uses: docker/metadata-action@v3
  114. with:
  115. images: weseek/growi,ghcr.io/weseek/growi
  116. flavor: |
  117. suffix=${{ steps.suffix.outputs.SUFFIX }}
  118. tags: |
  119. type=raw,value=latest
  120. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}
  121. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}
  122. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  123. - name: Login to docker.io registry
  124. run: |
  125. echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
  126. - name: Login to GitHub Container Registry
  127. uses: docker/login-action@v1
  128. with:
  129. registry: ghcr.io
  130. username: wsmoogle
  131. password: ${{ secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  132. - name: Set up Docker Buildx
  133. uses: docker/setup-buildx-action@v1
  134. - name: Cache Docker layers
  135. uses: actions/cache@v2
  136. with:
  137. path: /tmp/.buildx-cache
  138. key: ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-${{ github.sha }}
  139. restore-keys: |
  140. ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-
  141. ${{ runner.os }}-buildx-app-
  142. - name: Build and push
  143. uses: docker/build-push-action@v2
  144. with:
  145. context: .
  146. file: ./packages/app/docker/Dockerfile
  147. platforms: linux/amd64
  148. push: true
  149. cache-from: type=local,src=/tmp/.buildx-cache
  150. cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
  151. tags: ${{ steps.meta.outputs.tags }}
  152. - name: Move cache
  153. run: |
  154. rm -rf /tmp/.buildx-cache
  155. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  156. - name: Update Docker Hub Description
  157. uses: peter-evans/dockerhub-description@v2
  158. with:
  159. username: wsmoogle
  160. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  161. repository: weseek/growi
  162. readme-filepath: ./packages/app/docker/README.md
  163. - name: Slack Notification
  164. uses: weseek/ghaction-release-slack-notification@master
  165. with:
  166. channel: '#release'
  167. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  168. created_tag: 'v${{ needs.create-github-release.outputs.RELEASED_VERSION }}${{ steps.suffix.outputs.SUFFIX }}'
  169. - name: Check whether workspace is clean
  170. run: |
  171. STATUS=`git status --porcelain`
  172. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi