()
| 238 | } |
| 239 | |
| 240 | async function main() { |
| 241 | const version = getVersion(); |
| 242 | |
| 243 | console.log(isRelease |
| 244 | ? `🚀 RELEASE BUILD: Creating protocol tarball for AdCP v${version}` |
| 245 | : `📦 Development build: Creating latest protocol tarball`); |
| 246 | console.log(''); |
| 247 | |
| 248 | ensureDir(OUT_DIR); |
| 249 | |
| 250 | const stagingRoot = path.join(OUT_DIR, '.staging'); |
| 251 | ensureDir(stagingRoot); |
| 252 | |
| 253 | const latestSchemas = path.join(DIST_SCHEMAS, 'latest'); |
| 254 | if (!fs.existsSync(latestSchemas)) { |
| 255 | console.error(`❌ dist/schemas/latest not found. Run npm run build:schemas first.`); |
| 256 | process.exit(1); |
| 257 | } |
| 258 | |
| 259 | if (isRelease) { |
| 260 | const versionSchemas = path.join(DIST_SCHEMAS, version); |
| 261 | if (!fs.existsSync(versionSchemas)) { |
| 262 | console.error(`❌ dist/schemas/${version} not found. Run npm run build:schemas -- --release first.`); |
| 263 | process.exit(1); |
| 264 | } |
| 265 | |
| 266 | console.log(`📋 Staging bundle for ${version}`); |
| 267 | const versionStage = path.join(stagingRoot, version); |
| 268 | const versionRoot = `adcp-${version}`; |
| 269 | const manifest = stageBundle(versionStage, version, versionSchemas, versionRoot); |
| 270 | console.log(` ✓ manifest: ${manifest.file_count} files, root: ${manifest.root_dir}`); |
| 271 | |
| 272 | const versionTar = path.join(OUT_DIR, `${version}.tgz`); |
| 273 | await buildTarball(`version tarball`, versionStage, versionRoot, versionTar); |
| 274 | fs.writeFileSync(versionTar + '.sha256', `${sha256(versionTar)} ${version}.tgz\n`); |
| 275 | |
| 276 | console.log(`📋 Staging latest bundle (mirrors release)`); |
| 277 | const latestStage = path.join(stagingRoot, 'latest'); |
| 278 | stageBundle(latestStage, version, versionSchemas, versionRoot, true); |
| 279 | const latestTar = path.join(OUT_DIR, `latest.tgz`); |
| 280 | await buildTarball(`latest tarball`, latestStage, versionRoot, latestTar); |
| 281 | fs.writeFileSync(latestTar + '.sha256', `${sha256(latestTar)} latest.tgz\n`); |
| 282 | |
| 283 | console.log(`📝 Staging dist/protocol/${version}.tgz for git commit`); |
| 284 | try { |
| 285 | execSync(`git add dist/protocol/${version}.tgz dist/protocol/${version}.tgz.sha256`, { |
| 286 | cwd: ROOT, |
| 287 | stdio: 'inherit' |
| 288 | }); |
| 289 | } catch { |
| 290 | console.log(` (git add skipped — not in git context)`); |
| 291 | } |
| 292 | // .sig and .crt are produced by sign-protocol-tarball.sh after this script |
| 293 | // runs; that script handles its own staging. |
| 294 | } else { |
| 295 | console.log(`📋 Staging latest bundle`); |
| 296 | const latestStage = path.join(stagingRoot, 'latest'); |
| 297 | const latestRoot = `adcp-latest`; |
no test coverage detected