/** * `pnpm --filter @rosea/tauri sign:apk `: the release APK, signed in Custos * (fabrica-release.md F4). Runs after the release's approval; Mark's card shows the match code * custos-sign prints. Nothing is written unless custos-sign signs and verifies. */ import { spawnSync } from 'node:child_process'; import { existsSync, mkdirSync } from 'node:fs'; import { join } from 'node:path'; import { custosSign, signArgs, signedApkName, UNSIGNED_APK } from '../src/sign-apk.js'; import { PACKAGE, SRC_TAURI } from './tauri.js'; const [version = '', commit = ''] = process.argv.slice(2); try { const unsigned = join(SRC_TAURI, UNSIGNED_APK); if (!existsSync(unsigned)) throw new Error(`no release APK at ${unsigned}; run 'pnpm tauri:android-release' first`); const outDir = join(PACKAGE, '..', '..', 'target', 'release'); mkdirSync(outDir, { recursive: true }); const exe = custosSign(process.env, existsSync); const args = signArgs({ version, commit, unsigned, out: join(outDir, signedApkName(version)) }); const run = spawnSync(exe, args, { stdio: 'inherit' }); if (run.error) throw run.error; process.exit(run.status ?? 1); } catch (e) { console.error(`sign:apk: ${e instanceof Error ? e.message : String(e)}`); process.exit(1); }