diff --git a/AGENTS.md b/AGENTS.md index 68ac0b5d..9350408e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -297,7 +297,8 @@ would want. build to production as a draft the person rolls out, and the beta build to every testing track. Never promote a testing build to production. - A game moves to the next minor version (x.y.z to x.(y+1).0) once its - current version has an approved release on either store; until then each + current version is in production on the App Store (in review or + approved doesn't count, and Play never does); until then each build keeps the version and takes only the next build number. A patch of 0 is left off (1.5, not 1.5.0); any other patch stays (1.4.1). - Google Play goes through the runtime's `Tools/Play/play.js` (its README), diff --git a/README.md b/README.md index 2a6d4100..1db543a6 100644 --- a/README.md +++ b/README.md @@ -1735,7 +1735,7 @@ commands. build number to TestFlight and to Play's internal and closed testing (through `Tools/Play/play.js`); `version.js` works out that number, one past the highest the project, App Store Connect and Play have taken, and bumps the -version once it has an approved release. Each game runs them through small +version once it's in production on the App Store. Each game runs them through small shims with its settings in `Tools/Release/release.json`; [`Tools/Release/README.md`](Tools/Release/README.md) has the settings, the steps and the rules. diff --git a/Tools/Release/README.md b/Tools/Release/README.md index ee7ab307..8cb5f1a7 100644 --- a/Tools/Release/README.md +++ b/Tools/Release/README.md @@ -119,12 +119,12 @@ Tools/Release/nightly.sh --notes notes.txt # the release (the nigh run nobody watches can't answer an SSH agent's prompt (1Password's waits for one forever). They never prompt, and give up after ten minutes. 3. **Version.** The minor goes up (1.7 → 1.8, 1.4.1 → 1.5, a patch of 0 - left off) once the version has an approved release on either store: an App Store version - Apple approved (waiting for release, live, or later replaced or removed), - or a production release on Play that names the version and that Google - approved (`play.js versions --approved`). Then the next build number. Both - go into a `Build ` commit (`Build (version )` when the version - moved), pushed only after an upload. + left off) once the version is in production on the App Store, on any of + its platforms: live, or live once and since replaced or removed. A version + waiting for review, in review or approved but not yet released doesn't + count, nor does Play: Android goes by build numbers alone. Then the next + build number. Both go into a `Build ` commit (`Build (version )` when + the version moved), pushed only after an upload. 4. **Notes.** This build's changes, `• ` lines in plain words for players: `--notes`, else drafted from the PR titles (the `notes` settings). 5. **Art.** The game's `art` steps. diff --git a/Tools/Release/lib.js b/Tools/Release/lib.js index 0b95ca55..5d80cd6e 100644 --- a/Tools/Release/lib.js +++ b/Tools/Release/lib.js @@ -4,10 +4,11 @@ const { sameVersion, namesVersion } = require('../Play/lib'); -// App Store states of a version Apple approved, released or not. -const APP_STORE_APPROVED = [ - 'PENDING_DEVELOPER_RELEASE', 'PENDING_APPLE_RELEASE', 'PROCESSING_FOR_APP_STORE', 'PROCESSING_FOR_DISTRIBUTION', - 'READY_FOR_SALE', 'READY_FOR_DISTRIBUTION', 'PREORDER_READY_FOR_SALE', 'ACCEPTED', +// App Store states of a version that reached production: live, or live once +// and since replaced or removed. Waiting for review, in review, approved but +// not yet released and every other state don't count. +const APP_STORE_LIVE = [ + 'READY_FOR_SALE', 'READY_FOR_DISTRIBUTION', 'PREORDER_READY_FOR_SALE', 'REPLACED_WITH_NEW_VERSION', 'REMOVED_FROM_SALE', 'DEVELOPER_REMOVED_FROM_SALE', ]; @@ -119,13 +120,13 @@ const ascUploadNumbers = (uploads) => uploads .filter((u) => (u.attributes?.state?.state ?? u.attributes?.state) !== 'AWAITING_UPLOAD') .map((u) => Number(u.attributes?.cfBundleVersion)).filter(Number.isFinite); -// The App Store version Apple approved for `version` (any platform), as +// The App Store version in production for `version` (any platform), as // " ", or null. 1.4 and 1.4.0 are the same version. -function appStoreApproved(versions, version) { +function appStoreLive(versions, version) { for (const v of versions) { const a = v.attributes ?? {}; if (!sameVersion(a.versionString, version)) continue; - const state = [a.appVersionState, a.appStoreState].find((s) => APP_STORE_APPROVED.includes(s)); + const state = [a.appVersionState, a.appStoreState].find((s) => APP_STORE_LIVE.includes(s)); if (state) return `${a.versionString} ${state}`; } return null; @@ -234,8 +235,8 @@ const HTTPS_GIT = [ ]; module.exports = { - APP_STORE_APPROVED, HTTPS_GIT, PLATFORMS, projectSetting, withBuild, withVersion, bumpMinor, withoutZeroPatch, - highestTaken, nextBuild, thisBuild, androidName, patchName, ascData, ascBuildNumbers, ascUploadNumbers, appStoreApproved, + APP_STORE_LIVE, HTTPS_GIT, PLATFORMS, projectSetting, withBuild, withVersion, bumpMinor, withoutZeroPatch, + highestTaken, nextBuild, thisBuild, androidName, patchName, ascData, ascBuildNumbers, ascUploadNumbers, appStoreLive, newPRs, buildInSubject, buildSubject, bulleted, plainTitle, draftNotes, FALLBACK, fill, settingsFrom, nightlyProblems, playRelease, sameVersion, namesVersion, }; diff --git a/Tools/Release/nightly.js b/Tools/Release/nightly.js index 7758f0dc..78067f74 100755 --- a/Tools/Release/nightly.js +++ b/Tools/Release/nightly.js @@ -392,7 +392,7 @@ if (DRY) { heading('Report'); const since = [PRS.length && `${PRS.length} PR${PRS.length === 1 ? '' : 's'}`, MOVES.length && `${MOVES.length} runtime move${MOVES.length === 1 ? '' : 's'}`].filter(Boolean).join(' and '); say(`${S.name} ${V.version}, build ${V.build}${DRY ? ' (dry run)' : ''}: ${since} since Build ${LAST.number}`); -if (V.bumped) say(`Version: ${V.previous} had an approved release (${V.approved}), so this is ${V.version}`); +if (V.bumped) say(`Version: ${V.previous} is in production on the App Store (${V.live}), so this is ${V.version}`); for (const [label, result] of RESULTS) say(`${label}: ${result}`); say(pushed); say(`Logs: ${LOGS}`); diff --git a/Tools/Release/release.test.js b/Tools/Release/release.test.js index fc68e3fc..8efd8d86 100644 --- a/Tools/Release/release.test.js +++ b/Tools/Release/release.test.js @@ -57,7 +57,7 @@ test('patch names count further Play uploads at one version', () => { assert.strictEqual(at([{ name: '53' }]), '1.1'); }); -test('App Store Connect: replies a page a line, and approved versions', () => { +test('App Store Connect: replies a page a line, and versions in production', () => { assert.deepStrictEqual(lib.ascData('{"data":[{"id":"a"}]}'), [{ id: 'a' }]); assert.deepStrictEqual(lib.ascData('{"data":[{"id":"a"}]}\n{"data":[{"id":"b"}]}\n'), [{ id: 'a' }, { id: 'b' }]); assert.deepStrictEqual(lib.ascData(''), []); @@ -68,13 +68,20 @@ test('App Store Connect: replies a page a line, and approved versions', () => { { attributes: { cfBundleVersion: '76', state: { state: 'FAILED' } } }, ]), [77, 76]); const versions = [ - { attributes: { versionString: '1.5', appVersionState: 'WAITING_FOR_REVIEW' } }, - { attributes: { versionString: '1.4', appVersionState: 'READY_FOR_DISTRIBUTION', appStoreState: 'READY_FOR_SALE' } }, - { attributes: { versionString: '1.3', appStoreState: 'REPLACED_WITH_NEW_VERSION' } }, + { attributes: { platform: 'IOS', versionString: '1.7', appVersionState: 'PENDING_DEVELOPER_RELEASE', appStoreState: 'PENDING_DEVELOPER_RELEASE' } }, + { attributes: { platform: 'IOS', versionString: '1.6', appVersionState: 'IN_REVIEW', appStoreState: 'IN_REVIEW' } }, + { attributes: { platform: 'IOS', versionString: '1.5', appVersionState: 'WAITING_FOR_REVIEW' } }, + { attributes: { platform: 'IOS', versionString: '1.2', appVersionState: 'WAITING_FOR_REVIEW' } }, + { attributes: { platform: 'TV_OS', versionString: '1.2', appVersionState: 'READY_FOR_DISTRIBUTION', appStoreState: 'READY_FOR_SALE' } }, + { attributes: { platform: 'IOS', versionString: '1.4', appVersionState: 'READY_FOR_DISTRIBUTION', appStoreState: 'READY_FOR_SALE' } }, + { attributes: { platform: 'IOS', versionString: '1.3', appStoreState: 'REPLACED_WITH_NEW_VERSION' } }, ]; - assert.strictEqual(lib.appStoreApproved(versions, '1.5.0'), null); - assert.strictEqual(lib.appStoreApproved(versions, '1.4.0'), '1.4 READY_FOR_DISTRIBUTION'); - assert.strictEqual(lib.appStoreApproved(versions, '1.3'), '1.3 REPLACED_WITH_NEW_VERSION'); + assert.strictEqual(lib.appStoreLive(versions, '1.7'), null); + assert.strictEqual(lib.appStoreLive(versions, '1.6'), null); + assert.strictEqual(lib.appStoreLive(versions, '1.5.0'), null); + assert.strictEqual(lib.appStoreLive(versions, '1.4.0'), '1.4 READY_FOR_DISTRIBUTION'); + assert.strictEqual(lib.appStoreLive(versions, '1.3'), '1.3 REPLACED_WITH_NEW_VERSION'); + assert.strictEqual(lib.appStoreLive(versions, '1.2'), '1.2 READY_FOR_DISTRIBUTION'); }); test('what is new: merge commits past the last build, oldest first', () => { @@ -130,7 +137,7 @@ test('the Play release always goes to internal, copied to alpha, for review; --s }); // A game on disk: its project, its settings and a stand-in for its play.js. -function fixture(settings = {}) { +function fixture(settings = {}, releases = [{ track: 'internal', name: '1.4.1', status: 'completed', versionCodes: [9] }]) { const root = fs.mkdtempSync(path.join(os.tmpdir(), 'release-test-')); fs.mkdirSync(path.join(root, 'Game.xcodeproj')); fs.writeFileSync(path.join(root, 'Game.xcodeproj/project.pbxproj'), PROJECT); @@ -138,10 +145,11 @@ function fixture(settings = {}) { fs.writeFileSync(path.join(root, 'Tools/Release/release.json'), JSON.stringify({ project: 'Game.xcodeproj', playDir: 'Play', ...settings })); fs.mkdirSync(path.join(root, 'Play')); fs.writeFileSync(path.join(root, 'Play/play.js'), ` + const releases = ${JSON.stringify(releases)}; const approved = process.argv.includes('--approved'); - console.log(JSON.stringify({ package: 'com.example.game', highest: 9, - releases: [{ track: 'internal', name: '1.4.1', status: 'completed', versionCodes: [9] }], - uploaded: [9], ...(approved ? { approved: null } : {}) }));`); + const live = releases.find((r) => r.track === 'production') ?? null; + console.log(JSON.stringify({ package: 'com.example.game', highest: 9, releases, + uploaded: [9], ...(approved ? { approved: live && { name: live.name, status: live.status } } : {}) }));`); return root; } const version = (root, ...argv) => spawnSync(process.execPath, [path.join(__dirname, 'version.js'), ...argv], { @@ -182,11 +190,19 @@ test('version.js: patch names and an export prefix from the settings', () => { assert.strictEqual(r.stdout, 'export MYGAME_VERSION_CODE=10\nexport MYGAME_VERSION_NAME=1.4.1.1\n'); }); -test('version.js --release: no approved release keeps the version and takes the next build', () => { +test('version.js --release: no App Store release in production keeps the version and takes the next build', () => { const root = fixture(); const r = version(root, '--release'); assert.strictEqual(r.status, 0, r.stderr); - assert.deepStrictEqual(JSON.parse(r.stdout), { previous: '1.4.1', version: '1.4.1', bumped: false, approved: null, build: 10, name: '1.4.1' }); + assert.deepStrictEqual(JSON.parse(r.stdout), { previous: '1.4.1', version: '1.4.1', bumped: false, live: null, build: 10, name: '1.4.1' }); +}); + +test('version.js --release: a production release on Play leaves the version alone', () => { + const root = fixture({}, [{ track: 'production', name: '1.4.1', status: 'completed', versionCodes: [9] }]); + const r = version(root, '--release'); + assert.strictEqual(r.status, 0, r.stderr); + assert.deepStrictEqual(JSON.parse(r.stdout), { previous: '1.4.1', version: '1.4.1', bumped: false, live: null, build: 10, name: '1.4.1' }); + assert.match(r.stderr, /isn't in production on the App Store: it stays/); }); test('nightly.js refuses --ref without --dry-run, and unknown options, before touching anything', () => { diff --git a/Tools/Release/stores.js b/Tools/Release/stores.js index 7fc1d026..85a67c54 100644 --- a/Tools/Release/stores.js +++ b/Tools/Release/stores.js @@ -57,10 +57,10 @@ function appStoreBuilds(settings) { return numbers; } -// The App Store version Apple approved for `version`, or null. -function appStoreApproved(settings, version) { +// The App Store version in production for `version` (any platform), or null. +function appStoreLive(settings, version) { const versions = lib.ascData(run('asc', ['versions', 'list', '--app', settings.appStore.app, '--paginate', '--output', 'json'])); - return lib.appStoreApproved(versions, version); + return lib.appStoreLive(versions, version); } // Where the project and the stores stand. @@ -94,27 +94,26 @@ function writeBuild(root, settings, text, build) { } // The nightly's version step, in `root` (its release worktree): bump the -// minor when the version has an approved release on either store, then take -// the next build number. Writes the project; returns what it did. +// minor when the version is in production on the App Store, then take +// the next build number. Play doesn't count: Android goes by build numbers +// alone. Writes the project; returns what it did. function release({ root, settings, log = console.error }) { const before = fs.readFileSync(projectFile(root, settings), 'utf8'); const previous = lib.projectSetting(before, 'MARKETING_VERSION'); - const onAppStore = settings.appStore?.app ? appStoreApproved(settings, previous) : null; - const play = playVersions(root, settings, previous); - const onPlay = play.approved; - const approved = [onAppStore && `App Store ${onAppStore}`, onPlay && `Play production ${onPlay.name} (${onPlay.status})`].filter(Boolean).join(', '); + const live = settings.appStore?.app ? appStoreLive(settings, previous) : null; + const play = playVersions(root, settings); let version = previous; - if (approved) { + if (live) { version = lib.bumpMinor(previous); fs.writeFileSync(projectFile(root, settings), lib.withVersion(before, previous, version)); - log(`Version ${previous} is approved (${approved}): this build is ${version}.`); + log(`Version ${previous} is in production on the App Store (${live}): this build is ${version}.`); } else { - log(`Version ${previous} has no approved release on either store: it stays.`); + log(`Version ${previous} isn't in production on the App Store: it stays.`); } const s = survey({ root, settings, play }); writeBuild(root, settings, s.text, s.next); log(`Build ${s.next}: one past the project's ${s.project}, App Store Connect's ${s.readsAppStore ? Math.max(0, ...s.appStore) || 'none' : 'not read'} and Play's ${s.play.highest || 'none'}.`); - return { previous, version, bumped: version !== previous, approved: approved || null, build: s.next, name: nameFor(settings, version, s.next, s.play) }; + return { previous, version, bumped: version !== previous, live, build: s.next, name: nameFor(settings, version, s.next, s.play) }; } -module.exports = { loadSettings, projectFile, survey, release, nameFor, writeBuild, playVersions, appStoreBuilds, appStoreApproved, run }; +module.exports = { loadSettings, projectFile, survey, release, nameFor, writeBuild, playVersions, appStoreBuilds, appStoreLive, run }; diff --git a/Tools/Release/version.js b/Tools/Release/version.js index e2aec383..f49d01d7 100755 --- a/Tools/Release/version.js +++ b/Tools/Release/version.js @@ -10,8 +10,8 @@ // node /version.js --offline read neither store (--print-only says the same) // node /version.js --json the same, as JSON, for scripts // node /version.js --release the nightly's step: the minor goes up once the -// version has an approved release on either -// store, then --next; JSON on stdout +// version is in production on the App +// Store, then --next; JSON on stdout // // The Xcode project's CURRENT_PROJECT_VERSION is the build number on both // platforms (the Android build reads it as its versionCode), and its