From 0204d9263aba8c76f9d45ec145ab65f68c9dc7ba Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 19 Mar 2026 22:24:41 +0100 Subject: [PATCH] Use SOURCE_COMMIT w/ nixpacks --- web/build.mjs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/web/build.mjs b/web/build.mjs index 26ea00f..6968572 100644 --- a/web/build.mjs +++ b/web/build.mjs @@ -83,22 +83,28 @@ if (existsSync(workerSrc)) { // Get git version string let versionStr = 'unknown'; let versionLink = 'https://github.com/nicoverbruggen/kobopatch-webui'; +const nixpacksCommit = process.env.SOURCE_COMMIT; try { - const hash = String(execSync('git rev-parse --short HEAD', { cwd: repoDir })).trim(); - - let tag = ''; - try { - tag = String(execSync('git describe --tags --exact-match 2>/dev/null', { cwd: repoDir })).trim(); - } catch {} - if (tag) { - versionStr = tag; - const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim(); - if (dirty) versionStr += ' (D)'; - versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/releases/tag/${tag}`; + if (nixpacksCommit) { + versionStr = nixpacksCommit.slice(0, 7); + versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/commit/${nixpacksCommit}`; } else { - const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim(); - versionStr = dirty ? `${hash} (D)` : hash; - versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/commit/${hash}`; + const hash = String(execSync('git rev-parse --short HEAD', { cwd: repoDir })).trim(); + + let tag = ''; + try { + tag = String(execSync('git describe --tags --exact-match 2>/dev/null', { cwd: repoDir })).trim(); + } catch {} + if (tag) { + versionStr = tag; + const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim(); + if (dirty) versionStr += ' (D)'; + versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/releases/tag/${tag}`; + } else { + const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim(); + versionStr = dirty ? `${hash} (D)` : hash; + versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/commit/${hash}`; + } } } catch {}