From d3434457e711b22ba05f736262c25637b0085803 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 17 Aug 2026 16:27:13 -0400 Subject: [PATCH 1/2] build(version): derive app version from git tag when package.json is a placeholder --- vite.config.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index c879bacb8..517300225 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -30,6 +30,8 @@ function resolvePath(...args: string[]) { return normalizePath(path.resolve(...args)); } +const PLACEHOLDER_VERSION = '0.0.0'; + function getPackageInfo() { const mainPkgPath = path.resolve(__dirname, 'package.json'); const mainPkg = JSON.parse(fs.readFileSync(mainPkgPath, 'utf-8')); @@ -48,13 +50,32 @@ function getPackageInfo() { return { versions: { - volview: mainPkg.version, + volview: getVolViewVersion(mainPkg.version), 'vtk.js': vtkJsPkg.version, 'itk-wasm': itkWasmPkg.version, }, }; } +// package.json carries the placeholder 0.0.0 on main; the release workflow +// stamps the real version from the pushed tag before it builds. Builds that +// skip that step (Netlify, local dev) fall back to describing the tag directly. +function getVolViewVersion(pkgVersion: string) { + if (pkgVersion !== PLACEHOLDER_VERSION) return pkgVersion; + return getGitDescribe() ?? pkgVersion; +} + +function getGitDescribe() { + try { + const described = execSync('git describe --tags --always') + .toString() + .trim(); + return described.replace(/^v/, ''); + } catch { + return undefined; + } +} + function getGitShortSha() { try { return execSync('git rev-parse --short HEAD').toString().trim(); From 778aee1011fe9b68c03b4c4fbedf6591be442073 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 17 Aug 2026 16:32:52 -0400 Subject: [PATCH 2/2] build(netlify): fetch tags so the deployed About box shows a version --- netlify.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 6d7d2fdcb..c0470fbc0 100644 --- a/netlify.toml +++ b/netlify.toml @@ -9,7 +9,9 @@ VITE_SHOW_SAMPLE_DATA= "true" [build] -command = "sed -i \"s|DICOM_WEB_API_KEY|${DICOM_WEB_API_KEY}|g; s|DICOM_WEB_ADDRESS|${DICOM_WEB_ADDRESS}|g\" netlify.toml && npm run build" +# The version shown in the About box comes from `git describe`, which needs tags +# and enough history to count from them. Netlify clones neither by default. +command = "{ git fetch --tags --unshallow || git fetch --tags; } 2>/dev/null; sed -i \"s|DICOM_WEB_API_KEY|${DICOM_WEB_API_KEY}|g; s|DICOM_WEB_ADDRESS|${DICOM_WEB_ADDRESS}|g\" netlify.toml && npm run build" [dev] targetPort = 8080