@@ -46,6 +46,7 @@ export class PublishAction extends BaseRushAction {
4646 private _force : CommandLineFlagParameter ;
4747 private _prereleaseToken : PrereleaseToken ;
4848 private _versionPolicy : CommandLineStringParameter ;
49+ private _applyGitTagsOnPack : CommandLineFlagParameter ;
4950
5051 private _releaseFolder : CommandLineStringParameter ;
5152 private _pack : CommandLineFlagParameter ;
@@ -180,6 +181,12 @@ export class PublishAction extends BaseRushAction {
180181 parameterShortName : undefined ,
181182 description : 'If this flag is specified with --publish, packages will be published with --force on npm'
182183 } ) ;
184+ this . _applyGitTagsOnPack = this . defineFlagParameter ( {
185+ parameterLongName : '--apply-git-tags-on-pack' ,
186+ parameterShortName : undefined ,
187+ description : `If specified with --publish and --pack, git tags will be applied for packages on pack` +
188+ ` as if a publish was being run without --pack.`
189+ } ) ;
183190 }
184191
185192 /**
@@ -312,14 +319,23 @@ export class PublishAction extends BaseRushAction {
312319 if ( packageConfig . shouldPublish &&
313320 ( ! this . _versionPolicy . value || this . _versionPolicy . value === packageConfig . versionPolicyName )
314321 ) {
322+ const applyTag : ( apply : boolean ) => void = ( apply : boolean ) : void => {
323+ if ( ! apply ) {
324+ return ;
325+ }
326+
327+ git . addTag ( ! ! this . _publish . value && ! this . _registryUrl . value , packageName , packageConfig . packageJson . version ) ;
328+ updated = true ;
329+ } ;
330+
315331 if ( this . _pack . value ) {
316332 // packs to tarball instead of publishing to NPM repository
317333 this . _npmPack ( packageName , packageConfig ) ;
334+ applyTag ( this . _applyGitTagsOnPack . value ) ;
318335 } else if ( this . _force . value || ! this . _packageExists ( packageConfig ) ) {
319336 // Publish to npm repository
320337 this . _npmPublish ( packageName , packageConfig . projectFolder ) ;
321- git . addTag ( ! ! this . _publish . value && ! this . _registryUrl . value , packageName , packageConfig . packageJson . version ) ;
322- updated = true ;
338+ applyTag ( true ) ;
323339 } else {
324340 console . log ( `Skip ${ packageName } . Not updated.` ) ;
325341 }
0 commit comments