Skip to content

Commit b297823

Browse files
Copilotzth
andauthored
Enable dual-branch release workflows for independent 1.x and 2.x version management (#21)
* Initial plan * Implement dual-branch release workflow setup Co-authored-by: zth <[email protected]> * Add README documentation and test changeset functionality Co-authored-by: zth <[email protected]> * Final verification and testing complete Co-authored-by: zth <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: zth <[email protected]>
1 parent e82bc14 commit b297823

File tree

5 files changed

+120
-5
lines changed

5 files changed

+120
-5
lines changed

.github/workflows/release-2x.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Release workflow for the 2.x branch (2.x versions)
2+
# This workflow handles releases for the 2.x version line of rescript-bun.
3+
# It only triggers on pushes to the 2.x branch to ensure 2.x releases are properly managed.
4+
name: Release (2.x)
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
on:
11+
push:
12+
branches:
13+
- 2.x
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Use Node.js 20.x
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
registry-url: https://registry.npmjs.org/
29+
30+
- name: Setup Bun
31+
uses: oven-sh/setup-bun@v1
32+
with:
33+
bun-version: latest
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
38+
- name: Build project
39+
run: bun run build
40+
41+
# This workflow is specifically for 2.x releases on the 2.x branch
42+
# The changeset action will handle version bumps according to changeset config
43+
- name: Create Release Pull Request or Publish to npm (2.x releases)
44+
uses: changesets/action@v1
45+
with:
46+
publish: bun run release
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
name: Release
1+
# Release workflow for the main branch (1.x versions)
2+
# This workflow handles releases for the 1.x version line of rescript-bun.
3+
# It only triggers on pushes to the main branch to ensure 1.x releases are properly managed.
4+
name: Release (1.x)
25

36
permissions:
47
contents: write
@@ -35,10 +38,12 @@ jobs:
3538
- name: Build project
3639
run: bun run build
3740

38-
- name: Create Release Pull Request or Publish to npm
41+
# This workflow is specifically for 1.x releases on the main branch
42+
# The changeset action will handle version bumps according to changeset config
43+
- name: Create Release Pull Request or Publish to npm (1.x releases)
3944
uses: changesets/action@v1
4045
with:
4146
publish: bun run release
4247
env:
4348
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
# Test workflow for both main (1.x) and 2.x branches
2+
# This workflow runs tests on both the main branch (1.x development)
3+
# and the 2.x branch (2.x development) to ensure code quality across both version lines.
14
name: Test
25

36
on:
47
push:
5-
branches: [main]
8+
branches: [main, 2.x]
69
pull_request:
7-
branches: [main]
10+
branches: [main, 2.x]
811

912
jobs:
1013
build:

DUAL_BRANCH_SETUP.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Dual-Branch Release Setup
2+
3+
This repository uses a dual-branch approach for managing releases:
4+
5+
## Branch Structure
6+
7+
- **`main` branch**: Handles 1.x version releases
8+
- **`2.x` branch**: Handles 2.x version releases
9+
10+
## Workflow Files
11+
12+
### Release Workflows
13+
14+
- **`release-main.yml`**: Triggers on pushes to `main` branch, handles 1.x releases
15+
- **`release-2x.yml`**: Triggers on pushes to `2.x` branch, handles 2.x releases
16+
17+
Both workflow files exist on both branches, but each only triggers on its respective branch to prevent interference.
18+
19+
### Test Workflow
20+
21+
- **`test.yml`**: Runs on both `main` and `2.x` branches to ensure code quality across both version lines
22+
23+
## Changeset Configuration
24+
25+
Each branch has its own changeset configuration:
26+
27+
- **`main` branch**: `baseBranch: "main"` in `.changeset/config.json`
28+
- **`2.x` branch**: `baseBranch: "2.x"` in `.changeset/config.json`
29+
30+
This ensures that changesets work correctly on each branch by comparing against the appropriate base.
31+
32+
## Release Process
33+
34+
### For 1.x releases (main branch):
35+
1. Create changeset: `npm run changeset`
36+
2. Commit and push to main branch
37+
3. The `release-main.yml` workflow will create a release PR or publish
38+
39+
### For 2.x releases (2.x branch):
40+
1. Switch to 2.x branch: `git checkout 2.x`
41+
2. Create changeset: `npm run changeset`
42+
3. Commit and push to 2.x branch
43+
4. The `release-2x.yml` workflow will create a release PR or publish
44+
45+
## Important Notes
46+
47+
- Both branches maintain independent changeset histories
48+
- Workflows do not interfere with each other due to branch-specific triggers
49+
- Each branch can have different dependencies and configurations as needed
50+
- The version numbers are managed separately per branch (1.x vs 2.x)

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
_Check out the `2.x` branch for ReScript v12 support._
44

5+
## Release Branches
6+
7+
This repository maintains two active release branches:
8+
- **`main` branch**: For 1.x releases (ReScript v11+ support)
9+
- **`2.x` branch**: For 2.x releases (ReScript v12+ support)
10+
11+
Each branch has independent release cycles managed by changesets. See [DUAL_BRANCH_SETUP.md](DUAL_BRANCH_SETUP.md) for detailed information about the dual-branch setup.
12+
513
Use [Bun](https://bun.sh) with ReScript.
614

715
> **Currently alpha state software**. You're encouraged to start using it, but please report all issues. There will be both bindings missing and some bindings will probably be wrong/suboptimal. We're going to work through the API surface as we go. Report all issues you find!

0 commit comments

Comments
 (0)