@@ -50,9 +50,31 @@ console.log(`Major: ${major}, Iteration: ${iteration}`);
5050// 2. Configure git identity in CI
5151configureGitIdentityInCI ( ) ;
5252
53- // 3. Find the latest patch number for this devnet
54- const tagPattern = `v${ major } .0.0-devnet.${ iteration } -patch.` ;
55- const existingTags = execSync ( `git tag -l "${ tagPattern } *"` , {
53+ // 3. Check if HEAD already has a devnet tag for this branch
54+ const devnetTagPrefix = `v${ major } .0.0-devnet.${ iteration } -patch.` ;
55+ const headTags = execSync ( "git tag --points-at HEAD" , { encoding : "utf-8" } ) ;
56+ const existingDevnetTag = headTags
57+ . split ( "\n" )
58+ . map ( ( t ) => t . trim ( ) )
59+ . find ( ( t ) => t . startsWith ( devnetTagPrefix ) ) ;
60+
61+ if ( existingDevnetTag ) {
62+ const existingPatch = existingDevnetTag . split ( "-patch." ) . pop ( ) ! ;
63+ const existingSemver = existingDevnetTag . slice ( 1 ) ;
64+ const existingNamespace = `v${ major } -devnet-${ iteration } ` ;
65+ console . log ( `HEAD already tagged as ${ existingDevnetTag } , nothing to do.` ) ;
66+ writeGithubOutputs ( {
67+ tag : existingDevnetTag ,
68+ semver : existingSemver ,
69+ namespace : existingNamespace ,
70+ ref : branch ,
71+ patch : existingPatch ,
72+ } ) ;
73+ process . exit ( 0 ) ;
74+ }
75+
76+ // 4. Find the latest patch number for this devnet
77+ const existingTags = execSync ( `git tag -l "${ devnetTagPrefix } *"` , {
5678 encoding : "utf-8" ,
5779} ) ;
5880
@@ -77,12 +99,12 @@ if (dryRun) {
7799 console . log ( `[dry-run] Would create tag: ${ tag } ` ) ;
78100 console . log ( `[dry-run] Would push tag to origin` ) ;
79101} else {
80- // 4 . Create and push the tag
102+ // 5 . Create and push the tag
81103 execSync ( `git tag -a "${ tag } " -m "Devnet patch release ${ tag } "` ) ;
82104 execSync ( `git push origin "${ tag } "` ) ;
83105
84106 console . log ( `Tag ${ tag } created and pushed.` ) ;
85107
86- // 5 . Write outputs for CI
108+ // 6 . Write outputs for CI
87109 writeGithubOutputs ( { tag, semver, namespace, ref : branch , patch : String ( nextPatch ) } ) ;
88110}
0 commit comments