Skip to content

Commit 9794bca

Browse files
committed
feat(scripts): support conventional commit style for version bumps
Updates version bump detection to recognize both old style (Bump to v1.0.0) and new conventional commit style (chore(registry): bump version to 1.0.0). The git log grep now uses extended regex to match either pattern, and the filtering logic accepts both formats.
1 parent b854984 commit 9794bca

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

scripts/publish-npm-packages.mjs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ async function ensureNpmVersion() {
116116
* Find all commits with version bumps in the registry package.
117117
*/
118118
async function findVersionBumpCommits() {
119-
// Get git log with commit messages starting with "Bump".
119+
// Get git log with commit messages for version bumps.
120+
// Matches both old style "Bump..." and new conventional commit style "chore(registry): bump...".
120121
const result = await spawn('git', [
121122
'log',
122-
'--grep=^Bump',
123+
'-E',
124+
'--grep=^Bump|^chore\\(registry\\): bump',
123125
'--format=%H %s',
124126
'main',
125127
])
@@ -137,13 +139,18 @@ async function findVersionBumpCommits() {
137139
const message = match[2]
138140

139141
// Skip non-package bump commits (like dependency bumps).
140-
// Only accept specific version bump patterns:
142+
// Accept specific version bump patterns:
143+
// Old style:
141144
// - "Bump to v<version>" (general format)
142145
// - "Bump <pkgname> to v<version>"
143146
// - "Bump registry package to v<version>"
144-
// Exclude generic "Update" or "Bump" messages without "to v".
145-
// Use non-greedy .+? to match shortest text before "to v" (handles multi-word package names).
146-
if (!/^Bump (?:.+? )?to v/.test(message)) {
147+
// New conventional commit style:
148+
// - "chore(registry): bump version to <version>"
149+
// Exclude generic "Update" or "Bump" messages without version info.
150+
if (
151+
!/^Bump (?:.+? )?to v/.test(message) &&
152+
!/^chore\(registry\): bump version to \d+\.\d+\.\d+/.test(message)
153+
) {
147154
continue
148155
}
149156

0 commit comments

Comments
 (0)