release-candidate.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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@v3
  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@v3
  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@v3
  32. with:
  33. node-version: lts/*
  34. - name: Install dependencies
  35. run: corepack yarn install --immutable
  36. env:
  37. # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
  38. CYPRESS_INSTALL_BINARY: 0
  39. - name: Bump candidate packages version
  40. run: corepack yarn version apply --all --json | jq -s > releases.json
  41. - name: Prepare changelog
  42. run: corepack yarn workspace @uppy-dev/release update-changelogs releases.json | xargs git add
  43. - name: Update contributors table
  44. run: corepack yarn contributors:save && corepack yarn remark -foq README.md && git add README.md
  45. - name: Update CDN URLs
  46. run: corepack yarn workspace @uppy-dev/release update-version-URLs | xargs git add
  47. - name: Stage changes and remove temp files
  48. run: |
  49. git rm -rf .yarn/versions
  50. git rm CHANGELOG.next.md
  51. jq -r 'map(.cwd) | join("\n")' < releases.json | awk '{ print "git add " $0 "/package.json" }' | sh
  52. - name: Commit
  53. run: |
  54. echo "Release: uppy@$(jq -r 'map(select(.ident == "uppy"))[0].newVersion' < releases.json)" > commitMessage
  55. echo >> commitMessage
  56. echo "This is a release candidate for the following packages:" >> commitMessage
  57. echo >> commitMessage
  58. jq -r 'map("- `"+.ident+"`: "+.oldVersion+" -> "+.newVersion) | join("\n") ' < releases.json >> commitMessage
  59. git commit -n --amend --file commitMessage
  60. - name: Open Pull Request
  61. id: pr_opening
  62. run: |
  63. git push origin HEAD:release-candidate
  64. gh api repos/${{ github.repository }}/pulls \
  65. -F base="$(gh api /repos/${{ github.repository }} | jq -r .default_branch)" \
  66. -F head="release-candidate" \
  67. -F title="$(head -1 commitMessage)" \
  68. -F body="$(git --no-pager diff HEAD^ -- CHANGELOG.md | awk '{ if( substr($0,0,1) == "+" && $1 != "+##" && $1 != "+Released:" && $1 != "+++" ) { print substr($0,2) } }')" \
  69. --jq '.number | tostring | "##[set-output name=pr_number;]"+.'
  70. env:
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. - name: Assign to the releaser
  73. run: echo '{"assignees":[${{ toJSON(github.actor) }}]}' | gh api repos/${{ github.repository }}/issues/${{ steps.pr_opening.outputs.pr_number }}/assignees --input -
  74. env:
  75. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  76. - name: Enable Release workflow
  77. run: gh workflow enable Release --repo ${{ github.repository }}
  78. env:
  79. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}