@@ -405,6 +405,7 @@ const checkAction = async (tangram: string, path: string): Promise<Result> => {
405
405
/** Perform the `publish` action for a package name. If the existing tag is out of date, tag and push the new package. */
406
406
const publishAction = async ( tangram : string , name : string , path : string ) : Promise < Result > => {
407
407
log ( "publishing..." ) ;
408
+
408
409
// Check in the package, store the ID.
409
410
const packageIdResult = await checkinPackage ( tangram , path ) ;
410
411
if ( packageIdResult . kind !== "ok" ) {
@@ -415,19 +416,27 @@ const publishAction = async (tangram: string, name: string, path: string): Promi
415
416
return result ( "checkinError" , `no ID for ${ path } ` ) ;
416
417
}
417
418
418
- log ( `tagging ${ name } ...` ) ;
419
- const tagResult = await tagPackage ( tangram , name , path ) ;
420
- if ( tagResult . kind !== "ok" ) {
421
- return tagResult ;
422
- }
419
+ // Check if the tag already matches this ID.
420
+ let existing = await existingTaggedItem ( tangram , name ) ;
423
421
424
- // Push the tag.
425
- const pushTagResult = await push ( tangram , name ) ;
426
- if ( pushTagResult . kind !== "ok" ) {
427
- return pushTagResult ;
428
- }
422
+ if ( packageId === existing ) {
423
+ log ( `Existing tag for ${ name } matches current ID:` , existing ) ;
424
+ return ok ( `${ name } unchanged, no action taken.` ) ;
425
+ } else {
426
+ log ( `tagging ${ name } ...` ) ;
427
+ const tagResult = await tagPackage ( tangram , name , path ) ;
428
+ if ( tagResult . kind !== "ok" ) {
429
+ return tagResult ;
430
+ }
431
+
432
+ // Push the tag.
433
+ const pushTagResult = await push ( tangram , name ) ;
434
+ if ( pushTagResult . kind !== "ok" ) {
435
+ return pushTagResult ;
436
+ }
429
437
430
- return ok ( `tagged ${ name } : ${ packageId } ` ) ;
438
+ return ok ( `tagged ${ name } : ${ packageId } ` ) ;
439
+ }
431
440
} ;
432
441
433
442
/** Perform the upload action for a path. Will do the default build first. */
0 commit comments