22
33/**
44 * Release Script
5- * Updates package.json version and creates matching git tag
5+ * Updates package.json version, commits the change, and creates matching git tag
66 *
77 * Usage:
88 * bun run release # Auto-increment patch version
@@ -120,6 +120,27 @@ async function updatePackageJson(newVersion: string, dryRun: boolean): Promise<v
120120 }
121121}
122122
123+ async function commitPackageJsonChanges ( version : string , dryRun : boolean ) : Promise < void > {
124+ console . log ( `📝 Committing package.json changes` ) ;
125+
126+ if ( ! dryRun ) {
127+ // Stage package.json
128+ const { exitCode : addExitCode } = await executeCommand ( 'git' , [ 'add' , 'package.json' ] ) ;
129+ if ( addExitCode !== 0 ) {
130+ throw new ReleaseError ( 'Failed to stage package.json' ) ;
131+ }
132+
133+ // Commit the changes
134+ const commitMessage = `chore: bump version to ${ version } ` ;
135+ const { exitCode : commitExitCode } = await executeCommand ( 'git' , [ 'commit' , '-m' , commitMessage ] ) ;
136+ if ( commitExitCode !== 0 ) {
137+ throw new ReleaseError ( 'Failed to commit package.json changes' ) ;
138+ }
139+
140+ console . log ( '✅ Committed package.json changes' ) ;
141+ }
142+ }
143+
123144async function createGitTag ( version : string , dryRun : boolean ) : Promise < void > {
124145 const tagName = `v${ version } ` ;
125146
@@ -157,7 +178,7 @@ async function getCurrentVersion(): Promise<string> {
157178
158179function showHelp ( ) : void {
159180 console . log ( `
160- Release Script - Update package.json version and create git tag
181+ Release Script - Update package.json version, commit change, and create git tag
161182
162183Usage:
163184 bun run release [version|increment] [--dry-run]
@@ -245,6 +266,9 @@ async function main(): Promise<void> {
245266 // Update package.json
246267 await updatePackageJson ( newVersion , dryRun ) ;
247268
269+ // Commit package.json changes
270+ await commitPackageJsonChanges ( newVersion , dryRun ) ;
271+
248272 // Create git tag
249273 await createGitTag ( newVersion , dryRun ) ;
250274
@@ -256,8 +280,9 @@ async function main(): Promise<void> {
256280 console . log ( '🎉 Release completed successfully!' ) ;
257281 console . log ( '' ) ;
258282 console . log ( 'Next steps:' ) ;
259- console . log ( ' 1. Push the tag: git push origin v' + newVersion ) ;
260- console . log ( ' 2. This will trigger the GitHub release workflow' ) ;
283+ console . log ( ' 1. Push the commit: git push' ) ;
284+ console . log ( ' 2. Push the tag: git push origin v' + newVersion ) ;
285+ console . log ( ' 3. This will trigger the GitHub release workflow' ) ;
261286 }
262287
263288 } catch ( error ) {
0 commit comments