release.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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/bump-versions -i patch
  29. - name: Retrieve information from package.json
  30. uses: myrotvorets/info-from-package-json-action@0.0.2
  31. id: package-json
  32. - name: Update Changelog
  33. uses: stefanzweifel/changelog-updater-action@v1
  34. with:
  35. latest-version: v${{ steps.package-json.outputs.packageVersion }}
  36. release-notes: ${{ github.event.pull_request.body }}
  37. - name: Commit, Tag and Push
  38. uses: stefanzweifel/git-auto-commit-action@v4
  39. with:
  40. branch: ${{ github.event.pull_request.base.ref }}
  41. commit_message: Release v${{ steps.package-json.outputs.packageVersion }}
  42. tagging_message: v${{ steps.package-json.outputs.packageVersion }}
  43. - uses: ncipollo/release-action@v1
  44. with:
  45. body: ${{ github.event.pull_request.body }}
  46. tag: v${{ steps.package-json.outputs.packageVersion }}
  47. token: ${{ secrets.GITHUB_TOKEN }}
  48. - name: Delete drafts
  49. uses: hugo19941994/delete-draft-releases@v1.0.0
  50. env:
  51. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  52. create-pr-for-next-rc:
  53. needs: create-github-release
  54. runs-on: ubuntu-latest
  55. steps:
  56. - uses: actions/checkout@v2
  57. with:
  58. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  59. - uses: actions/setup-node@v2
  60. with:
  61. node-version: '14'
  62. cache: 'yarn'
  63. cache-dependency-path: '**/yarn.lock'
  64. - name: Install dependencies
  65. run: |
  66. npx lerna bootstrap
  67. - name: Bump versions for next RC
  68. run: |
  69. node ./bin/bump-versions -i prerelease
  70. - name: Retrieve information from package.json
  71. uses: myrotvorets/info-from-package-json-action@0.0.2
  72. id: package-json
  73. - name: Commit
  74. uses: github-actions-x/commit@v2.8
  75. with:
  76. github-token: ${{ secrets.GITHUB_TOKEN }}
  77. push-branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
  78. commit-message: 'Bump version'
  79. name: GitHub Action
  80. - name: Create PR
  81. uses: repo-sync/pull-request@v2
  82. with:
  83. source_branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
  84. destination_branch: master
  85. pr_title: Prepare v${{ steps.package-json.outputs.packageVersion }}
  86. pr_label: exclude from changelog
  87. pr_body: "An automated PR generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
  88. github_token: ${{ secrets.GITHUB_TOKEN }}
  89. build-image:
  90. needs: create-github-release
  91. runs-on: ubuntu-latest
  92. strategy:
  93. matrix:
  94. flavor: [default, nocdn]
  95. steps:
  96. - uses: actions/checkout@v2
  97. with:
  98. ref: v${{ needs.create-github-release.outputs.RELEASED_VERSION }}
  99. - name: Setup suffix
  100. id: suffix
  101. run: |
  102. [[ ${{ matrix.flavor }} = "nocdn" ]] && suffix="-nocdn" || suffix=""
  103. echo "::set-output name=SUFFIX::$suffix"
  104. - name: Docker meta
  105. id: meta
  106. uses: docker/metadata-action@v3
  107. with:
  108. images: weseek/growi,ghcr.io/weseek/growi
  109. flavor: |
  110. suffix=${{ steps.suffix.outputs.SUFFIX }}
  111. tags: |
  112. type=raw,value=latest
  113. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}
  114. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}
  115. type=semver,value=${{ needs.create-github-release.outputs.RELEASED_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  116. - name: Login to docker.io registry
  117. run: |
  118. echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
  119. - name: Login to GitHub Container Registry
  120. uses: docker/login-action@v1
  121. with:
  122. registry: ghcr.io
  123. username: wsmoogle
  124. password: ${{ secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  125. - name: Set up Docker Buildx
  126. uses: docker/setup-buildx-action@v1
  127. - name: Cache Docker layers
  128. uses: actions/cache@v2
  129. with:
  130. path: /tmp/.buildx-cache
  131. key: ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-${{ github.sha }}
  132. restore-keys: |
  133. ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-
  134. ${{ runner.os }}-buildx-app-
  135. - name: Build and push
  136. uses: docker/build-push-action@v2
  137. with:
  138. context: .
  139. file: ./packages/app/docker/Dockerfile
  140. platforms: linux/amd64
  141. push: true
  142. cache-from: type=local,src=/tmp/.buildx-cache
  143. cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
  144. tags: ${{ steps.meta.outputs.tags }}
  145. - name: Move cache
  146. run: |
  147. rm -rf /tmp/.buildx-cache
  148. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  149. - name: Update Docker Hub Description
  150. uses: peter-evans/dockerhub-description@v2
  151. with:
  152. username: wsmoogle
  153. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  154. repository: weseek/growi
  155. readme-filepath: ./packages/app/docker/README.md
  156. - name: Slack Notification
  157. uses: weseek/ghaction-release-slack-notification@master
  158. with:
  159. channel: '#release'
  160. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  161. created_tag: 'v${{ needs.create-github-release.outputs.RELEASED_VERSION }}${{ steps.suffix.outputs.SUFFIX }}'
  162. - name: Check whether workspace is clean
  163. run: |
  164. STATUS=`git status --porcelain`
  165. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi