Update how version number is determined
Some checks failed
Build and test project / build-and-test (push) Has been cancelled
Some checks failed
Build and test project / build-and-test (push) Has been cancelled
This commit is contained in:
@@ -77,20 +77,23 @@ if (existsSync(workerSrc)) {
|
|||||||
|
|
||||||
// Get git version string
|
// Get git version string
|
||||||
let versionStr = 'unknown';
|
let versionStr = 'unknown';
|
||||||
let versionHash = 'unknown';
|
let versionLink = 'https://github.com/nicoverbruggen/kobopatch-webui';
|
||||||
try {
|
try {
|
||||||
const hash = String(execSync('git rev-parse --short HEAD', { cwd: repoDir })).trim();
|
const hash = String(execSync('git rev-parse --short HEAD', { cwd: repoDir })).trim();
|
||||||
versionHash = hash;
|
|
||||||
|
|
||||||
let tag = '';
|
let tag = '';
|
||||||
try {
|
try {
|
||||||
tag = String(execSync('git describe --tags --exact-match', { cwd: repoDir, stdio: 'ignore' })).trim();
|
tag = String(execSync('git describe --tags --exact-match', { cwd: repoDir })).trim();
|
||||||
} catch {}
|
} catch {}
|
||||||
if (tag) {
|
if (tag) {
|
||||||
versionStr = 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 {
|
} else {
|
||||||
const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim();
|
const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim();
|
||||||
versionStr = dirty ? `${hash} (D)` : hash;
|
versionStr = dirty ? `${hash} (D)` : hash;
|
||||||
|
versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/commit/${hash}`;
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
@@ -121,7 +124,7 @@ html = html.replace(
|
|||||||
html = html.replace('<span id="commit-hash"></span>', `<span id="commit-hash">${versionStr}</span>`);
|
html = html.replace('<span id="commit-hash"></span>', `<span id="commit-hash">${versionStr}</span>`);
|
||||||
html = html.replace(
|
html = html.replace(
|
||||||
'href="https://github.com/nicoverbruggen/kobopatch-webui"',
|
'href="https://github.com/nicoverbruggen/kobopatch-webui"',
|
||||||
`href="https://github.com/nicoverbruggen/kobopatch-webui/commit/${versionHash}"`
|
`href="${versionLink}"`
|
||||||
);
|
);
|
||||||
|
|
||||||
writeFileSync(join(distDir, 'index.html'), html);
|
writeFileSync(join(distDir, 'index.html'), html);
|
||||||
|
|||||||
Reference in New Issue
Block a user