build: build with docker

This commit is contained in:
鲁树人
2025-03-28 12:14:59 +09:00
parent a40ecc4569
commit a07bcf2575
5 changed files with 63 additions and 3 deletions

View File

@@ -7,8 +7,13 @@ import { execSync } from 'node:child_process';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const commitHash = execSync('git rev-parse --short HEAD').toString('utf-8').trim();
let commitHash = process.env.GIT_COMMIT || 'unknown';
try {
execSync('git rev-parse --short HEAD').toString('utf-8').trim();
} catch (e) {
console.error('Failed to get commit hash:', e);
}
const pkgJson = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf-8'));
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash ?? 'unknown'}` + '\n';
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash}` + '\n';
writeFileSync(__dirname + '/../dist/version.txt', pkgVer, 'utf-8');