Skip to content

Commit f52f84f

Browse files
Merge pull request #2 from Zhang-JiahangH/codex/automate-versioning-in-ci/cd-workflow
ci: automate semantic versioning, changelog and npm release with Release Please
2 parents d27ad68 + 6a1cb54 commit f52f84f

7 files changed

Lines changed: 77 additions & 5 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
release-please:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: googleapis/release-please-action@v4
18+
with:
19+
config-file: release-please-config.json
20+
manifest-file: .release-please-manifest.json

.github/workflows/release.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release
1+
name: Publish to npm
22

33
on:
44
push:
@@ -26,9 +26,20 @@ jobs:
2626
node-version: 20.11.1
2727
registry-url: 'https://registry.npmjs.org/'
2828

29-
- run: pnpm install
29+
- run: pnpm install --frozen-lockfile
30+
31+
- name: Validate tag and package version
32+
run: |
33+
TAG_VERSION="${GITHUB_REF_NAME#v}"
34+
PKG_VERSION="$(node -p "require('./packages/react/package.json').version")"
35+
36+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
37+
echo "Tag version ($TAG_VERSION) does not match package version ($PKG_VERSION)."
38+
exit 1
39+
fi
40+
3041
- run: pnpm build
3142
- run: pnpm test
3243
- run: pnpm --filter react-virtualized-diff publish --access public --no-git-checks
3344
env:
34-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"packages/react": "0.1.2"
3+
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on Keep a Changelog, and this project follows Semantic Versioning.
66

7+
## [0.1.2] - 2026-04-06
8+
9+
### Added
10+
11+
- Added `release-please` workflow to automatically create version/changelog release PRs from conventional commits
12+
- Added release manifest/config to keep package versioning source-of-truth in repository metadata
13+
14+
### Changed
15+
16+
- Updated publish workflow to validate git tag version against `packages/react/package.json` before npm publish
17+
- Release flow now supports automated patch/minor bumps without manually editing workflow version values
18+
719
## [0.1.1] - 2026-04-06
820

921
### Added

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ See [CHANGELOG.md](./CHANGELOG.md) for tracked releases and supported capabiliti
117117

118118
---
119119

120+
## Automated versioning & release
121+
122+
This repository now uses **Release Please** to automate versioning and changelog generation.
123+
124+
- Merge commits to `main` using Conventional Commits (`fix:`, `feat:`, `feat!:` etc.)
125+
- Release Please opens/updates a release PR automatically
126+
- Merging that PR creates a `vX.Y.Z` tag and GitHub Release
127+
- npm publish workflow is triggered by that tag and publishes `react-virtualized-diff` automatically
128+
129+
Version bump rules (SemVer):
130+
131+
- `fix:`/`chore:` and similar => patch (`v0.1.x` -> `v0.1.x+1`)
132+
- `feat:` => minor (`v0.1.x` -> `v0.2.0`)
133+
- `feat!:` or `BREAKING CHANGE:` => major (`v0.x.x` -> `v1.0.0`)
134+
120135
## Future plan
121136

122137
### Near-term roadmap
@@ -133,7 +148,7 @@ See [CHANGELOG.md](./CHANGELOG.md) for tracked releases and supported capabiliti
133148
- [ ] Dark/light theme presets and design tokens
134149
- [ ] SSR usage guide (Next.js / Remix examples)
135150
- [ ] More real-world examples (JSON, logs, markdown, code)
136-
- [ ] CI release automation + semantic versioning workflow
151+
- [x] CI release automation + semantic versioning workflow
137152
- [ ] Contribution guide and issue templates
138153
- [ ] International docs beyond English/Chinese
139154

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-virtualized-diff",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "High-performance React diff viewer for large files",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.mjs",

release-please-config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"include-component-in-tag": false,
4+
"packages": {
5+
"packages/react": {
6+
"release-type": "node",
7+
"package-name": "react-virtualized-diff",
8+
"changelog-path": "CHANGELOG.md"
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)