// Next safe build number (CFBundleVersion) from App Store Connect: one above the highest build ever uploaded for the // app, across every version train. Prints only the number on stdout, so scripts can use it: // storebound apple next-build -> 42 // xcodebuild ... CURRENT_PROJECT_VERSION=$(storebound apple next-build) // Then attach exactly that build: storebound apple listing --version x.y.z --build 42 (never "the latest"). import type { Ctx } from '../lib/ctx'; import { need } from '../lib/ctx'; import { printJson } from '../lib/log'; import { nextBuildNumber } from '../lib/release'; import { ascClient } from './asc'; export async function run(ctx: Ctx): Promise { const { config, root } = ctx.loaded; const c = await ascClient(root, need(config.apple?.bundleId, 'apple.bundleId'), config.apple?.appId); const appId = await c.app(); const builds = await c.all(`/v1/builds?filter[app]=${appId}&limit=200&fields[builds]=version`); const next = nextBuildNumber(builds.map(b => String(b.attributes.version))); if (ctx.args.has('json')) { printJson({ next, builds: builds.length }); return; } console.error(`[apple] ${builds.length} builds on App Store Connect; next build number:`); console.log(next); }