|
| 1 | +name: Prepare Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + pull-requests: write |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: prepare-js-release-${{ github.ref_name }} |
| 12 | + cancel-in-progress: false |
| 13 | + |
| 14 | +env: |
| 15 | + HUSKY: "0" |
| 16 | + |
| 17 | +jobs: |
| 18 | + prepare-release: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 20 |
| 21 | + steps: |
| 22 | + - name: Require main branch |
| 23 | + run: | |
| 24 | + if [ "${{ github.ref_name }}" != "main" ]; then |
| 25 | + { |
| 26 | + echo "## Prepare JS release" |
| 27 | + echo |
| 28 | + echo "This workflow must be run from \`main\`. Selected ref: \`${{ github.ref_name }}\`." |
| 29 | + } >> "$GITHUB_STEP_SUMMARY" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
| 33 | + with: |
| 34 | + fetch-depth: 0 |
| 35 | + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 |
| 36 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 37 | + with: |
| 38 | + node-version-file: .tool-versions |
| 39 | + cache: pnpm |
| 40 | + - name: Install dependencies |
| 41 | + run: pnpm install --frozen-lockfile |
| 42 | + - name: Validate publishable package metadata |
| 43 | + run: node scripts/release/validate-publishable-packages.mjs |
| 44 | + - name: Record source commit and release branch |
| 45 | + id: source |
| 46 | + run: | |
| 47 | + main_sha="$(git rev-parse HEAD)" |
| 48 | + short_main_sha="$(git rev-parse --short=12 HEAD)" |
| 49 | + release_branch="release/${short_main_sha}" |
| 50 | +
|
| 51 | + { |
| 52 | + echo "main_sha=$main_sha" |
| 53 | + echo "short_main_sha=$short_main_sha" |
| 54 | + echo "release_branch=$release_branch" |
| 55 | + } >> "$GITHUB_OUTPUT" |
| 56 | + - name: Run changeset version |
| 57 | + run: pnpm exec changeset version |
| 58 | + - name: Create release commit |
| 59 | + run: | |
| 60 | + git config user.name "github-actions[bot]" |
| 61 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 62 | + git switch -c "${{ steps.source.outputs.release_branch }}" |
| 63 | + git add -A |
| 64 | + git commit -m "chore: Prepare changelog" |
| 65 | + git push origin HEAD:refs/heads/${{ steps.source.outputs.release_branch }} |
| 66 | + - name: Create release PR |
| 67 | + env: |
| 68 | + GH_TOKEN: ${{ github.token }} |
| 69 | + run: | |
| 70 | + gh pr create \ |
| 71 | + --base release \ |
| 72 | + --head "${{ steps.source.outputs.release_branch }}" \ |
| 73 | + --title "chore: Prepare for release (${{ steps.source.outputs.short_main_sha }})" \ |
| 74 | + --body "Prepares a release by updating changelogs and package versions, and synchronizing everything to the release branch." |
0 commit comments