Skip to content

Commit de29abc

Browse files
Update Github Workflow (#327)
## Why The previous `release drafter` and `Build and upload package` workflow did not work! In the previous setup, when we publish a draft release created by `release drafter`, it does not update the version in `package.json` so the `package.json` file in the released source code is outdated. ## What changed - We still use release drafter like before. But instead of publishing the draft release directly, we should Go to Actions -> workflows/prepare-release.yml and run the workflow. - It will automatically create a git tag from the draft release - The new git tag will trigger the `publish.yml` workflow, which will build and publish the package to npm - Use node 22 in CI ## Versioning - [ ] Breaking protocol change - [ ] Breaking ts/js API change <!-- Kind reminder to add tests and updated documentation if needed --> --------- Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
1 parent 49ff423 commit de29abc

File tree

5 files changed

+106
-68
lines changed

5 files changed

+106
-68
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ jobs:
2020
actions: read
2121
checks: write
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 0
2626

2727
- name: Setup Node
28-
uses: actions/setup-node@v3
28+
uses: actions/setup-node@v4
2929
with:
30-
node-version: 18
30+
node-version: 22
3131

3232
- name: Cache dependencies
33-
uses: actions/cache@v3
33+
uses: actions/cache@v4
3434
with:
3535
path: ~/.npm
3636
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

.github/workflows/npmjs-publish.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
tag-release:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: read
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
# Run release-drafter to determine the next version
20+
- name: Determine next version from release-drafter
21+
id: release_drafter
22+
uses: release-drafter/release-drafter@v6
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
# Use the output from the previous step to version the package
27+
- name: Setup Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 22
31+
32+
- name: Configure Git
33+
run: |
34+
git config user.name 'GitHub Actions'
35+
git config user.email 'eng+github@repl.it'
36+
37+
- name: Bump version and create tag
38+
run: |
39+
# Get the tag_name output from the release-drafter step
40+
tag="${{ steps.release_drafter.outputs.tag_name }}"
41+
42+
# Strip the 'v' prefix to get the bare version number
43+
version="${tag#v}"
44+
45+
echo "Next version calculated by release-drafter is: $version"
46+
47+
# Use the calculated version with npm version
48+
npm version "$version"
49+
50+
- name: Push changes and tags
51+
run: git push --follow-tags

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# .github/workflows/publish.yml
2+
name: Build and Publish Package
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*' # Trigger on tags like v1.0.0, v2.3.4, etc.
8+
9+
jobs:
10+
build-and-publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
# This checks out the code at the specific tag that triggered the workflow
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
registry-url: 'https://registry.npmjs.org/'
22+
23+
- name: Install dependencies and build
24+
run: npm ci
25+
26+
- name: Publish to npm
27+
run: npm publish --access public
28+
env:
29+
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }}
30+
31+
- name: Publish GitHub Release
32+
uses: release-drafter/release-drafter@v5
33+
with:
34+
publish: true
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,29 +280,24 @@ River uses an automated release process with [Release Drafter](https://github.co
280280

281281
### Automated Release Process (Recommended)
282282

283-
1. **Label your PRs** with the appropriate version bump:
283+
1. **Merge PRs to main** - Release Drafter automatically:
284284

285-
- `patch` - Bug fixes, small improvements (e.g., 0.208.4 → 0.208.5)
286-
- `minor` - New features, backwards compatible (e.g., 0.208.4 → 0.209.0)
287-
- `major` - Breaking changes (e.g., 0.208.4 → 1.0.0)
288-
289-
2. **Merge PRs to main** - Release Drafter automatically:
285+
- Updates the draft release notes with PR titles
286+
- You can view the draft at [GitHub Releases](../../releases)
290287

291-
- Creates/updates a draft release with the calculated version
292-
- Generates release notes from PR titles
293-
- Determines version bump based on the highest label used
288+
2. **When ready to release**:
294289

295-
3. **Publish the release** when ready:
296-
- Go to [GitHub Releases](../../releases)
297-
- Review the draft release notes
298-
- Click "Publish release"
299-
- This automatically publishes to NPM
290+
- Go to [Actions](../../actions/workflows/prepare-release.yml)
291+
- Click "Run workflow" to open the configuration dialog
292+
- Click "Run workflow" again to confirm and start the process (version is automatically determined from draft release)
300293

301-
### Manual Release (Alternative)
294+
The version bump is automatically calculated based on PR labels:
302295

303-
For hotfixes or special cases, you can manually trigger a release:
296+
- `patch` - Bug fixes, small improvements (e.g., 0.208.4 → 0.208.5)
297+
- `minor` - New features, backwards compatible (e.g., 0.208.4 → 0.209.0)
298+
- `major` - Breaking changes (e.g., 0.208.4 → 1.0.0)
304299

305-
1. Go to [Actions](../../actions/workflows/npmjs-publish.yml)
306-
2. Click "Run workflow"
307-
3. Enter the desired version (e.g., `0.208.5`)
308-
4. Click "Run workflow"
300+
3. **Automation takes over**:
301+
- The "Prepare Release" workflow bumps the version and creates a git tag
302+
- The git tag automatically triggers the "Build and Publish" workflow
303+
- The `river` package is published to NPM and the GitHub release is created

0 commit comments

Comments
 (0)