Publish release manifest with NAS deployments
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const qaVersion = process.env.PUBLIC_QA_VERSION ?? makeQaVersion();
|
||||
|
||||
runPnpmScript('verify:local-release');
|
||||
runPnpmScript('qa:early');
|
||||
writeReleaseManifest(qaVersion);
|
||||
runPnpmScript('deploy:nas:dist');
|
||||
runPnpmScript('verify:public-deploy', { PUBLIC_QA_VERSION: qaVersion });
|
||||
|
||||
@@ -14,6 +17,30 @@ function makeQaVersion() {
|
||||
return `ship-${stamp}`;
|
||||
}
|
||||
|
||||
function writeReleaseManifest(qaVersion) {
|
||||
const manifest = {
|
||||
app: 'heros_web',
|
||||
qaVersion,
|
||||
commit: gitValue(['rev-parse', 'HEAD'], 'unknown'),
|
||||
shortCommit: gitValue(['rev-parse', '--short', 'HEAD'], 'unknown'),
|
||||
branch: gitValue(['branch', '--show-current'], 'unknown'),
|
||||
generatedAt: new Date().toISOString(),
|
||||
verification: ['verify:local-release', 'qa:early', 'verify:public-deploy']
|
||||
};
|
||||
|
||||
mkdirSync('dist', { recursive: true });
|
||||
writeFileSync(join('dist', 'release-manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
|
||||
console.log(`Wrote dist/release-manifest.json for ${manifest.shortCommit} (${qaVersion})`);
|
||||
}
|
||||
|
||||
function gitValue(args, fallback) {
|
||||
const result = spawnSync('git', args, { cwd: process.cwd(), encoding: 'utf8' });
|
||||
if (result.status !== 0) {
|
||||
return fallback;
|
||||
}
|
||||
return result.stdout.trim() || fallback;
|
||||
}
|
||||
|
||||
function runPnpmScript(scriptName, extraEnv = {}) {
|
||||
const label = `pnpm run ${scriptName}`;
|
||||
console.log(`\n$ ${label}`);
|
||||
|
||||
Reference in New Issue
Block a user