release.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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: Cache Docker layers
  83. uses: actions/cache@v2
  84. with:
  85. path: /tmp/.buildx-cache
  86. key: ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-${{ github.sha }}
  87. restore-keys: |
  88. ${{ runner.os }}-buildx-app-${{ matrix.flavor }}-
  89. ${{ runner.os }}-buildx-app-
  90. - name: Build and push
  91. uses: docker/build-push-action@v2
  92. with:
  93. context: .
  94. file: ./docker/Dockerfile
  95. platforms: linux/amd64
  96. push: true
  97. cache-from: type=local,src=/tmp/.buildx-cache
  98. cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
  99. tags: ${{ steps.meta.outputs.tags }}
  100. - name: Move cache
  101. run: |
  102. rm -rf /tmp/.buildx-cache
  103. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  104. - name: Update Docker Hub Description
  105. uses: peter-evans/dockerhub-description@v2
  106. with:
  107. username: wsmoogle
  108. password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
  109. repository: weseek/growi
  110. readme-filepath: ./docker/README.md
  111. - name: Slack Notification
  112. uses: weseek/ghaction-release-slack-notification@master
  113. with:
  114. channel: '#release'
  115. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  116. created_tag: 'v${{ needs.github-release.outputs.RELEASE_VERSION }}${{ steps.suffix.outputs.SUFFIX }}'
  117. - name: Check whether workspace is clean
  118. run: |
  119. STATUS=`git status --porcelain`
  120. if [ -z "$STATUS" ]; then exit 0; else exit 1; fi