release-candidate.yml 3.6 KB

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