From a77e01e07873c081e8d21bc1ea347f675210bde3 Mon Sep 17 00:00:00 2001 From: Ben Lovy Date: Thu, 9 Jan 2025 16:09:53 -0500 Subject: [PATCH] don't re-push unchanged tags --- scripts/package_automation.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/scripts/package_automation.ts b/scripts/package_automation.ts index 5801d81b..bbb10377 100644 --- a/scripts/package_automation.ts +++ b/scripts/package_automation.ts @@ -405,6 +405,7 @@ const checkAction = async (tangram: string, path: string): Promise => { /** Perform the `publish` action for a package name. If the existing tag is out of date, tag and push the new package. */ const publishAction = async (tangram: string, name: string, path: string): Promise => { log("publishing..."); + // Check in the package, store the ID. const packageIdResult = await checkinPackage(tangram, path); if (packageIdResult.kind !== "ok") { @@ -415,19 +416,27 @@ const publishAction = async (tangram: string, name: string, path: string): Promi return result("checkinError", `no ID for ${path}`); } - log(`tagging ${name}...`); - const tagResult = await tagPackage(tangram, name, path); - if (tagResult.kind !== "ok") { - return tagResult; - } + // Check if the tag already matches this ID. + let existing = await existingTaggedItem(tangram, name); - // Push the tag. - const pushTagResult = await push(tangram, name); - if (pushTagResult.kind !== "ok") { - return pushTagResult; - } + if (packageId === existing) { + log(`Existing tag for ${name} matches current ID:`, existing); + return ok(`${name} unchanged, no action taken.`); + } else { + log(`tagging ${name}...`); + const tagResult = await tagPackage(tangram, name, path); + if (tagResult.kind !== "ok") { + return tagResult; + } + + // Push the tag. + const pushTagResult = await push(tangram, name); + if (pushTagResult.kind !== "ok") { + return pushTagResult; + } - return ok(`tagged ${name}: ${packageId}`); + return ok(`tagged ${name}: ${packageId}`); + } }; /** Perform the upload action for a path. Will do the default build first. */