Skip to content

Commit a42aa46

Browse files
afc163claude
andauthored
fix: sync workflow skips unchanged versions and creates GitHub release (#37)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f1554dd commit a42aa46

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

.github/workflows/sync.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,13 @@ jobs:
7474
git tag "v${CLI_VERSION}"
7575
git push origin main --tags
7676
77+
# Create GitHub Release
78+
npx tsx scripts/extract-changelog.ts "$CLI_VERSION" > /tmp/release-notes.md
79+
gh release create "v${CLI_VERSION}" \
80+
--title "v${CLI_VERSION}" \
81+
--notes-file /tmp/release-notes.md
82+
7783
# Publish to npm
7884
npm publish --provenance --access public
85+
env:
86+
GH_TOKEN: ${{ github.token }}

scripts/extract-changelog.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Extract changelog section for a given version from CHANGELOG.md.
3+
* Usage: npx tsx scripts/extract-changelog.ts 6.3.4
4+
*/
5+
6+
import fs from 'node:fs';
7+
8+
const version = process.argv[2];
9+
if (!version) {
10+
console.error('Usage: tsx scripts/extract-changelog.ts <version>');
11+
process.exit(1);
12+
}
13+
14+
const content = fs.readFileSync('CHANGELOG.md', 'utf8');
15+
const regex = new RegExp(
16+
`^## .*?${version.replace(/\./g, '\\.')}.*?\n(.*?)(?=^## |\\Z)`,
17+
'ms',
18+
);
19+
const match = regex.exec(content);
20+
if (match) {
21+
process.stdout.write(match[1].trim() + '\n');
22+
} else {
23+
process.stdout.write(`Release v${version}\n`);
24+
}

scripts/sync.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,18 @@ function main() {
104104
}
105105
console.log(`Latest v${major}: ${latestTag}`);
106106

107-
// Extract primary (latest) snapshot → data/v{major}.json
108-
checkout(antdDir, latestTag);
109-
extract(antdDir, `data/v${major}.json`);
107+
// Extract primary (latest) snapshot → data/v{major}.json (skip if already up-to-date)
108+
const primaryFile = `data/v${major}.json`;
109+
const currentVersion = fs.existsSync(primaryFile)
110+
? JSON.parse(fs.readFileSync(primaryFile, 'utf8')).version
111+
: null;
112+
if (currentVersion === latestTag) {
113+
console.log(` v${major} already at ${latestTag}, skipping primary extract`);
114+
} else {
115+
console.log(` v${major}: ${currentVersion}${latestTag}`);
116+
checkout(antdDir, latestTag);
117+
extract(antdDir, primaryFile);
118+
}
110119

111120
// Extract per-minor snapshots, skip ones that already exist
112121
for (const [minorKey, tag] of minorMap) {

0 commit comments

Comments
 (0)