release-candidate.yml 3.8 KB

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