diff --git a/package.json b/package.json index a9684af..c05b130 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "verify:local-release": "pnpm run verify:battle-save && pnpm run verify:campaign-save && tsc --noEmit && pnpm run build && pnpm run verify:release", "verify:public-deploy": "node scripts/verify-public-deploy.mjs", "qa:representative": "node scripts/qa-representative-battles.mjs", - "deploy:nas": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/deploy-nas.ps1 -Build" + "deploy:nas": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/deploy-nas.ps1 -Build", + "ship:release": "node scripts/ship-release.mjs" }, "dependencies": { "phaser": "^3.90.0" diff --git a/scripts/ship-release.mjs b/scripts/ship-release.mjs new file mode 100644 index 0000000..70776ae --- /dev/null +++ b/scripts/ship-release.mjs @@ -0,0 +1,36 @@ +import { spawnSync } from 'node:child_process'; + +const qaVersion = process.env.PUBLIC_QA_VERSION ?? makeQaVersion(); + +runPnpmScript('verify:local-release'); +runPnpmScript('deploy:nas'); +runPnpmScript('verify:public-deploy', { PUBLIC_QA_VERSION: qaVersion }); + +console.log(`Shipped and verified public deploy with PUBLIC_QA_VERSION=${qaVersion}`); + +function makeQaVersion() { + const stamp = new Date().toISOString().replace(/[-:.TZ]/g, '').slice(0, 14); + return `ship-${stamp}`; +} + +function runPnpmScript(scriptName, extraEnv = {}) { + const label = `pnpm run ${scriptName}`; + console.log(`\n$ ${label}`); + + const result = + process.platform === 'win32' + ? spawnSync(process.env.ComSpec ?? 'cmd.exe', ['/d', '/s', '/c', `pnpm.cmd run ${scriptName}`], { + cwd: process.cwd(), + env: { ...process.env, ...extraEnv }, + stdio: 'inherit' + }) + : spawnSync('pnpm', ['run', scriptName], { + cwd: process.cwd(), + env: { ...process.env, ...extraEnv }, + stdio: 'inherit' + }); + + if (result.status !== 0) { + throw new Error(`Command failed: ${label}`); + } +}