@@ -4,6 +4,8 @@ import { ensureFile } from '@std/fs';
44import { updateAllVersions } from '../manifest/mod.ts' ;
55import { setVersion as setVersionsManifest } from '../versions/mod.ts' ;
66
7+ export type TagStrategy = 'github' | 'git' ;
8+
79export class ReleaseManager {
810 constructor ( private storage : Storage ) { }
911
@@ -184,6 +186,7 @@ export class ReleaseManager {
184186 bump : VersionBump ,
185187 sha : string ,
186188 dryRun = false ,
189+ tagStrategy : TagStrategy = 'github' ,
187190 ) : Promise < Release > {
188191 const tag = `v${ bump . to } ` ;
189192 const notes = this . generateReleaseNotes ( bump ) ;
@@ -253,18 +256,45 @@ export class ReleaseManager {
253256 release . sha = new TextDecoder ( ) . decode ( amendedShaResult . stdout ) . trim ( ) ;
254257 }
255258
256- // Push commit to remote (tag will be created by storage.saveRelease via API)
257- const pushCommand = new Deno . Command ( 'git' , {
258- args : [ 'push' , 'origin' , 'HEAD' ] ,
259- } ) ;
260- const pushResult = await pushCommand . output ( ) ;
259+ if ( tagStrategy === 'git' ) {
260+ // Create tag locally using git CLI
261+ const tagCommand = new Deno . Command ( 'git' , {
262+ args : [ 'tag' , '-a' , tag , '-m' , `Release ${ tag } ` ] ,
263+ } ) ;
264+ const { code, stderr } = await tagCommand . output ( ) ;
265+
266+ if ( code !== 0 ) {
267+ const error = new TextDecoder ( ) . decode ( stderr ) ;
268+ throw new PlsError (
269+ `Failed to create git tag: ${ error } ` ,
270+ 'GIT_TAG_ERROR' ,
271+ ) ;
272+ }
273+
274+ // Push commit and tag to remote
275+ const pushCommand = new Deno . Command ( 'git' , {
276+ args : [ 'push' , 'origin' , 'HEAD' , '--follow-tags' ] ,
277+ } ) ;
278+ const pushResult = await pushCommand . output ( ) ;
261279
262- if ( pushResult . code !== 0 ) {
263- const error = new TextDecoder ( ) . decode ( pushResult . stderr ) ;
264- console . warn ( `Warning: Failed to push to remote: ${ error } ` ) ;
280+ if ( pushResult . code !== 0 ) {
281+ const error = new TextDecoder ( ) . decode ( pushResult . stderr ) ;
282+ console . warn ( `Warning: Failed to push to remote: ${ error } ` ) ;
283+ }
284+ } else {
285+ // Push commit only (tag will be created by storage.saveRelease via API)
286+ const pushCommand = new Deno . Command ( 'git' , {
287+ args : [ 'push' , 'origin' , 'HEAD' ] ,
288+ } ) ;
289+ const pushResult = await pushCommand . output ( ) ;
290+
291+ if ( pushResult . code !== 0 ) {
292+ const error = new TextDecoder ( ) . decode ( pushResult . stderr ) ;
293+ console . warn ( `Warning: Failed to push to remote: ${ error } ` ) ;
294+ }
265295 }
266296
267- // Save release to storage (creates GitHub release + tag via API )
297+ // Save release to storage (creates GitHub release, and tag if using github strategy )
268298 await this . storage . saveRelease ( release ) ;
269299
270300 // Update CHANGELOG.md
0 commit comments