Skip to content

Commit 5f2ecc1

Browse files
authored
update release process (#267)
* update release process * fix lock
1 parent 6e5ea18 commit 5f2ecc1

10 files changed

Lines changed: 240 additions & 502 deletions

File tree

.changeset/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.changeset/config.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
version-sync:
17+
name: Version Sync Check
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 22
25+
- name: Check version sync
26+
run: node scripts/check-version-sync.js
27+
1628
lint:
1729
name: Lint
1830
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 126 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,150 @@ on:
88

99
concurrency: ${{ github.workflow }}-${{ github.ref }}
1010

11-
permissions:
12-
contents: write
13-
pull-requests: write
14-
1511
jobs:
16-
release:
17-
name: Release
12+
check-release:
13+
name: Check for new version
1814
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
permissions:
17+
contents: read
18+
outputs:
19+
should_release: ${{ steps.check.outputs.should_release }}
20+
needs_github_release: ${{ steps.check.outputs.needs_github_release }}
21+
version: ${{ steps.check.outputs.version }}
1922
steps:
2023
- name: Checkout repository
2124
uses: actions/checkout@v4
25+
26+
- name: Compare package.json version to npm and check GitHub release
27+
id: check
28+
run: |
29+
LOCAL_VERSION=$(node -p "require('./packages/core/package.json').version")
30+
echo "Local version: $LOCAL_VERSION"
31+
32+
NPM_VERSION=$(npm view @json-render/core version 2>/dev/null || echo "0.0.0")
33+
echo "npm version: $NPM_VERSION"
34+
35+
if [ "$LOCAL_VERSION" != "$NPM_VERSION" ]; then
36+
echo "Version changed: $NPM_VERSION -> $LOCAL_VERSION"
37+
echo "should_release=true" >> "$GITHUB_OUTPUT"
38+
echo "needs_github_release=true" >> "$GITHUB_OUTPUT"
39+
else
40+
echo "Version unchanged on npm, skipping build and publish"
41+
echo "should_release=false" >> "$GITHUB_OUTPUT"
42+
43+
TAG="v$LOCAL_VERSION"
44+
if gh release view "$TAG" &>/dev/null; then
45+
echo "GitHub release $TAG exists"
46+
echo "needs_github_release=false" >> "$GITHUB_OUTPUT"
47+
else
48+
echo "GitHub release $TAG is missing, will create it"
49+
echo "needs_github_release=true" >> "$GITHUB_OUTPUT"
50+
fi
51+
fi
52+
echo "version=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
build:
57+
name: Build
58+
needs: check-release
59+
if: needs.check-release.outputs.should_release == 'true'
60+
runs-on: ubuntu-latest
61+
timeout-minutes: 15
62+
permissions:
63+
contents: read
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
68+
- name: Install pnpm
69+
uses: pnpm/action-setup@v4
70+
71+
- name: Setup Node.js
72+
uses: actions/setup-node@v4
2273
with:
23-
fetch-depth: 0
74+
node-version: 22
75+
cache: pnpm
76+
77+
- name: Install dependencies
78+
run: pnpm install --frozen-lockfile
79+
80+
- name: Build packages
81+
run: pnpm run build
82+
83+
publish:
84+
name: Publish to npm
85+
needs: [check-release, build]
86+
if: needs.check-release.outputs.should_release == 'true'
87+
runs-on: ubuntu-latest
88+
timeout-minutes: 15
89+
permissions:
90+
contents: read
91+
steps:
92+
- name: Checkout repository
93+
uses: actions/checkout@v4
2494

2595
- name: Install pnpm
2696
uses: pnpm/action-setup@v4
2797

2898
- name: Setup Node.js
2999
uses: actions/setup-node@v4
30100
with:
31-
node-version: 20
101+
node-version: 22
32102
cache: pnpm
33103
registry-url: "https://registry.npmjs.org"
34104

35105
- name: Install dependencies
36106
run: pnpm install --frozen-lockfile
37107

38-
- name: Create Release Pull Request or Publish
39-
uses: changesets/action@v1
40-
with:
41-
version: pnpm ci:version
42-
publish: pnpm ci:publish
43-
title: "chore: version packages"
44-
commit: "chore: version packages"
108+
- name: Build packages
109+
run: pnpm run build
110+
111+
- name: Publish all public packages
112+
run: pnpm -r publish --no-git-checks --filter '@json-render/*'
45113
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47114
NODE_AUTH_TOKEN: ${{ secrets.NPM_VERCEL_TOKEN_ELEVATED }}
115+
116+
github-release:
117+
name: Create GitHub Release
118+
needs: [check-release, publish]
119+
if: >-
120+
always()
121+
&& needs.check-release.outputs.needs_github_release == 'true'
122+
&& (needs.publish.result == 'success' || needs.publish.result == 'skipped')
123+
runs-on: ubuntu-latest
124+
timeout-minutes: 10
125+
permissions:
126+
contents: write
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@v4
130+
131+
- name: Extract changelog entry
132+
run: |
133+
VERSION="${{ needs.check-release.outputs.version }}"
134+
awk '/<!-- release:start -->/{found=1; next} /<!-- release:end -->/{found=0} found{print}' CHANGELOG.md > /tmp/release-notes.md
135+
136+
LINES=$(wc -l < /tmp/release-notes.md | tr -d ' ')
137+
if [ "$LINES" -lt 2 ]; then
138+
echo "Error: No release notes found between <!-- release:start --> and <!-- release:end --> markers in CHANGELOG.md"
139+
exit 1
140+
fi
141+
echo "Extracted release notes for $VERSION ($LINES lines)"
142+
143+
- name: Create GitHub Release
144+
run: |
145+
VERSION="${{ needs.check-release.outputs.version }}"
146+
TAG="v$VERSION"
147+
148+
if gh release view "$TAG" &>/dev/null; then
149+
echo "Release $TAG already exists"
150+
else
151+
echo "Creating release $TAG..."
152+
gh release create "$TAG" \
153+
--title "$TAG" \
154+
--notes-file /tmp/release-notes.md
155+
fi
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

AGENTS.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,20 @@ Do **not** add `--port` flags -- portless handles port assignment automatically.
7373
- Skills in `skills/*/SKILL.md` (if the package has a corresponding skill)
7474
- `AGENTS.md` (if workflow or conventions change)
7575

76-
## Releases
76+
## Releasing
7777

78-
This monorepo uses [Changesets](https://github.com/changesets/changesets) for versioning and publishing.
78+
Releases are manual, single-PR affairs. The maintainer controls the changelog voice and format.
7979

80-
### Fixed version group
81-
82-
All public `@json-render/*` packages are in a **fixed** group (see `.changeset/config.json`). A changeset that bumps any one of them bumps all of them to the same version. You only need to list the packages that actually changed in the changeset front matter — the fixed group handles the rest.
80+
All public `@json-render/*` packages share the same version. The canonical version lives in `packages/core/package.json`.
8381

8482
### Preparing a release
8583

86-
When asked to prepare a release (e.g. "prepare v0.12.0"):
84+
When asked to prepare a release (e.g. "prepare v0.17.0"):
8785

88-
1. **Create a changeset file** at `.changeset/v0-<N>-release.md` following the existing pattern:
89-
- YAML front matter listing changed packages with bump type (`minor` for feature releases, `patch` for bug-fix-only releases)
90-
- A one-line summary, then `### New:` / `### Improved:` / `### Fixed:` sections describing each change
91-
- Always list `@json-render/core` plus any packages with actual code changes
92-
2. **Do NOT bump versions** in `package.json` files — CI runs `pnpm ci:version` (which calls `changeset version`) to do that automatically
93-
3. **Do NOT manually write `CHANGELOG.md`** entries — `changeset version` generates them from the changeset file
94-
4. **Add new packages to the fixed group** in `.changeset/config.json` if they should be versioned together with the rest
86+
1. Create a branch (e.g. `prepare-v0.17.0`)
87+
2. Bump the version in `packages/core/package.json`
88+
3. Run `pnpm run version:sync` to update all other `@json-render/*` packages
89+
4. Write the changelog entry in `CHANGELOG.md`, wrapped in `<!-- release:start -->` and `<!-- release:end -->` markers (move the markers from the previous entry to the new one)
9590
5. **Fill documentation gaps** — every public package should have:
9691
- A row in the root `README.md` packages table
9792
- A renderer section in the root `README.md` (if it's a renderer)
@@ -101,12 +96,15 @@ When asked to prepare a release (e.g. "prepare v0.12.0"):
10196
- A skill at `skills/<name>/SKILL.md`
10297
- A `packages/<name>/README.md`
10398
6. **Run `pnpm type-check`** after all changes to verify nothing is broken
99+
7. Open a PR and merge to `main`
100+
101+
CI compares the `@json-render/core` version to what's on npm. If it differs, it builds, publishes all public packages, and creates the GitHub release automatically. The release body is extracted from the content between the markers.
104102

105-
### CI scripts
103+
### Scripts
106104

107-
- `pnpm changeset`interactively create a new changeset
108-
- `pnpm ci:version`run `changeset version` + lockfile update (CI only)
109-
- `pnpm ci:publish` — build all packages and publish to npm (CI only)
105+
- `pnpm run version:sync`sync all `@json-render/*` package versions to match `@json-render/core`
106+
- `pnpm run version:check`verify all versions are in sync (runs in CI)
107+
- `pnpm run ci:publish` — build all packages and publish to npm (CI only)
110108

111109
<!-- opensrc:start -->
112110

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## 0.16.0
4+
5+
<!-- release:start -->
6+
### Improved
7+
8+
- **Release process** — Switched from Changesets to a manual single-PR release workflow with changelog markers and automatic npm publish on version bump
9+
<!-- release:end -->

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
"test:coverage": "vitest run --coverage",
2424
"test:e2e": "pnpm --filter e2e-tests test",
2525
"prepare": "husky",
26-
"changeset": "changeset",
27-
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
28-
"ci:publish": "pnpm run build && changeset publish",
26+
"version:sync": "node scripts/sync-version.js",
27+
"version:check": "node scripts/check-version-sync.js",
28+
"ci:publish": "pnpm run build && pnpm -r publish --no-git-checks --filter '@json-render/*'",
2929
"generate:og": "npx tsx scripts/generate-og-images.mts"
3030
},
3131
"devDependencies": {
32-
"@changesets/cli": "2.29.8",
3332
"@resvg/resvg-js": "2.6.2",
3433
"@solidjs/testing-library": "^0.8.10",
3534
"@sveltejs/vite-plugin-svelte": "^6.2.4",

0 commit comments

Comments
 (0)