From d721c9c1e3c002ee8489b3537f492322702ed75a Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Sat, 19 Jul 2025 23:11:18 +0800 Subject: [PATCH] fix(ci): git tag describe will fail when doing nightly and manual build --- apps/stage-tamagotchi/scripts/utils.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/stage-tamagotchi/scripts/utils.ts b/apps/stage-tamagotchi/scripts/utils.ts index 5a694837e..019949723 100644 --- a/apps/stage-tamagotchi/scripts/utils.ts +++ b/apps/stage-tamagotchi/scripts/utils.ts @@ -36,8 +36,15 @@ export async function getVersion(options: { release: boolean, autoTag: boolean, // Now, only auto-tag & release && non-specific tag is the only possibility, // fetch the latest git ref - const res = await execa('git', ['describe', '--tags', '--abbrev=0']) - return String(res.stdout).replace(/^v/, '').trim() + try { + const res = await execa('git', ['describe', '--tags', '--abbrev=0']) + return String(res.stdout).replace(/^v/, '').trim() + } + catch { + // If no tags exist, fall back to package.json version + console.warn('No git tags found, falling back to package.json version') + return packageJSON.version + } } export async function getFilename(target: string, options: { release: boolean, autoTag: boolean, tag: string[] }) {