@@ -24,23 +24,23 @@ let newVersion = mainPackageJson.version;
2424
2525// Async function to publish a package
2626async function publishPackage ( dir , isDryRun ) {
27-
2827 const packageJsonPath = join ( dir , 'package.json' ) ;
2928 if ( ! existsSync ( packageJsonPath ) ) {
3029 return ;
3130 }
32-
31+
3332 const packageJson = loadJsonFile ( packageJsonPath ) ;
3433 if ( packageJson . private ) {
3534 console . log ( `Skipping private package: ${ packageJson . name } ` ) ;
3635 return ;
3736 }
38-
37+
3938 try {
4039 console . log ( `Publishing package: ${ packageJson . name } from ${ dir } ...` ) ;
4140 if ( isDryRun ) {
4241 console . log ( `[DRY RUN] Would publish: ${ packageJson . name } ` ) ;
43- } else {
42+ }
43+ else {
4444 await execAsync ( 'npm publish' , { cwd : dir } ) ;
4545 console . log ( `Successfully published: ${ packageJson . name } ` ) ;
4646 }
@@ -53,7 +53,6 @@ async function publishPackage(dir, isDryRun) {
5353// Read all workspaces - private packages will be filtered out during publishing
5454const workspaceGlobs = mainPackageJson . workspaces ;
5555( async ( ) => {
56-
5756 // publishing packages
5857 console . log ( `\n=== PUBLISH PHASE ===` ) ;
5958 console . log ( `Processing packages for publication...` ) ;
@@ -68,13 +67,13 @@ const workspaceGlobs = mainPackageJson.workspaces;
6867 console . log ( 'All packages have been processed.' ) ;
6968
7069 console . log ( `Updated versions of all packages to ${ newVersion } ` ) ;
71-
70+
7271 if ( dryRun ) {
7372 console . log ( '[DRY RUN] Would update package-lock.json, commit changes, and create tag' ) ;
7473 console . log ( '[DRY RUN] No git operations performed' ) ;
7574 return ;
7675 }
77-
76+
7877 // Update the root package-lock.json to reflect updated sub-package versions.
7978 console . log ( 'Updating root package-lock.json...' ) ;
8079 await execAsync ( 'npm install' , { cwd : process . cwd ( ) } ) ;
@@ -96,19 +95,19 @@ const workspaceGlobs = mainPackageJson.workspaces;
9695 console . log ( 'Pushing changes...' ) ;
9796 await execAsync ( 'git push' ) ;
9897
99- // Tag the new version
100- console . log ( 'Tagging new version...' ) ;
101- await execAsync ( `git tag -a v${ newVersion } -m "Release version ${ newVersion } "` ) ;
102- await execAsync ( 'git push --tags' ) ;
103-
104- console . log ( 'Committed and pushed version updates and created a new tag.' ) ;
98+ console . log ( 'Committed and pushed version updates.' ) ;
10599 }
106100 else {
107101 console . log ( 'No changes to commit.' ) ;
108102 }
103+
104+ // Always tag the new version after successful publish
105+ console . log ( 'Tagging new version...' ) ;
106+ await execAsync ( `git tag -a v${ newVersion } -m "Release version ${ newVersion } "` ) ;
107+ await execAsync ( 'git push --tags' ) ;
108+ console . log ( 'Created and pushed tag for version ' + newVersion ) ;
109109 }
110110 catch ( error ) {
111111 console . error ( `Failed to commit and push changes: ${ error . message } ` ) ;
112112 }
113-
114113} ) ( ) ;
0 commit comments