release.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. name: Release
  2. on:
  3. push:
  4. branches:
  5. - release/current
  6. - release/*.*.*
  7. jobs:
  8. github-release:
  9. runs-on: ubuntu-latest
  10. outputs:
  11. RELEASE_VERSION: ${{ steps.bump-version.outputs.RELEASE_VERSION }}
  12. steps:
  13. - uses: actions/checkout@v2
  14. - name: Init Git
  15. run: |
  16. git config --local user.name "GitHub Action"
  17. git config --local user.email "info@weseek.co.jp"
  18. git remote set-url origin "https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY"
  19. - name: Bump version
  20. id: bump-version
  21. run: |
  22. npm --no-git-tag-version version patch
  23. export RELEASE_VERSION=`npm run version --silent`
  24. sh ./bin/github-actions/update-readme.sh
  25. echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
  26. echo ::set-output name=RELEASE_VERSION::$RELEASE_VERSION
  27. - name: Checkout, Commit, Tag and Push
  28. run: |
  29. TMP_RELEASE_BRANCH=tmp/release-${{ env.RELEASE_VERSION }}
  30. git checkout -B $TMP_RELEASE_BRANCH
  31. git commit -am "Release v${{ env.RELEASE_VERSION }}"
  32. git tag -a v${{ env.RELEASE_VERSION }} -m "v${{ env.RELEASE_VERSION }}"
  33. git push --follow-tags origin $TMP_RELEASE_BRANCH
  34. git push --delete origin $TMP_RELEASE_BRANCH
  35. - name: Upload release notes
  36. uses: Roang-zero1/github-create-release-action@master
  37. with:
  38. created_tag: v${{ env.RELEASE_VERSION }}
  39. changelog_file: CHANGES.md
  40. env:
  41. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  42. build-image:
  43. needs: github-release
  44. runs-on: ubuntu-latest
  45. strategy:
  46. matrix:
  47. flavor: [default, nocdn]
  48. steps:
  49. - uses: actions/checkout@v2
  50. - name: Checkout released tag
  51. run: |
  52. git fetch --tags
  53. git checkout refs/tags/v${{ needs.github-release.outputs.RELEASE_VERSION }}
  54. - name: Setup suffix
  55. id: suffix
  56. run: |
  57. [[ ${{ matrix.flavor }} = "nocdn" ]] && suffix="-nocdn" || suffix=""
  58. echo "::set-output name=SUFFIX::$suffix"
  59. - name: Docker meta
  60. id: meta
  61. uses: docker/metadata-action@v3
  62. with:
  63. images: weseek/growi,ghcr.io/weseek/growi
  64. flavor: |
  65. suffix=${{ steps.suffix.outputs.SUFFIX }}
  66. tags: |
  67. type=raw,value=latest
  68. type=semver,value=${{ needs.github-release.outputs.RELEASE_VERSION }},pattern={{major}}
  69. type=semver,value=${{ needs.github-release.outputs.RELEASE_VERSION }},pattern={{major}}.{{minor}}
  70. type=semver,value=${{ needs.github-release.outputs.RELEASE_VERSION }},pattern={{major}}.{{minor}}.{{patch}}
  71. - name: Login to docker.io registry
  72. run: |
  73. echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
  74. - name: Login to GitHub Container Registry
  75. uses: docker/login-action@v1
  76. with:
  77. registry: ghcr.io
  78. username: wsmoogle
  79. password: ${{ secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  80. - name: Set up Docker Buildx
  81. uses: docker/setup-buildx-action@v1
  82. - name: Build and push
  83. uses: docker/build-push-action@v2
  84. with:
  85. context: .
  86. file: ./docker/Dockerfile
  87. platforms: linux/amd64
  88. push: true
  89. tags: ${{ steps.meta.outputs.tags }}
  90. - name: Update Docker Hub Description
  91. uses: peter-evans/dockerhub-description@v2
  92. with:
  93. username: wsmoogle
  94. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  95. repository: weseek/growi
  96. readme-filepath: ./docker/README.md
  97. - name: Slack Notification
  98. uses: weseek/ghaction-release-slack-notification@master
  99. with:
  100. channel: '#release'
  101. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  102. created_tag: 'v${{ needs.github-release.outputs.RELEASE_VERSION }}${{ env.SUFFIX }}'
  103. - name: Check whether workspace is clean
  104. run: |
  105. STATUS=`git status --porcelain`
  106. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi