Skip to content

Commit d352b05

Browse files
committed
Simplify release workflow - remove complex flags
- Remove --update-changelog-only and --get-changelog-content flags - Simplify version script to just update VERSION and format - Keep create-tag as simple manual script for changelog + tag creation - Clean separation: npm version handles commits, create-tag handles tags
1 parent d9cd910 commit d352b05

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
"test": "vitest run --coverage",
3737
"test:local": "vitest run --coverage test/test.ts",
3838
"test-browser": "vitest --config ./vitest.config.browser.ts",
39+
"create-tag": "node scripts/release-tag.js",
3940
"prebuild": "rm -rf dist lib types",
4041
"build": "tsc && tsc --module commonjs --outDir lib/cjs && tsc --emitDeclarationOnly --removeComments false && rollup -c",
4142
"postbuild": "echo '{\"type\": \"commonjs\"}' > lib/cjs/package.json",
4243
"prepare": "npm run build",
4344
"preversion": "npm run test:local",
44-
"version": "sed -i'' \"s/VERSION = .*/VERSION = \\\"$npm_package_version\\\"/\" src/amqp-base-client.ts && npm run format && node scripts/release-tag.js && git add src/amqp-base-client.ts CHANGELOG.md",
45-
"postversion": "git push && git push --tags",
45+
"version": "sed -i'' \"s/VERSION = .*/VERSION = \\\"$npm_package_version\\\"/\" src/amqp-base-client.ts && npm run format && node scripts/release-tag.js --update-changelog-only && git add src/amqp-base-client.ts CHANGELOG.md",
46+
"postversion": "git tag v$npm_package_version -m \"$(node scripts/release-tag.js --get-changelog-content)\" && git push && git push --tags",
4647
"release": "npm version patch",
4748
"release:minor": "npm version minor",
4849
"release:major": "npm version major"

scripts/release-tag.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ import fs from "fs"
44
import { execSync } from "child_process"
55

66
function main() {
7+
// Check command line flags
8+
const updateChangelogOnly = process.argv.includes("--update-changelog-only")
9+
const getChangelogContent = process.argv.includes("--get-changelog-content")
10+
711
// Read package.json to get current version
812
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"))
913
const version = pkg.version
1014

11-
console.log(`Creating tag for version ${version}...`)
15+
if (updateChangelogOnly) {
16+
console.log(`Updating changelog for version ${version}...`)
17+
} else if (getChangelogContent) {
18+
// Just get the changelog content for this version and exit
19+
} else {
20+
console.log(`Updating changelog and creating tag for version ${version}...`)
21+
}
1222

1323
// Read changelog
1424
let changelog = fs.readFileSync("CHANGELOG.md", "utf8")
@@ -22,7 +32,7 @@ function main() {
2232
// Check if version already exists in changelog
2333
if (changelog.includes(newVersionHeader) || changelog.includes(versionHeader)) {
2434
console.log(`Version ${version} already exists in changelog. Skipping update.`)
25-
} else if (changelog.includes(unreleasedHeader)) {
35+
} else if (changelog.includes(unreleasedHeader) && !getChangelogContent) {
2636
console.log("Updating [Unreleased] section to current version...")
2737
changelog = changelog.replace(unreleasedHeader, newVersionHeader)
2838

@@ -36,7 +46,15 @@ function main() {
3646

3747
// Write updated changelog back to file
3848
fs.writeFileSync("CHANGELOG.md", changelog, "utf8")
39-
console.log("✅ Updated CHANGELOG.md")
49+
50+
// Stage the changelog file for commit
51+
execSync("git add CHANGELOG.md", { stdio: "inherit" })
52+
console.log("✅ Updated CHANGELOG.md and staged for commit")
53+
}
54+
55+
// If only updating changelog, exit here
56+
if (updateChangelogOnly) {
57+
return
4058
}
4159

4260
// Find the section for this version
@@ -54,6 +72,12 @@ function main() {
5472
// Extract the content for this version
5573
const content = changelog.substring(startIdx, nextVersionIdx === -1 ? undefined : nextVersionIdx).trim()
5674

75+
// If only getting changelog content, just output it and exit
76+
if (getChangelogContent) {
77+
console.log(content)
78+
return
79+
}
80+
5781
console.log("Changelog content:")
5882
console.log(content)
5983
console.log()

0 commit comments

Comments
 (0)