name: Prepare Publish on: workflow_dispatch: inputs: target_branch: description: Release target branch. required: true default: main type: string 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.target_branch }}-${{ inputs.version || inputs.release }} cancel-in-progress: false permissions: {} jobs: prepare: if: github.repository == 'vitest-dev/vitest' name: Prepare release PR runs-on: ubuntu-latest permissions: contents: read # checkout target branch steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ inputs.target_branch }} fetch-depth: 0 persist-credentials: false - name: Install pnpm uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 - name: Set node version to 24 uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 24 package-manager-cache: false - name: Install run: pnpm install --frozen-lockfile --prefer-offline env: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' - name: Create branch and update version env: TARGET_BRANCH: ${{ inputs.target_branch }} RELEASE_TYPE: ${{ inputs.release }} RELEASE_VERSION: ${{ inputs.version }} RUN_ID: ${{ github.run_id }} run: | RELEASE_INPUT="${RELEASE_VERSION:-$RELEASE_TYPE}" PREPARE_BRANCH="prepare-$TARGET_BRANCH-$RELEASE_INPUT-$RUN_ID" git switch -c "$PREPARE_BRANCH" # The numeric prefix comes from `gh api /users/vitest-release-bot%5Bbot%5D --jq .id`. # This is just to make the avatar in the commit look pretty. git config user.name "vitest-release-bot[bot]" git config user.email "292707936+vitest-release-bot[bot]@users.noreply.github.com" pnpm run release - id: generate-token uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 with: client-id: ${{ secrets.RELEASE_GITHUB_APP_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: TARGET_BRANCH: ${{ inputs.target_branch }} GH_TOKEN: ${{ steps.generate-token.outputs.token }} run: | PREPARE_BRANCH="$(git branch --show-current)" VERSION="$(jq -r .version package.json)" git push -u "https://x-access-token:$GH_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD gh pr create \ --base "$TARGET_BRANCH" \ --head "$PREPARE_BRANCH" \ --title "chore: release v$VERSION" \ --body "Release PR generated by the Prepare Publish workflow: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"