Skip to content

Commit 5a4653b

Browse files
abueideclaude
andauthored
feat(ci): support branch-based prerelease without managing beta branch (#1202)
Remove beta branch force-push workflow and enable any feature branch to publish prereleases with branch name as prerelease identifier. **Changes:** - Remove beta branch force-push step from release workflow - Use current branch name for GITHUB_REF instead of hardcoded 'beta' - Configure semantic-release to treat any non-master branch as prerelease - Update documentation with new fix candidate workflow **Benefits:** - No branch management or syncing required - Clear traceability: branch name appears in version (e.g., 2.23.0-fix-retry-bug.1) - Multiple fix candidates can exist simultaneously - Each feature branch gets its own npm dist-tag **Usage:** 1. Push feature branch (e.g., fix/customer-issue-123) 2. Run Release workflow from that branch with type 'beta' 3. Customer installs: npm install @segment/analytics-react-native@fix-customer-issue-123 Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 33a8fe2 commit 5a4653b

4 files changed

Lines changed: 30 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ jobs:
5353
fetch-depth: 0
5454
token: ${{ github.token }}
5555

56-
- name: Point beta branch at current commit
57-
if: inputs.type == 'beta'
58-
run: |
59-
git checkout -B beta HEAD
60-
git push origin beta --force
61-
6256
- name: Install devbox
6357
uses: jetify-com/devbox-install-action@v0.14.0
6458

@@ -70,7 +64,9 @@ jobs:
7064

7165
- name: Release (beta)
7266
if: inputs.type == 'beta'
73-
run: devbox run -e GITHUB_REF=refs/heads/beta release
67+
run: |
68+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
69+
devbox run -e GITHUB_REF=refs/heads/$BRANCH_NAME release
7470
env:
7571
GH_TOKEN: ${{ github.token }}
7672

multi-release.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module.exports = {
2-
branches: ['master', { name: 'beta', prerelease: true }],
2+
branches: [
3+
'master',
4+
{ name: '+([0-9])?(.{+([0-9]),x}).x', prerelease: true }, // support branches (e.g., 1.x, 1.2.x)
5+
{ name: '*', prerelease: true }, // any other branch = prerelease
6+
],
37
tagFormat: '${name}-v${version}',
48
deps: {
59
bump: 'satisfy', // Do not trigger a release for every package if the only change is a minor/patch upgrade of dependencies

release.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module.exports = {
2-
branches: ['master', { name: 'beta', prerelease: true }],
2+
branches: [
3+
'master',
4+
{ name: '+([0-9])?(.{+([0-9]),x}).x', prerelease: true }, // support branches (e.g., 1.x, 1.2.x)
5+
{ name: '*', prerelease: true }, // any other branch = prerelease
6+
],
37
tagFormat: '${name}-v${version}',
48
plugins: [
59
['@semantic-release/commit-analyzer', { preset: 'conventionalcommits' }],

wiki/release.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Release guide
22

3-
This repo uses semantic-release with multi-semantic-release to version and publish all public workspaces. Tags follow `${name}-v${version}` and releases are cut from `master` (stable) and `beta` (prerelease).
3+
This repo uses semantic-release with multi-semantic-release to version and publish all public workspaces. Tags follow `${name}-v${version}` and releases are cut from `master` (stable) or any feature branch (prerelease).
44

55
### Prerequisites
66

@@ -16,10 +16,22 @@ This repo uses semantic-release with multi-semantic-release to version and publi
1616

1717
### CI/CD path (recommended)
1818

19-
1. Ensure `master`/`beta` are green. Merges must use conventional commits.
20-
2. Trigger `Release` workflow in Actions. Choose type: `dry-run`, `beta`, or `production`.
19+
1. Ensure target branch is green. Merges must use conventional commits.
20+
2. Trigger `Release` workflow in Actions:
21+
- **Production release**: Run from `master` with type `production` → publishes stable versions (e.g., `2.23.0`)
22+
- **Fix candidate/beta**: Run from any feature branch with type `beta` → publishes prerelease versions (e.g., `2.23.0-fix-retry-bug.1`)
23+
- **Dry run**: Run from any branch with type `dry-run` to preview what would be published
2124
3. Outputs: package tags (`${name}-vX.Y.Z`), npm publishes, and GitHub releases.
2225

26+
**Beta/fix candidate workflow:**
27+
28+
- Push your feature branch (e.g., `fix/customer-issue-123`)
29+
- Run Release workflow from that branch with type `beta`
30+
- Publishes with branch name in version: `2.23.0-fix-customer-issue-123.1`
31+
- Customer installs with: `npm install @segment/analytics-react-native@fix-customer-issue-123`
32+
- No branch management or syncing required
33+
- Each feature branch gets its own npm dist-tag
34+
2335
Note: version bumps and changelogs are **not** committed back to the repo. The source of truth for versions is the git tags and npm registry. To sync the repo's `package.json` versions with npm, run `devbox run --config=shells/devbox-fast.json sync-versions` and include the changes in a PR.
2436

2537
### Local dry run
@@ -31,6 +43,7 @@ Note: version bumps and changelogs are **not** committed back to the repo. The s
3143

3244
- Only public packages release; private workspaces (e.g., `packages/shared`) are ignored.
3345
- Tag pattern is important: keep `${name}-v${version}` if you create manual tags for debugging.
34-
- If adding a new branch for releases, update both `release.config.js` and `multi-release.config.js`.
46+
- Branch name becomes part of prerelease identifier: use descriptive branch names (e.g., `fix/retry-logic` not `fix123`).
3547
- Keep yarn.lock in sync before releasing to avoid install differences between CI and local.
3648
- `.npmrc` contains `workspaces-update=false` to prevent `npm version` from failing on Yarn's `workspace:` protocol.
49+
- Multiple fix candidates can coexist on npm simultaneously with different dist-tags.

0 commit comments

Comments
 (0)