Skip to content

Commit 6adf219

Browse files
committed
Fix changelog commit workflow
- Add --update-changelog flag to update changelog without creating tag - Include changelog update in version script so it gets committed with version - Both VERSION constant and CHANGELOG.md now committed together - Separate tag creation remains available via npm run create-tag
1 parent d352b05 commit 6adf219

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"postbuild": "echo '{\"type\": \"commonjs\"}' > lib/cjs/package.json",
4343
"prepare": "npm run build",
4444
"preversion": "npm run test:local",
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",
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 && git add src/amqp-base-client.ts CHANGELOG.md",
46+
"postversion": "git push && git push --tags",
4747
"release": "npm version patch",
4848
"release:minor": "npm version minor",
4949
"release:major": "npm version major"

scripts/release-tag.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@ 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")
7+
// Check if we should only update changelog (no tag creation)
8+
const updateChangelogOnly = process.argv.includes("--update-changelog")
109

1110
// Read package.json to get current version
1211
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"))
1312
const version = pkg.version
1413

1514
if (updateChangelogOnly) {
1615
console.log(`Updating changelog for version ${version}...`)
17-
} else if (getChangelogContent) {
18-
// Just get the changelog content for this version and exit
1916
} else {
20-
console.log(`Updating changelog and creating tag for version ${version}...`)
17+
console.log(`Creating tag for version ${version}...`)
2118
}
2219

2320
// Read changelog
@@ -32,7 +29,7 @@ function main() {
3229
// Check if version already exists in changelog
3330
if (changelog.includes(newVersionHeader) || changelog.includes(versionHeader)) {
3431
console.log(`Version ${version} already exists in changelog. Skipping update.`)
35-
} else if (changelog.includes(unreleasedHeader) && !getChangelogContent) {
32+
} else if (changelog.includes(unreleasedHeader)) {
3633
console.log("Updating [Unreleased] section to current version...")
3734
changelog = changelog.replace(unreleasedHeader, newVersionHeader)
3835

@@ -46,13 +43,10 @@ function main() {
4643

4744
// Write updated changelog back to file
4845
fs.writeFileSync("CHANGELOG.md", changelog, "utf8")
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")
46+
console.log("✅ Updated CHANGELOG.md")
5347
}
5448

55-
// If only updating changelog, exit here
49+
// If only updating changelog, exit here (don't create tag)
5650
if (updateChangelogOnly) {
5751
return
5852
}
@@ -72,12 +66,6 @@ function main() {
7266
// Extract the content for this version
7367
const content = changelog.substring(startIdx, nextVersionIdx === -1 ? undefined : nextVersionIdx).trim()
7468

75-
// If only getting changelog content, just output it and exit
76-
if (getChangelogContent) {
77-
console.log(content)
78-
return
79-
}
80-
8169
console.log("Changelog content:")
8270
console.log(content)
8371
console.log()

0 commit comments

Comments
 (0)