release-candidate.yml 3.7 KB

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