From 68a9581ae63b7088264cda42535c2f3f4d3af686 Mon Sep 17 00:00:00 2001 From: rdlabo Date: Fri, 20 Nov 2026 10:16:29 +0900 Subject: [PATCH 1/2] fix: classify stable releases using stable tags --- .../classify-mobile-release.mjs | 29 ++++++++++++- .../classify-mobile-release.spec.mjs | 42 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/.github/actions/classify-mobile-release/classify-mobile-release.mjs b/.github/actions/classify-mobile-release/classify-mobile-release.mjs index 915698cc..a68dace2 100644 --- a/.github/actions/classify-mobile-release/classify-mobile-release.mjs +++ b/.github/actions/classify-mobile-release/classify-mobile-release.mjs @@ -36,7 +36,7 @@ export function selectPreviousTag(tags, { currentTag, currentMatch, containsAppP return tags .filter((candidate) => candidate !== `v${currentTag}`) .map((candidate) => ({ candidate, match: parseReleaseTag(candidate) })) - .filter(({ match }) => match && compareRelease(match, currentMatch) < 0) + .filter(({ match }) => match && compareRelease(match, currentMatch) < 0 && (currentMatch[4] !== undefined || match[4] === undefined)) .filter(({ candidate }) => containsAppPackage(candidate)) .sort((left, right) => compareRelease(right.match, left.match))[0]?.candidate; } @@ -120,6 +120,14 @@ export function classifyRelease({ return 'live-update'; } +export function assertUnusedStoreBuild(buildNumber, handoffs) { + for (const { tag, buildNumber: previousBuild } of handoffs) { + if (Number(buildNumber) <= Number(previousBuild)) { + throw new Error(`Store build ${buildNumber} must exceed ${previousBuild} already handed off by ${tag}.`); + } + } +} + export function buildOutputLines(releaseKind, version, buildNumber) { return [ `release_kind=${releaseKind}`, @@ -196,6 +204,25 @@ export function main({ argv = process.argv.slice(2), env = process.env } = {}) { nativeFilesChanged, nativeDependencyChanges, }); + if (releaseKind === 'store' && tagMatch[4] === undefined) { + const [, major, minor] = tagMatch; + // The release baseline ignores prereleases, but a handoff in this train + // can still have consumed a build number. + const handoffTags = execFileSync('git', ['tag', '--list', `capawesome/v${major}.${minor}.*-*`], { + encoding: 'utf8', + }).trim(); + const handoffs = handoffTags ? handoffTags.split('\n') : []; + assertUnusedStoreBuild( + native.buildNumber, + handoffs.map((tag) => ({ + tag, + buildNumber: readNativeVersions( + gitShow(`${appPath}/android/app/build.gradle`, tag), + gitShow(`${appPath}/ios/App/App.xcodeproj/project.pbxproj`, tag), + ).buildNumber, + })), + ); + } const lines = buildOutputLines(releaseKind, version, native.buildNumber); if (env.GITHUB_OUTPUT) appendFileSync(env.GITHUB_OUTPUT, `${lines.join('\n')}\n`); console.log(`Classified v${version} as ${releaseKind} for native ${native.marketingVersion} (${native.buildNumber}).`); diff --git a/.github/actions/classify-mobile-release/classify-mobile-release.spec.mjs b/.github/actions/classify-mobile-release/classify-mobile-release.spec.mjs index b4a57ab3..5fabe6ab 100644 --- a/.github/actions/classify-mobile-release/classify-mobile-release.spec.mjs +++ b/.github/actions/classify-mobile-release/classify-mobile-release.spec.mjs @@ -2,6 +2,7 @@ import assert from 'node:assert/strict'; import { describe, it } from 'node:test'; import { assertBuildEncodesVersion, + assertUnusedStoreBuild, buildOutputLines, classifyRelease, compareRelease, @@ -75,6 +76,35 @@ describe('previous release selection', () => { ); }); + it('uses the previous stable release for a stable promotion', () => { + const tags = ['v9.0.0', 'v9.1.0-1']; + const previousTag = selectPreviousTag(tags, { + currentTag: '9.1.0', + currentMatch: match('9.1.0'), + containsAppPackage: () => true, + }); + assert.equal(previousTag, 'v9.0.0'); + assert.equal( + classifyRelease( + classification({ + tagMatch: match('9.1.0'), + native: { marketingVersion: '9.1.0', buildNumber: '9010000' }, + previousTag, + previousMatch: parseReleaseTag(previousTag), + }), + ), + 'store', + ); + assert.equal( + selectPreviousTag(tags, { + currentTag: '9.1.0-2', + currentMatch: match('9.1.0-2'), + containsAppPackage: () => true, + }), + 'v9.1.0-1', + ); + }); + it('returns undefined for the first applicable release', () => { assert.equal( selectPreviousTag(['v9.0.0'], { @@ -252,6 +282,18 @@ describe('release classification', () => { }); }); +describe('native handoff build numbers', () => { + it('requires a store build above every prior handoff in its release train', () => { + const handoffs = [ + { tag: 'capawesome/v9.1.0-1', buildNumber: '9010001' }, + { tag: 'capawesome/v9.1.0-2', buildNumber: '9010002' }, + ]; + assert.throws(() => assertUnusedStoreBuild('9010002', handoffs), /already handed off by capawesome\/v9\.1\.0-2/); + assert.throws(() => assertUnusedStoreBuild('9010000', handoffs), /must exceed 9010001/); + assert.doesNotThrow(() => assertUnusedStoreBuild('9010003', handoffs)); + }); +}); + describe('action outputs', () => { it('emits the routing and existing Live Update outputs', () => { assert.deepEqual(buildOutputLines('live-update', '9.0.1', '9000000'), [ From 0b2943ff0ba43f813e5fd90779f0de98f5b33325 Mon Sep 17 00:00:00 2001 From: rdlabo Date: Fri, 20 Nov 2026 10:27:21 +0900 Subject: [PATCH 2/2] docs: document native build number validation --- .../actions/classify-mobile-release/classify-mobile-release.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/classify-mobile-release/classify-mobile-release.mjs b/.github/actions/classify-mobile-release/classify-mobile-release.mjs index a68dace2..7d05a590 100644 --- a/.github/actions/classify-mobile-release/classify-mobile-release.mjs +++ b/.github/actions/classify-mobile-release/classify-mobile-release.mjs @@ -120,6 +120,7 @@ export function classifyRelease({ return 'live-update'; } +/** Requires a store build number greater than every prior native handoff in its release train. */ export function assertUnusedStoreBuild(buildNumber, handoffs) { for (const { tag, buildNumber: previousBuild } of handoffs) { if (Number(buildNumber) <= Number(previousBuild)) {