Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ on:
- stable
- rc
- canary
ref:
description: Git ref to checkout
required: true
type: string

permissions:
contents: write
id-token: write

concurrency:
group: release-${{ github.event.inputs.mode }}-${{ github.event.inputs.ref }}
group: release-${{ github.event.inputs.mode }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
Expand All @@ -30,14 +26,14 @@ jobs:
runs-on: ubuntu-latest
env:
RELEASE_MODE: ${{ github.event.inputs.mode }}
RELEASE_REF: ${{ github.event.inputs.ref }}
RELEASE_REF: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: actions-bot
GIT_AUTHOR_EMAIL: actions-bot@users.noreply.github.com
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0

- name: Configure git identity
Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Prereleases also run manually with `.github/workflows/release.yml`.

### RC releases

Use `release/<minor>` or `release/<version>` branches, for example `release/1.7` or `release/2.0`.
Use `release/v<version>` branches, for example `release/v1.7` or `release/v2.0.0`.

`rc` mode is intentionally restricted to `release/*` branches and will fail on `main`.
`rc` mode is intentionally restricted to `release/v<version>` branches and will fail on `main`.

First `rc` run on a release branch:

Expand Down
18 changes: 12 additions & 6 deletions scripts/release/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function normalizeRef(ref) {
return ref.replace(/^refs\/heads\//, '').trim();
}

function isReleaseBranch(ref) {
return /^release\/v\d+\.\d+(?:\.\d+)?$/.test(ref);
}

function run(command, args, options = {}) {
execFileSync(command, args, {
stdio: 'inherit',
Expand Down Expand Up @@ -92,7 +96,7 @@ function updateLockfile() {
run('pnpm', ['install', '--lockfile-only']);
}

function commitVersionChanges(message) {
function commitVersionChanges() {
run('git', [
'add',
'.changeset',
Expand All @@ -108,7 +112,7 @@ function commitVersionChanges(message) {
fail('no release files were staged for commit');
}

run('git', ['commit', '-m', message]);
run('git', ['commit', '-m', `chore: release v${readVersion()}`]);
}

function pushBranch() {
Expand Down Expand Up @@ -166,7 +170,7 @@ function runStableRelease() {

run('pnpm', ['changeset', 'version']);
updateLockfile();
commitVersionChanges('Version packages for stable release');
commitVersionChanges();
pushBranch();
run('pnpm', ['release:check']);
run('pnpm', ['release:build']);
Expand All @@ -179,8 +183,10 @@ function runRcRelease() {
fail(`rc releases must not run from ${stableBranch}`);
}

if (!branch.startsWith('release/')) {
fail(`rc releases must run from a release/* branch, received ${branch}`);
if (!isReleaseBranch(branch)) {
fail(
`rc releases must run from a release/v<version> branch, received ${branch}`,
);
}

ensureRemoteBranch();
Expand All @@ -192,7 +198,7 @@ function runRcRelease() {

run('pnpm', ['changeset', 'version']);
updateLockfile();
commitVersionChanges('Version packages for rc release');
commitVersionChanges();
pushBranch();
run('pnpm', ['release:check']);
run('pnpm', ['release:build']);
Expand Down
Loading