:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(mobile): render readable release notes (#126587)
Chris Volzer7f8f346e5f38
diff --git a/products/mobile/docs/RELEASING.md b/products/mobile/docs/RELEASING.mdindex c69f1adc2615..141514e99825 100644--- a/products/mobile/docs/RELEASING.md+++ b/products/mobile/docs/RELEASING.md@@ -101,7 +101,11 @@ Rotate the key and certificate together, retain the old material securely for ol### Receipts, ordering and retriesThe workflow run and `mobile-production` deployment report its outcome. The `mobile-staging` deployment records the build/update staging outcome.-The GitHub prerelease `mobile-release/<id>` contains a machine-readable JSON receipt; the Actions run also retains a receipt artifact, including a claimed receipt if publishing fails.+The GitHub prerelease `mobile-release/<id>` shows the request's release notes, version, submission or update outcome, and links to its source and workflow.+Completed releases attach the full machine-readable receipt as `mobile-release-receipt.json`. The publisher uploads and downloads that file to verify its contents before publishing the Markdown description or advancing the production pointer.+Draft releases retain their claimed/staged JSON description for recovery, even if an interruption leaves a completed attachment on the draft.+Receipt lookup reads the attachment for completed releases and still accepts older JSON descriptions. An unreadable attachment stops publication rather than falling back to stale data.+The Actions run also retains a receipt artifact, including a claimed receipt if publishing fails.Receipt lookup includes draft releases across every page of the release list. GitHub's release-by-tag endpoint only returns published releases and cannot find an interrupted draft claim.Repeated entries across pages are deduplicated by numeric release ID, so only distinct releases can cause a duplicate-receipt error.Receipt writes use the numeric release ID returned when the claim is created and explicitly retain its request tag. If multiple releases share a request tag, publication stops before any EAS operation; reconcile every named release ID before retrying.diff --git a/products/mobile/scripts/releases/fixtures/hosted-cli.mjs b/products/mobile/scripts/releases/fixtures/hosted-cli.mjsindex 3fbcf8a9b4ed..eace6f007f77 100644--- a/products/mobile/scripts/releases/fixtures/hosted-cli.mjs+++ b/products/mobile/scripts/releases/fixtures/hosted-cli.mjs@@ -89,6 +89,25 @@ if (tool === 'eas') {if (args.includes('--draft=false')) {state.releases[tag].draft = false}+ } else if (operation === 'upload') {+ if (process.env.MOBILE_FAKE_FAIL === 'receipt-upload') {+ done()+ process.exit(1)+ }+ const file = args[2]+ state.releases[tag].assets ??= []+ const assets = state.releases[tag].assets+ if (assets.some(({ name }) => name === basename(file))) {+ throw new Error('Receipt asset already exists')+ }+ assets.push({ name: basename(file), content: readFileSync(file, 'utf8') })+ } else if (operation === 'download') {+ const asset = state.releases[tag].assets?.find(({ name }) => name === flag('--pattern'))+ if (!asset) {+ throw new Error('Receipt asset not found')+ }+ done(process.env.MOBILE_FAKE_FAIL === 'receipt-download' ? '{"state":"claimed"}' : asset.content)+ process.exit(0)} else {throw new Error(`Unexpected release operation ${operation}`)}@@ -129,6 +148,10 @@ if (tool === 'eas') {} else if (path === 'releases' && method === 'POST') {done(createRelease(data))} else if (path.startsWith('releases/') && method === 'PATCH') {+ if (data.draft === false && process.env.MOBILE_FAKE_FAIL === 'receipt-publish') {+ done()+ process.exit(1)+ }const release = releases().find(({ id }) => id === Number(path.split('/')[1]))if (!release) {throw new Error('Release ID not found')diff --git a/products/mobile/scripts/releases/hosted.test.mjs b/products/mobile/scripts/releases/hosted.test.mjsindex 174510c4fe52..b1ae686370af 100644--- a/products/mobile/scripts/releases/hosted.test.mjs+++ b/products/mobile/scripts/releases/hosted.test.mjs@@ -40,7 +40,7 @@ function fixture(t) {for (const path of [scripts, requests, bin]) {mkdirSync(path, { recursive: true })}- for (const name of ['release.mjs', 'policy.mjs']) {+ for (const name of ['release.mjs', 'policy.mjs', 'receipt.mjs']) {copyFileSync(join(scriptRoot, name), join(scripts, name))}copyFileSync(join(scriptRoot, '../eas-build.sh'), join(app, 'scripts/eas-build.sh'))@@ -165,7 +165,7 @@ function fixture(t) {}}-test('real CLI stages exact native builds, submits their IDs, then promotes an OTA group and deduplicates reruns', (t) => {+test('real CLI publishes readable notes and receipts, promotes an OTA from a legacy receipt and deduplicates reruns', (t) => {const f = fixture(t)f.addRequest('native-140', 'native', null)let outcome = f.invoke(['publish'])@@ -173,15 +173,42 @@ test('real CLI stages exact native builds, submits their IDs, then promotes an Olet state = f.state()assert.deepEqual(state.submissions, ['1'.repeat(36), '2'.repeat(36)])assert.equal(state.releases['mobile-release/native-140'].draft, false)- assert.equal(state.releases['mobile-release/native-140'].tag_name, 'mobile-release/native-140')- assert.equal(JSON.parse(state.releases['mobile-release/native-140'].body).state, 'complete')+ const native = state.releases['mobile-release/native-140']+ assert.equal(native.tag_name, 'mobile-release/native-140')+ const nativeReceipt = JSON.parse(native.assets[0].content)+ assert.equal(nativeReceipt.state, 'complete')+ assert.deepEqual(+ nativeReceipt.result.submittedBuilds.map(({ id }) => id),+ state.submissions+ )+ assert.match(native.body, /Invented test release\./)+ assert.match(native.body, /\| iOS \| TestFlight \| Completed \|/)+ assert.match(native.body, /\| Android \| Google Play internal testing \| Completed \|/)+ assert.match(native.body, /mobile-release%2Fnative-140\/mobile-release-receipt\.json/)+ assert.doesNotMatch(native.body, /certificateFingerprint|schemaVersion/)assert.deepEqual(state.deploymentStatuses, ['in_progress', 'success'])assert.ok(state.commands.filter(({ tool }) => tool === 'eas').every(({ args }) => !args.includes('--latest')))+ const nativeEffects = state.commands.filter(({ tool }) => tool === 'eas').length+ assert.equal(f.invoke(['publish']).status, 0)+ assert.equal(f.state().commands.filter(({ tool }) => tool === 'eas').length, nativeEffects)+ native.assets[0].content = 'invalid JSON'+ writeFileSync(f.stateFile, JSON.stringify(state))+ assert.notEqual(f.invoke(['publish']).status, 0)+ assert.equal(f.state().commands.filter(({ tool }) => tool === 'eas').length, nativeEffects)+ delete native.assets+ writeFileSync(f.stateFile, JSON.stringify(state))+ assert.notEqual(f.invoke(['publish']).status, 0)+ assert.equal(f.state().commands.filter(({ tool }) => tool === 'eas').length, nativeEffects)+ native.body = JSON.stringify(nativeReceipt)+ writeFileSync(f.stateFile, JSON.stringify(state))f.addRequest('chart-fix', 'ota', 'native-140')outcome = f.invoke(['publish'])assert.equal(outcome.status, 0, outcome.stderr)state = f.state()- const ota = JSON.parse(state.releases['mobile-release/chart-fix'].body)+ const otaRelease = state.releases['mobile-release/chart-fix']+ const ota = JSON.parse(otaRelease.assets[0].content)+ assert.match(otaRelease.body, /Published to the production channel for iOS and Android\./)+ assert.doesNotMatch(otaRelease.body, /Build submissions/)assert.equal(ota.staged.group, 'b'.repeat(36))assert.equal(ota.result.productionGroup, 'c'.repeat(36))assert.equal(ota.native.runtimeVersion, '1.4.0')@@ -199,6 +226,39 @@ test('real CLI stages exact native builds, submits their IDs, then promotes an Oassert.equal(f.state().commands.filter(({ tool }) => tool === 'eas').length, effectsBefore)})+test('receipt finalization failures retain the staged claim and never advance production or resubmit', async (t) => {+ for (const failure of ['receipt-upload', 'receipt-download', 'receipt-publish']) {+ await t.test(failure, (t) => {+ const f = fixture(t)+ f.addRequest('native-140', 'native', null)+ const failed = f.invoke(['publish'], { MOBILE_FAKE_FAIL: failure })+ assert.notEqual(failed.status, 0)+ const state = f.state()+ const release = state.releases['mobile-release/native-140']+ assert.equal(release.draft, true)+ const claim = JSON.parse(release.body)+ assert.equal(claim.state, 'claimed')+ assert.equal(claim.staged.builds.length, 2)+ if (failure === 'receipt-upload') {+ assert.equal(release.assets, undefined)+ } else {+ assert.equal(JSON.parse(release.assets[0].content).state, 'complete')+ }+ if (failure === 'receipt-download') {+ assert.match(failed.stderr, /Uploaded release receipt differs/)+ }+ assert.equal(state.pointer, null)+ assert.equal(state.submissions.length, 2)+ const effectsBefore = state.commands.filter(({ tool }) => tool === 'eas').length+ const retry = f.invoke(['publish'])+ assert.notEqual(retry.status, 0)+ assert.match(retry.stderr, /already claimed/)+ assert.equal(f.state().commands.filter(({ tool }) => tool === 'eas').length, effectsBefore)+ assert.equal(f.state().pointer, null)+ })+ }+})+test('lost submission response retains staged IDs and rerunning the workflow cannot duplicate submissions', (t) => {const f = fixture(t)f.addRequest('native-140', 'native', null)@@ -326,9 +386,10 @@ test('signing configuration and a matching private key are required before a rel}for (const fingerprint of [undefined, 'different-certificate']) {const state = f.state()- const receipt = JSON.parse(state.releases['mobile-release/native-140'].body)+ const asset = state.releases['mobile-release/native-140'].assets[0]+ const receipt = JSON.parse(asset.content)receipt.native.certificateFingerprint = fingerprint- state.releases['mobile-release/native-140'].body = JSON.stringify(receipt)+ asset.content = JSON.stringify(receipt)writeFileSync(f.stateFile, JSON.stringify(state))const outcome = f.invoke(['publish'])assert.notEqual(outcome.status, 0)diff --git a/products/mobile/scripts/releases/receipt.mjs b/products/mobile/scripts/releases/receipt.mjsnew file mode 100644index 000000000000..eb9f1463a6bf--- /dev/null+++ b/products/mobile/scripts/releases/receipt.mjs@@ -0,0 +1,25 @@+export const receiptAssetName = 'mobile-release-receipt.json'++export function renderReleaseNotes(receipt, repository) {+ const { request, result, commit, runUrl } = receipt+ const tag = encodeURIComponent(`mobile-release/${request.id}`)+ const lines = [request.notes.trim(), '', `**Version:** ${request.runtimeVersion} · **Status:** Pre-release`, '']+ if (request.kind === 'native') {+ lines.push('## Build submissions', '', '| Platform | Destination | Submission |', '| --- | --- | --- |')+ for (const build of result.submittedBuilds) {+ const platform = build.platform === 'ios' ? 'iOS' : 'Android'+ const destination = build.platform === 'ios' ? 'TestFlight' : 'Google Play internal testing'+ lines.push(`| ${platform} | ${destination} | Completed |`)+ }+ lines.push('', 'Store processing may still be pending before these builds become available to testers.', '')+ } else {+ lines.push('## Update', '', 'Published to the production channel for iOS and Android.', '')+ }+ lines.push(+ `[Source commit ${commit.slice(0, 7)}](https://github.com/${repository}/commit/${commit}) · [Release workflow](${runUrl})`,+ '',+ `[Release receipt (JSON)](https://github.com/${repository}/releases/download/${tag}/${receiptAssetName})`,+ ''+ )+ return lines.join('\n')+}diff --git a/products/mobile/scripts/releases/receipt.test.mjs b/products/mobile/scripts/releases/receipt.test.mjsnew file mode 100644index 000000000000..497da3f3be07--- /dev/null+++ b/products/mobile/scripts/releases/receipt.test.mjs@@ -0,0 +1,23 @@+import assert from 'node:assert/strict'+import test from 'node:test'+import { renderReleaseNotes } from './receipt.mjs'++test('release notes preserve authored Markdown and keep bookkeeping in the receipt attachment', () => {+ const notes = 'A chart update.\n\n### What to verify\n\n- Open a saved chart\n- Change its date range'+ const receipt = {+ request: { id: 'chart-update', kind: 'native', runtimeVersion: '2.0.0', notes },+ commit: 'a'.repeat(40),+ runUrl: 'https://example.com/release-run',+ result: { submittedBuilds: [{ platform: 'ios', id: 'invented-build-id' }] },+ recovery: { state: 'complete' },+ native: { certificateFingerprint: 'invented-certificate-fingerprint' },+ }+ const rendered = renderReleaseNotes(receipt, 'example/project')+ assert.ok(rendered.startsWith(`${notes}\n\n`))+ assert.match(rendered, /\*\*Version:\*\* 2\.0\.0/)+ assert.match(rendered, /Store processing may still be pending/)+ assert.match(rendered, /https:\/\/github\.com\/example\/project\/commit\/a{40}/)+ assert.match(rendered, /\[Release workflow\]\(https:\/\/example\.com\/release-run\)/)+ assert.match(rendered, /releases\/download\/mobile-release%2Fchart-update\/mobile-release-receipt\.json/)+ assert.doesNotMatch(rendered, /invented-build-id|certificateFingerprint|recovery/)+})diff --git a/products/mobile/scripts/releases/release.mjs b/products/mobile/scripts/releases/release.mjsindex 05cb6cd3803b..6590d5b8ff72 100644--- a/products/mobile/scripts/releases/release.mjs+++ b/products/mobile/scripts/releases/release.mjs@@ -4,7 +4,7 @@ import { appendFileSync, mkdirSync, readdirSync, readFileSync, writeFileSync } fimport { createRequire } from 'node:module'import { basename, dirname, join, resolve } from 'node:path'import { fileURLToPath } from 'node:url'-import { parseArgs } from 'node:util'+import { isDeepStrictEqual, parseArgs } from 'node:util'import {compareVersions,@@ -18,6 +18,7 @@ import {validateRequest,validateUpdates,} from './policy.mjs'+import { receiptAssetName, renderReleaseNotes } from './receipt.mjs'const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../..')const repoRoot = resolve(appRoot, '../..')@@ -296,6 +297,22 @@ function releaseTag(id) {return `mobile-release/${id}`}+function downloadReceipt(id) {+ return JSON.parse(+ run('gh', [+ 'release',+ 'download',+ releaseTag(id),+ '--repo',+ repo,+ '--pattern',+ receiptAssetName,+ '--output',+ '-',+ ])+ )+}+function releaseReceipt(id) {if (!releaseInventory) {const inventory = []@@ -315,7 +332,11 @@ function releaseReceipt(id) {)}const [release] = matches- return release ? { release, receipt: JSON.parse(release.body) } : null+ if (!release) {+ return null+ }+ const attached = !release.draft && release.assets?.some(({ name }) => name === receiptAssetName)+ return { release, receipt: attached ? downloadReceipt(id) : JSON.parse(release.body) }}function productionState() {@@ -362,7 +383,7 @@ function advancePointer(receipt) {}function saveReceipt(receipt) {- const output = join(process.env.RUNNER_TEMP, 'mobile-release-receipt.json')+ const output = join(process.env.RUNNER_TEMP, receiptAssetName)writeFileSync(output, `${JSON.stringify(receipt, null, 2)}\n`)return output}@@ -582,14 +603,18 @@ async function publish() {request.kind === 'native'? { commit, runtimeVersion: request.runtimeVersion, fingerprints, certificateFingerprint }: previous.native- saveReceipt(receipt)+ const receiptPath = saveReceipt(receipt)+ run('gh', ['release', 'upload', releaseTag(request.id), receiptPath, '--repo', repo])+ if (!isDeepStrictEqual(downloadReceipt(request.id), receipt)) {+ throw new Error('Uploaded release receipt differs; reconcile the draft before retrying')+ }api(`releases/${releaseId}`,{tag_name: releaseTag(request.id),draft: false,prerelease: true,- body: JSON.stringify(receipt, null, 2),+ body: renderReleaseNotes(receipt, repo),},'PATCH')