storebound aab <file> --json (offline packageName / versionCode / versionName / SDKs / sha256, no config) and play release --json result for CI scripts that replace their own Play API calls

This commit is contained in:
CRTkafa 2026-10-22 03:28:46 +08:00
parent ee35b11341
commit 256e8e33ad
9 changed files with 47 additions and 3 deletions

View file

@ -8,9 +8,10 @@
// Draft app (never published): Play only accepts status "draft" on any track; the first production release is sent
// from the Console (see the play-first-release skill).
import { readFileSync, statSync } from 'node:fs';
import { createHash } from 'node:crypto';
import type { Ctx } from '../lib/ctx';
import { confirm, need } from '../lib/ctx';
import { done, log, warn } from '../lib/log';
import { done, log, warn, printJson } from '../lib/log';
import { aabInfo } from '../lib/gradle';
import { playTargetSdkProblem, targetSdkFile } from '../lib/store-minimums';
import { playClient } from './client';
@ -55,6 +56,7 @@ export async function run(ctx: Ctx): Promise<void> {
if (sdkWhy) throw new Error(`${aab}: not released, ${sdkWhy}`);
}
const play = await playClient(root, pkg);
let released = fixed ?? '';
try {
await play.edit(async (id, ctl) => {
let code = fixed ?? '';
@ -74,6 +76,7 @@ export async function run(ctx: Ctx): Promise<void> {
log('play', `uploaded versionCode ${code}`);
}
}
released = code;
let changed = 0;
for (const t of tracks) {
const release: PlayTrackRelease = { versionCodes: [code], status: t.status };
@ -100,5 +103,8 @@ export async function run(ctx: Ctx): Promise<void> {
if (config.play?.managedPublishing !== true) warn('play', `managed publishing is ${config.play?.managedPublishing === false ? 'off' : 'off by default (play.managedPublishing not set)'}: the release goes live automatically once Google approves it`);
if (prod.status === 'draft') log('play', 'next: `storebound console plan play-production-countries` (the API cannot set countries), then `storebound console plan play-production-release` (its final "Send changes for review" is the owner\'s)');
}
// machine-readable result for CI scripts (a Jenkins stage reads it instead of calling the Play API itself)
if (a.has('json')) printJson({ versionCode: released ? Number(released) : null, sha256: aab ? createHash('sha256').update(readFileSync(aab)).digest('hex') : null, name: a.get('name') ?? null,
tracks: tracks.map(t => ({ track: t.track, status: t.status, userFraction: t.status === 'inProgress' ? Number(fraction ?? 0.1) : null })), dry: a.has('dry') });
done('play', 'release done');
}