diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 622a8e48c3a52e..f72157534cfc20 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -3,6 +3,11 @@ name: Prepare Release on: workflow_dispatch: inputs: + target_branch: + description: Release target branch + required: true + default: main + type: string package: description: Package to release required: true @@ -31,7 +36,7 @@ on: type: string concurrency: - group: ${{ github.workflow }}-${{ inputs.package }}-${{ inputs.version || inputs.release }} + group: ${{ github.workflow }}-${{ inputs.target_branch }}-${{ inputs.package }}-${{ inputs.version || inputs.release }} cancel-in-progress: false permissions: {} @@ -45,10 +50,19 @@ jobs: contents: write pull-requests: write steps: + - name: Validate target branch + env: + TARGET_BRANCH: ${{ inputs.target_branch }} + run: | + if [[ "$TARGET_BRANCH" != "main" && ! "$TARGET_BRANCH" =~ ^v[0-9]+(\.[0-9]+)?$ ]]; then + echo "Target branch must be main or a v* release branch (for example, v8 or v8.0)" + exit 1 + fi + - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: - ref: main + ref: ${{ inputs.target_branch }} fetch-depth: 0 persist-credentials: false @@ -82,4 +96,5 @@ jobs: package-path: packages/${{ inputs.package }} pr-body: ${{ steps.prepare.outputs.pr_body }} tag: ${{ steps.prepare.outputs.tag }} + target-branch: ${{ inputs.target_branch }} version: ${{ steps.prepare.outputs.version }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5ea200675430ec..0772404103c64a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - "v[0-9]*" permissions: {} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a943153950d0b8..45aa095ce78006 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -352,14 +352,15 @@ All publishable packages in this repository use a pull-request-driven release fl #### Prepare a Release 1. Run the [Prepare Release](.github/workflows/prepare-release.yml) workflow from the `main` branch. -2. Select `vite`, `create-vite`, or `plugin-legacy`. -3. Select a `release` type. The default `next` creates the next patch for a stable version or advances an existing prerelease. Alternatively, select another supported release type or enter an exact `version`, which takes precedence over `release`. -4. Wait for the action to open the release PR. The PR contains the selected package's version bump and changelog entry. A `create-vite` release also updates template Vite dependency versions when appropriate. +2. Enter the target branch. Use `main` for the current release line or a `v*` release branch (for example, `v8` or `v8.0`) for a patch release. +3. Select `vite`, `create-vite`, or `plugin-legacy`. +4. Select a `release` type. The default `next` creates the next patch for a stable version or advances an existing prerelease. Alternatively, select another supported release type or enter an exact `version`, which takes precedence over `release`. +5. Wait for the action to open a release PR against the target branch. The PR contains the selected package's version bump and changelog entry. A `create-vite` release also updates template Vite dependency versions when appropriate. #### Review and Publish 1. Review the generated version and changelog, and wait for the release PR checks to pass. -2. Merge the PR while retaining its `release: ` commit subject. Vite uses `release: v`; other packages use `release: @`. A matching commit at the tip of `main` triggers the publish job. +2. Merge the PR while retaining its `release: ` commit subject. Vite uses `release: v`; other packages use `release: @`. A matching commit at the tip of `main` or a `v*` release branch triggers the publish job. 3. Open the [Publish Package](.github/workflows/publish.yml) run and approve its `Release` environment deployment. 4. Wait for the workflow to publish the package, create its tag, and create the corresponding GitHub release. 5. Verify the new version on npm. @@ -368,7 +369,7 @@ All publishable packages in this repository use a pull-request-driven release fl The release flow depends on configuration outside this repository: -- The `Release` environment must require maintainer approval before publishing. +- The `Release` environment must require maintainer approval before publishing and allow deployments from `main` and supported `v*` release branches. - The npm trusted publishers for `vite`, `create-vite`, and `@vitejs/plugin-legacy` must be restricted to `vitejs/vite`, `.github/workflows/publish.yml`, and the `Release` environment. #### Recovery