Use commit count as patch version instead of raw git describe output.
This commit is contained in:
parent
c164dacf18
commit
6fadff26c2
1 changed files with 10 additions and 2 deletions
|
|
@ -15,13 +15,21 @@ import buildConfig from './build.config';
|
||||||
function resolveAppVersion() {
|
function resolveAppVersion() {
|
||||||
if (process.env.VITE_APP_VERSION) return process.env.VITE_APP_VERSION;
|
if (process.env.VITE_APP_VERSION) return process.env.VITE_APP_VERSION;
|
||||||
try {
|
try {
|
||||||
return execSync('git describe --tags --always --dirty', {
|
const raw = execSync('git describe --tags --always --dirty', {
|
||||||
stdio: ['ignore', 'pipe', 'ignore'],
|
stdio: ['ignore', 'pipe', 'ignore'],
|
||||||
})
|
})
|
||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
|
const m = raw.match(/^(v?\d+\.\d+)\.\d+-(\d+)-g([0-9a-f]+)(-dirty)?$/);
|
||||||
|
if (m) {
|
||||||
|
const base = m[1];
|
||||||
|
const patch = m[2];
|
||||||
|
const hash = m[3];
|
||||||
|
const dirty = m[4] ?? '';
|
||||||
|
return `${base}.${patch}+g${hash}${dirty}`;
|
||||||
|
}
|
||||||
|
return raw;
|
||||||
} catch {
|
} catch {
|
||||||
// Fallback for builds without a usable .git (e.g. Docker — .git is in .dockerignore)
|
|
||||||
const pkg = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
const pkg = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
||||||
return `v${pkg.version}`;
|
return `v${pkg.version}`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue