Prepare Release #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Prepare Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: Package to release | |
| required: true | |
| default: plugin-react | |
| type: choice | |
| options: | |
| - plugin-react | |
| - plugin-react-swc | |
| - plugin-rsc | |
| release: | |
| description: Bumpp release type | |
| required: true | |
| default: next | |
| type: choice | |
| options: | |
| - next | |
| - patch | |
| - minor | |
| - major | |
| - prepatch | |
| - preminor | |
| - premajor | |
| version: | |
| description: Specify exact version instead of bumpp release type | |
| required: false | |
| type: string | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ inputs.package }}-${{ inputs.version || inputs.release }} | |
| cancel-in-progress: false | |
| permissions: {} | |
| jobs: | |
| prepare: | |
| if: github.repository == 'vitejs/vite-plugin-react' | |
| name: Prepare release PR | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 | |
| - name: Set node version | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: 24 | |
| package-manager-cache: false | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --prefer-offline | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' | |
| - name: Prepare release | |
| id: prepare | |
| env: | |
| RELEASE: ${{ inputs.version || inputs.release }} | |
| RELEASE_PACKAGE: ${{ inputs.package }} | |
| run: | | |
| node scripts/prepare-release.ts "$RELEASE_PACKAGE" "$RELEASE" | |
| echo "version=$(jq -r .version packages/$RELEASE_PACKAGE/package.json)" >> "$GITHUB_OUTPUT" | |
| - id: generate-token | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| with: | |
| client-id: ${{ vars.RELEASE_GITHUB_APP_CLIENT_ID }} | |
| private-key: ${{ secrets.RELEASE_GITHUB_APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: ${{ github.event.repository.name }} | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - name: Open release PR | |
| env: | |
| APP_SLUG: ${{ steps.generate-token.outputs.app-slug }} | |
| GH_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| PACKAGE: ${{ inputs.package }} | |
| PR_BODY_FILE: ${{ runner.temp }}/release-pr-body.md | |
| VERSION: ${{ steps.prepare.outputs.version }} | |
| run: | | |
| BRANCH="release-$PACKAGE-$VERSION-$GITHUB_RUN_ID" | |
| BOT_ID="$(gh api "/users/$APP_SLUG%5Bbot%5D" --jq .id)" | |
| { | |
| echo "$PACKAGE release PR generated by the Prepare Release workflow: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
| echo | |
| echo "## Changelog" | |
| echo | |
| node scripts/extract-changelog.ts "packages/$PACKAGE/CHANGELOG.md" "$VERSION" | |
| } > "$PR_BODY_FILE" | |
| git config user.name "$APP_SLUG[bot]" | |
| git config user.email "$BOT_ID+$APP_SLUG[bot]@users.noreply.github.com" | |
| git switch -c "$BRANCH" | |
| git add "packages/$PACKAGE/package.json" "packages/$PACKAGE/CHANGELOG.md" | |
| git commit -m "release: $PACKAGE@$VERSION" | |
| git push -u "https://x-access-token:$GH_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD | |
| gh pr create \ | |
| --assignee "$GITHUB_ACTOR" \ | |
| --base main \ | |
| --head "$BRANCH" \ | |
| --title "release: $PACKAGE@$VERSION" \ | |
| --body-file "$PR_BODY_FILE" |