release-candidate.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. name: Release candidate
  2. on:
  3. push:
  4. branches: release
  5. jobs:
  6. prepare-release:
  7. name: Prepare release candidate Pull Request
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Checkout sources
  11. uses: actions/checkout@v2
  12. with:
  13. branch: release
  14. - name: Rebase
  15. run: |
  16. git fetch origin HEAD --depth=1
  17. git config --global user.email "actions@github.com"
  18. git config --global user.name "GitHub Actions"
  19. git rebase FETCH_HEAD
  20. - name: Get yarn cache directory path
  21. id: yarn-cache-dir-path
  22. run: echo "::set-output name=dir::$(corepack yarn config get cacheFolder)"
  23. - uses: actions/cache@v2
  24. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  25. with:
  26. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  27. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  28. restore-keys: |
  29. ${{ runner.os }}-yarn-
  30. - name: Install Node.js
  31. uses: actions/setup-node@v2
  32. with:
  33. node-version: 16.x
  34. - name: Install dependencies
  35. run: corepack yarn install --immutable
  36. - name: Bump candidate packages version
  37. run: corepack yarn version apply --all --json | jq -s > releases.json
  38. - name: Prepare changelog
  39. run: corepack yarn workspace @uppy-dev/release update-changelogs releases.json | xargs git add
  40. - name: Update contributors table
  41. run: corepack yarn contributors:save && corepack yarn remark -foq README.md && git add README.md
  42. - name: Update CDN URLs
  43. run: corepack yarn workspace @uppy-dev/release update-version-URLs | xargs git add
  44. - name: Stage changes and remove temp files
  45. run: |
  46. git rm -rf .yarn/versions
  47. git rm CHANGELOG.next.md
  48. jq -r 'map(.cwd) | join("\n")' < releases.json | awk '{ print "git add " $0 "/package.json" }' | sh
  49. - name: Commit
  50. run: |
  51. echo "Release: uppy@$(jq -r 'map(select(.ident == "uppy"))[0].newVersion' < releases.json)" > commitMessage
  52. echo >> commitMessage
  53. echo "This is a release candidate for the following packages:" >> commitMessage
  54. echo >> commitMessage
  55. jq -r 'map("- `"+.ident+"`: "+.oldVersion+" -> "+.newVersion) | join("\n") ' < releases.json >> commitMessage
  56. git commit -n --amend --file commitMessage
  57. - name: Open Pull Request
  58. id: pr_opening
  59. run: |
  60. git push origin HEAD:release-candidate
  61. gh api repos/${{ github.repository }}/pulls \
  62. -F base="$(gh api /repos/${{ github.repository }} | jq -r .default_branch)" \
  63. -F head="release-candidate" \
  64. -F title="$(head -1 commitMessage)" \
  65. -F body="$(git --no-pager diff HEAD^ -- CHANGELOG.md | awk '{ if( substr($0,0,1) == "+" && $1 != "+##" && $1 != "+Released:" && $1 != "+++" ) { print substr($0,2) } }')" \
  66. --jq '.number | tostring | "##[set-output name=pr_number;]"+.'
  67. env:
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. - name: Assign to the releaser
  70. run: echo '{"assignees":[${{ toJSON(github.actor) }}]}' | gh api repos/${{ github.repository }}/issues/${{ steps.pr_opening.outputs.pr_number }}/assignees --input -
  71. env:
  72. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  73. - name: Enable Release workflow
  74. run: gh workflow enable Release --repo ${{ github.repository }}
  75. env:
  76. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}