gowalk-cicd 1.0.182 → 1.0.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1240,6 +1240,71 @@ different bytes under the same number. Build numbers come from `/builds`,
|
|
|
1240
1240
|
`/preReleaseVersions` **and** `/apps/{id}/buildUploads`, so an unfinished or refused
|
|
1241
1241
|
reservation is never reused; delete such a reservation only after reading it back.
|
|
1242
1242
|
|
|
1243
|
+
When an iOS producer was cancelled **after** both `Build and transfer iOS binary` and
|
|
1244
|
+
`Retain Apple verification handoff` succeeded, version 1.0.183 provides explicit recovery:
|
|
1245
|
+
|
|
1246
|
+
```bash
|
|
1247
|
+
node .github/actions/swift-app/scripts/apple_upload_recovery.cjs \
|
|
1248
|
+
ORIGINAL_RUN_ID ORIGINAL_ATTEMPT DEPLOYMENT_ID HANDOFF_ARTIFACT_ID \
|
|
1249
|
+
> "$RUNNER_TEMP/apple-upload-recovery.json"
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
Run this released helper in an authorized `workflow_dispatch` Actions job on the same
|
|
1253
|
+
repository's default branch, after checking out the adopted tooling. The job needs
|
|
1254
|
+
`actions: read`, `contents: read`, `deployments: write`, `GITHUB_TOKEN: ${{ github.token }}`
|
|
1255
|
+
and the existing `ASC_KEY_P8`, `ASC_KEY_ID`, `ASC_ISSUER_ID` secrets (or the prepared ASC key
|
|
1256
|
+
path). Serialize the recovery workflow with normal Mobile Deploy using its exact concurrency
|
|
1257
|
+
group and `cancel-in-progress: false`; this prevents a deploy from starting between the
|
|
1258
|
+
last provenance read and the receipt write. Use this workflow policy and job environment:
|
|
1259
|
+
|
|
1260
|
+
```yaml
|
|
1261
|
+
on: workflow_dispatch
|
|
1262
|
+
permissions:
|
|
1263
|
+
contents: read
|
|
1264
|
+
actions: read
|
|
1265
|
+
deployments: write
|
|
1266
|
+
concurrency:
|
|
1267
|
+
group: mobile-deploy-${{ github.ref }}
|
|
1268
|
+
cancel-in-progress: false
|
|
1269
|
+
jobs:
|
|
1270
|
+
recover:
|
|
1271
|
+
if: ${{ github.ref_name == github.event.repository.default_branch }}
|
|
1272
|
+
runs-on: ubuntu-24.04
|
|
1273
|
+
timeout-minutes: 20
|
|
1274
|
+
env:
|
|
1275
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
1276
|
+
ASC_KEY_P8: ${{ secrets.ASC_KEY_P8 }}
|
|
1277
|
+
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
|
|
1278
|
+
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
|
|
1279
|
+
steps:
|
|
1280
|
+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
|
|
1281
|
+
# Invoke the command above with the four verified original identifiers,
|
|
1282
|
+
# then retain its JSON with the pinned, guarded artifact uploader.
|
|
1283
|
+
```
|
|
1284
|
+
|
|
1285
|
+
Retain `apple-upload-recovery.json` with the existing pinned, guarded artifact uploader.
|
|
1286
|
+
The command has no local receipt or caller-provided
|
|
1287
|
+
digest option: it downloads the exact original artifact, verifies GitHub's archive SHA-256,
|
|
1288
|
+
and accepts only its bounded `apple-verification.json` member. It authenticates the current
|
|
1289
|
+
dispatch separately from the original run, attempt, source, repository, branch and deployment.
|
|
1290
|
+
|
|
1291
|
+
Recovery requires a terminal cancelled original run and iOS producer with those two
|
|
1292
|
+
successful steps in order. A later completed attempt may exist; an active latest attempt
|
|
1293
|
+
refuses, including a retry observed immediately before writing the receipt. Fresh Apple
|
|
1294
|
+
readback must prove the exact completed upload and file, matching bytes, eligible `VALID`
|
|
1295
|
+
build and matching app. Only then can the original deployment become `uploaded`; repeating
|
|
1296
|
+
recovery verifies the same evidence without another write. No binary is rebuilt or uploaded,
|
|
1297
|
+
and the old handoff's metadata and release notes are never replayed. Missing, expired or
|
|
1298
|
+
mismatched evidence remains refused; do not relabel a receipt or impersonate the original
|
|
1299
|
+
`GITHUB_*` environment. Normal delivery still refuses cancelled producers.
|
|
1300
|
+
|
|
1301
|
+
Retain the recovery proof, then rerun the **whole original deployment workflow**. Its
|
|
1302
|
+
upload-once admission reuses the confirmed iOS receipt and skips the iOS binary. Follow that
|
|
1303
|
+
new attempt and any unrelated remaining jobs to completion; recovery does not change the
|
|
1304
|
+
original cancelled attempt's conclusion. Read current store state for remaining submission
|
|
1305
|
+
work without changing an already accepted submission. This exceptional command adds no
|
|
1306
|
+
normal delivery job, polling or latency.
|
|
1307
|
+
|
|
1243
1308
|
Flutter SDK setup retries interrupted manifest and archive GETs, with four attempts
|
|
1244
1309
|
within 60 seconds for manifests or 30 minutes for archives, with an 8 GiB archive bound. Retries resume private bytes
|
|
1245
1310
|
with HTTP Range; if the origin ignores Range, a bounded full restart is permitted. The completed archive
|
|
@@ -9,22 +9,12 @@ const positive = value => Number.isSafeInteger(value) && value > 0;
|
|
|
9
9
|
const id = value => typeof value === 'string' && /^[A-Za-z0-9-]{1,64}$/.test(value);
|
|
10
10
|
const fail = code => { throw Error(`apple_upload_verify_${code}`); };
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (bytes.length > 2 * 1024 * 1024 || !/^[a-f0-9]{64}$/.test(digest || '') ||
|
|
16
|
-
createHash('sha256').update(bytes).digest('hex') !== digest) fail('handoff_digest');
|
|
17
|
-
const value = JSON.parse(bytes), owner = value.owner || {}, r = value.receipt || {}, m = value.metadata || {};
|
|
18
|
-
const event = JSON.parse(fs.readFileSync(env.GITHUB_EVENT_PATH, 'utf8'));
|
|
19
|
-
if (value.schema !== SCHEMA || owner.repository !== env.GITHUB_REPOSITORY ||
|
|
12
|
+
function validate(value) {
|
|
13
|
+
const owner = value?.owner || {}, r = value?.receipt || {}, m = value?.metadata || {};
|
|
14
|
+
if (value?.schema !== SCHEMA ||
|
|
20
15
|
!/^[\w.-]+\/[\w.-]+$/.test(owner.repository || '') || !/^[a-f0-9]{40}$/.test(owner.source_sha || '') ||
|
|
21
|
-
|
|
22
|
-
owner.
|
|
23
|
-
!['push', 'workflow_dispatch'].includes(owner.event) || owner.event !== env.GITHUB_EVENT_NAME ||
|
|
24
|
-
!positive(owner.run_id) || owner.run_id !== Number(env.GITHUB_RUN_ID) || !positive(owner.run_attempt) ||
|
|
25
|
-
!positive(attempt) || !positive(Number(env.GITHUB_RUN_ATTEMPT)) ||
|
|
26
|
-
owner.run_attempt !== attempt || attempt > Number(env.GITHUB_RUN_ATTEMPT) ||
|
|
27
|
-
!positive(owner.deployment_id) || owner.deployment_id !== Number(env.MOBILE_RELEASE_DEPLOYMENT_ID)) {
|
|
16
|
+
!owner.ref?.startsWith('refs/heads/') || !['push', 'workflow_dispatch'].includes(owner.event) ||
|
|
17
|
+
!positive(owner.run_id) || !positive(owner.run_attempt) || !positive(owner.deployment_id)) {
|
|
28
18
|
fail('handoff_owner');
|
|
29
19
|
}
|
|
30
20
|
if (r.schema !== 'gowalk-cicd/apple-build-upload-receipt.v1' || r.stage !== 'transferred' ||
|
|
@@ -40,6 +30,22 @@ function read(path, digest, attempt, env = process.env) {
|
|
|
40
30
|
return value;
|
|
41
31
|
}
|
|
42
32
|
|
|
33
|
+
function read(path, digest, attempt, env = process.env) {
|
|
34
|
+
if (fs.statSync(path).size > 2 * 1024 * 1024) fail('handoff_size');
|
|
35
|
+
const bytes = fs.readFileSync(path);
|
|
36
|
+
if (bytes.length > 2 * 1024 * 1024 || !/^[a-f0-9]{64}$/.test(digest || '') ||
|
|
37
|
+
createHash('sha256').update(bytes).digest('hex') !== digest) fail('handoff_digest');
|
|
38
|
+
const value = validate(JSON.parse(bytes)), owner = value.owner;
|
|
39
|
+
const event = JSON.parse(fs.readFileSync(env.GITHUB_EVENT_PATH, 'utf8'));
|
|
40
|
+
if (owner.repository !== env.GITHUB_REPOSITORY || owner.source_sha !== env.GITHUB_SHA ||
|
|
41
|
+
owner.ref !== env.GITHUB_REF || owner.ref !== `refs/heads/${event.repository?.default_branch}` ||
|
|
42
|
+
owner.event !== env.GITHUB_EVENT_NAME || owner.run_id !== Number(env.GITHUB_RUN_ID) ||
|
|
43
|
+
!positive(attempt) || !positive(Number(env.GITHUB_RUN_ATTEMPT)) ||
|
|
44
|
+
owner.run_attempt !== attempt || attempt > Number(env.GITHUB_RUN_ATTEMPT) ||
|
|
45
|
+
owner.deployment_id !== Number(env.MOBILE_RELEASE_DEPLOYMENT_ID)) fail('handoff_owner');
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
function transferred(job) {
|
|
44
50
|
if (!Array.isArray(job.steps)) return false;
|
|
45
51
|
const selected = ['Build and transfer iOS binary', 'Retain Apple verification handoff'].map(name =>
|
|
@@ -49,7 +55,7 @@ function transferred(job) {
|
|
|
49
55
|
return selected[0][0].number < selected[1][0].number;
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
async function verifyProducer(value, artifactId, api = github) {
|
|
58
|
+
async function verifyProducer(value, artifactId, api = github, recoverCancelled = false) {
|
|
53
59
|
if (!positive(artifactId)) fail('artifact_identity');
|
|
54
60
|
const o = value.owner;
|
|
55
61
|
const run = await api.request('GET', `/actions/runs/${o.run_id}/attempts/${o.run_attempt}`);
|
|
@@ -57,12 +63,21 @@ async function verifyProducer(value, artifactId, api = github) {
|
|
|
57
63
|
run.path !== '.github/workflows/deploy.yml' || run.event !== o.event ||
|
|
58
64
|
`refs/heads/${run.head_branch}` !== o.ref || run.repository?.full_name !== o.repository ||
|
|
59
65
|
run.head_repository?.full_name !== o.repository) fail('producer_run');
|
|
66
|
+
if (recoverCancelled) {
|
|
67
|
+
const latest = await api.request('GET', `/actions/runs/${o.run_id}`);
|
|
68
|
+
if (run.status !== 'completed' || run.conclusion !== 'cancelled' || latest.id !== o.run_id ||
|
|
69
|
+
latest.status !== 'completed' || !positive(latest.run_attempt) || latest.run_attempt < o.run_attempt ||
|
|
70
|
+
latest.head_sha !== o.source_sha || latest.path !== run.path || latest.event !== o.event ||
|
|
71
|
+
latest.head_branch !== run.head_branch || latest.repository?.full_name !== o.repository ||
|
|
72
|
+
latest.head_repository?.full_name !== o.repository) fail('cancelled_producer_run');
|
|
73
|
+
}
|
|
60
74
|
const result = await api.request('GET', `/actions/runs/${o.run_id}/attempts/${o.run_attempt}/jobs?per_page=100`);
|
|
61
75
|
if (!Array.isArray(result.jobs) || result.jobs.length >= 100) fail('producer_jobs');
|
|
62
76
|
const jobs = result.jobs.filter(job => job.name === 'iOS TestFlight' || job.name?.endsWith('/ iOS TestFlight'));
|
|
63
77
|
// A later symbol-retention failure does not undo these exact completed steps.
|
|
64
78
|
// The producer's original failure remains red; only Apple delivery is reconciled here.
|
|
65
|
-
|
|
79
|
+
const conclusions = recoverCancelled ? ['cancelled'] : ['success', 'failure'];
|
|
80
|
+
if (jobs.length !== 1 || jobs[0].status !== 'completed' || !conclusions.includes(jobs[0].conclusion) ||
|
|
66
81
|
jobs[0].head_sha !== o.source_sha || !transferred(jobs[0])) fail('producer_job');
|
|
67
82
|
const artifact = await api.request('GET', `/actions/artifacts/${artifactId}`);
|
|
68
83
|
if (artifact.id !== artifactId || artifact.expired !== false || artifact.workflow_run?.id !== o.run_id ||
|
|
@@ -100,4 +115,4 @@ function metadata(value, env = process.env) {
|
|
|
100
115
|
}
|
|
101
116
|
}
|
|
102
117
|
|
|
103
|
-
module.exports = {read, verifyProducer, phase, metadata, fail};
|
|
118
|
+
module.exports = {read, validate, verifyProducer, phase, metadata, fail};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* Explicit Actions recovery of a cancelled producer's authenticated handoff; never upload or metadata. */
|
|
2
|
+
'use strict';
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const {createHash} = require('node:crypto');
|
|
5
|
+
const {inflateRawSync} = require('node:zlib');
|
|
6
|
+
const github = require('./mobile_release_api.cjs');
|
|
7
|
+
const handoff = require('./apple_upload_handoff.cjs');
|
|
8
|
+
const verifier = require('./apple_upload_verify.cjs');
|
|
9
|
+
const LIMIT = 2 * 1024 * 1024;
|
|
10
|
+
const positive = value => Number.isSafeInteger(value) && value > 0;
|
|
11
|
+
const fail = code => handoff.fail(`recovery_${code}`);
|
|
12
|
+
|
|
13
|
+
// This archive contains one fixed JSON member. Parse in memory; never extract paths or trust a local receipt.
|
|
14
|
+
function unpack(bytes) {
|
|
15
|
+
try {
|
|
16
|
+
if (bytes.length > LIMIT) fail('artifact_size');
|
|
17
|
+
const end = bytes.lastIndexOf(Buffer.from('504b0506', 'hex'));
|
|
18
|
+
if (end < 0 || end + 22 + bytes.readUInt16LE(end + 20) !== bytes.length ||
|
|
19
|
+
bytes.readUInt16LE(end + 4) !== 0 || bytes.readUInt16LE(end + 6) !== 0 ||
|
|
20
|
+
bytes.readUInt16LE(end + 8) !== 1 || bytes.readUInt16LE(end + 10) !== 1) fail('archive_invalid');
|
|
21
|
+
const at = bytes.readUInt32LE(end + 16), directorySize = bytes.readUInt32LE(end + 12);
|
|
22
|
+
if (at + directorySize !== end || bytes.readUInt32LE(at) !== 0x02014b50) fail('archive_invalid');
|
|
23
|
+
const flags = bytes.readUInt16LE(at + 8), method = bytes.readUInt16LE(at + 10);
|
|
24
|
+
const packed = bytes.readUInt32LE(at + 20), size = bytes.readUInt32LE(at + 24);
|
|
25
|
+
const length = bytes.readUInt16LE(at + 28), name = bytes.subarray(at + 46, at + 46 + length);
|
|
26
|
+
const mode = (bytes.readUInt32LE(at + 38) >>> 16) & 0xf000;
|
|
27
|
+
if (name.toString('utf8') !== 'apple-verification.json' || flags & 1 || ![0, 8].includes(method) ||
|
|
28
|
+
![0, 0x8000].includes(mode) || size > LIMIT || packed > LIMIT ||
|
|
29
|
+
46 + length + bytes.readUInt16LE(at + 30) + bytes.readUInt16LE(at + 32) !== directorySize ||
|
|
30
|
+
bytes.readUInt16LE(at + 34) !== 0 || bytes.readUInt32LE(at + 42) !== 0 ||
|
|
31
|
+
bytes.readUInt32LE(0) !== 0x04034b50 || bytes.readUInt16LE(6) !== flags ||
|
|
32
|
+
bytes.readUInt16LE(8) !== method) fail('archive_invalid');
|
|
33
|
+
const localLength = bytes.readUInt16LE(26), start = 30 + localLength + bytes.readUInt16LE(28);
|
|
34
|
+
if (!bytes.subarray(30, 30 + localLength).equals(name) || start + packed > at) fail('archive_invalid');
|
|
35
|
+
const compressed = bytes.subarray(start, start + packed);
|
|
36
|
+
const content = method ? inflateRawSync(compressed, {maxOutputLength: LIMIT}) : compressed;
|
|
37
|
+
if (content.length !== size || content.length > LIMIT) fail('archive_invalid');
|
|
38
|
+
return content;
|
|
39
|
+
} catch { fail('archive_invalid'); }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function download(artifact, env = process.env, fetcher = fetch) {
|
|
43
|
+
if (!positive(artifact?.id) || !/^sha256:[a-f0-9]{64}$/.test(artifact.digest || '') ||
|
|
44
|
+
!positive(artifact.size_in_bytes) || artifact.size_in_bytes > LIMIT ||
|
|
45
|
+
!/^[\w.-]+\/[\w.-]+$/.test(env.GITHUB_REPOSITORY || '')) fail('artifact_invalid');
|
|
46
|
+
const signal = AbortSignal.timeout(30000);
|
|
47
|
+
const response = await fetcher(`https://api.github.com/repos/${env.GITHUB_REPOSITORY}/actions/artifacts/${artifact.id}/zip`,
|
|
48
|
+
{redirect: 'manual', signal, headers: {Authorization: `Bearer ${env.GITHUB_TOKEN || ''}`,
|
|
49
|
+
'User-Agent': 'gowalk-cicd', Accept: 'application/vnd.github+json'}});
|
|
50
|
+
const url = new URL(response.headers.get('location') || 'https://invalid.invalid');
|
|
51
|
+
if (response.status !== 302 || url.protocol !== 'https:' || url.username || url.password ||
|
|
52
|
+
url.port || url.hash || !/(?:\.blob\.core\.windows\.net|\.githubusercontent\.com)$/.test(url.hostname)) {
|
|
53
|
+
fail('artifact_unavailable');
|
|
54
|
+
}
|
|
55
|
+
// The signed storage URL receives no repository credential, and cannot redirect again.
|
|
56
|
+
const body = await fetcher(url, {redirect: 'error', signal});
|
|
57
|
+
if (!body.ok || !body.body) fail('artifact_unavailable');
|
|
58
|
+
const chunks = [];
|
|
59
|
+
let size = 0;
|
|
60
|
+
for await (const chunk of body.body) {
|
|
61
|
+
size += chunk.length;
|
|
62
|
+
if (size > LIMIT || size > artifact.size_in_bytes) fail('artifact_size');
|
|
63
|
+
chunks.push(chunk);
|
|
64
|
+
}
|
|
65
|
+
const bytes = Buffer.concat(chunks);
|
|
66
|
+
if (bytes.length !== artifact.size_in_bytes ||
|
|
67
|
+
`sha256:${createHash('sha256').update(bytes).digest('hex')}` !== artifact.digest) fail('artifact_digest');
|
|
68
|
+
return unpack(bytes);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function current(env, api) {
|
|
72
|
+
const runId = Number(env.GITHUB_RUN_ID), attempt = Number(env.GITHUB_RUN_ATTEMPT);
|
|
73
|
+
const event = JSON.parse(fs.readFileSync(env.GITHUB_EVENT_PATH, 'utf8'));
|
|
74
|
+
const repository = env.GITHUB_REPOSITORY, branch = event.repository?.default_branch;
|
|
75
|
+
if (env.GITHUB_ACTIONS !== 'true' || env.GITHUB_EVENT_NAME !== 'workflow_dispatch' ||
|
|
76
|
+
!/^[\w.-]+\/[\w.-]+$/.test(repository || '') || !positive(runId) || !positive(attempt) ||
|
|
77
|
+
!branch || env.GITHUB_REF !== `refs/heads/${branch}` || !/^[a-f0-9]{40}$/.test(env.GITHUB_SHA || '')) {
|
|
78
|
+
fail('caller_invalid');
|
|
79
|
+
}
|
|
80
|
+
const run = await api.request('GET', `/actions/runs/${runId}/attempts/${attempt}`);
|
|
81
|
+
if (run.id !== runId || run.run_attempt !== attempt || run.status !== 'in_progress' ||
|
|
82
|
+
run.event !== 'workflow_dispatch' || run.head_branch !== branch || run.head_sha !== env.GITHUB_SHA ||
|
|
83
|
+
run.repository?.full_name !== repository || run.head_repository?.full_name !== repository ||
|
|
84
|
+
!/^\.github\/workflows\/[\w.-]+\.ya?ml$/.test(run.path || '') ||
|
|
85
|
+
env.GITHUB_WORKFLOW_REF !== `${repository}/${run.path}@${env.GITHUB_REF}`) fail('caller_unverified');
|
|
86
|
+
return {run_id: runId, run_attempt: attempt, repository, ref: env.GITHUB_REF};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function recover({runId, attempt, deploymentId, artifactId}, dependencies = {}) {
|
|
90
|
+
if (![runId, attempt, deploymentId, artifactId].every(positive)) fail('arguments');
|
|
91
|
+
const env = dependencies.env || process.env, api = dependencies.api || github;
|
|
92
|
+
const caller = await current(env, api);
|
|
93
|
+
if (runId === caller.run_id) fail('caller_invalid');
|
|
94
|
+
const artifact = await api.request('GET', `/actions/artifacts/${artifactId}`);
|
|
95
|
+
if (artifact.id !== artifactId || artifact.expired !== false || artifact.workflow_run?.id !== runId ||
|
|
96
|
+
artifact.name !== `apple-verification-${runId}-${attempt}`) fail('artifact_identity');
|
|
97
|
+
const bytes = await download(artifact, env, dependencies.fetch || fetch);
|
|
98
|
+
let parsed;
|
|
99
|
+
try { parsed = JSON.parse(bytes.toString('utf8')); } catch { fail('handoff_invalid'); }
|
|
100
|
+
const value = handoff.validate(parsed), owner = value.owner;
|
|
101
|
+
if (owner.repository !== caller.repository || owner.ref !== caller.ref || owner.run_id !== runId ||
|
|
102
|
+
owner.run_attempt !== attempt || owner.deployment_id !== deploymentId ||
|
|
103
|
+
owner.source_sha !== artifact.workflow_run?.head_sha) fail('handoff_owner');
|
|
104
|
+
const result = await verifier.verify(value, artifactId, 900, {...dependencies, api, recoverCancelled: true});
|
|
105
|
+
return {...result, schema: 'gowalk-cicd/apple-upload-recovered.v1', producer_run: runId,
|
|
106
|
+
repository: owner.repository, producer_source_sha: owner.source_sha,
|
|
107
|
+
producer_ref: owner.ref, producer_event: owner.event,
|
|
108
|
+
artifact_id: artifactId, artifact_digest: artifact.digest,
|
|
109
|
+
handoff_sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
110
|
+
ipa_sha256: value.receipt.sha256, file_id: value.receipt.file_id,
|
|
111
|
+
recovery_run: caller.run_id, recovery_attempt: caller.run_attempt};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function main() {
|
|
115
|
+
if (process.argv.length !== 6) fail('arguments');
|
|
116
|
+
const [runId, attempt, deploymentId, artifactId] = process.argv.slice(2).map(Number);
|
|
117
|
+
console.log(JSON.stringify(await recover({runId, attempt, deploymentId, artifactId})));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (require.main === module) main().catch(error => {
|
|
121
|
+
const code = /^(apple_upload_verify|apple_upload_reconcile|mobile_release)_[a-z0-9_]+$/.test(error?.message || '') ?
|
|
122
|
+
error.message : 'apple_upload_verify_recovery_unavailable';
|
|
123
|
+
console.error('::error title=apple_upload_recovery_refused::' + JSON.stringify({code}));
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
});
|
|
126
|
+
module.exports = {unpack, download, current, recover};
|
|
@@ -42,7 +42,7 @@ async function verify(value, artifactId, timeout, dependencies = {}) {
|
|
|
42
42
|
const sleep = dependencies.sleep || delay, started = now(), deadline = started + timeout * 1000;
|
|
43
43
|
const key = dependencies.get ? null : credential();
|
|
44
44
|
const get = dependencies.get || (path => apple.appleGet(path, key, Math.max(1, Math.min(30000, deadline - now()))));
|
|
45
|
-
await handoff.verifyProducer(value, artifactId, api);
|
|
45
|
+
await handoff.verifyProducer(value, artifactId, api, dependencies.recoverCancelled === true);
|
|
46
46
|
await handoff.phase(value, api);
|
|
47
47
|
let proof;
|
|
48
48
|
do {
|
|
@@ -52,6 +52,8 @@ async function verify(value, artifactId, timeout, dependencies = {}) {
|
|
|
52
52
|
await sleep(Math.min(10000, deadline - now()));
|
|
53
53
|
} while (now() < deadline);
|
|
54
54
|
if (!proof) handoff.fail('processing_pending');
|
|
55
|
+
// Explicit historical recovery rechecks its terminal producer before the only write.
|
|
56
|
+
if (dependencies.recoverCancelled === true) await handoff.verifyProducer(value, artifactId, api, true);
|
|
55
57
|
const prior = await handoff.phase(value, api);
|
|
56
58
|
if (prior === 'uploading') await api.status(value.owner.deployment_id, 'uploaded', 'success');
|
|
57
59
|
if (await handoff.phase(value, api) !== 'uploaded') handoff.fail('write_unconfirmed');
|
package/package.json
CHANGED
package/remedies.json
CHANGED
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
"fixed_in": "1.0.132",
|
|
24
24
|
"remedy": "Read the original run, attempt and deployment receipt before retrying. A completed uploaded receipt is reused with its original evidence; finish its metadata and submission work. An uploading receipt is ambiguous even when a later owner refusal reports no provider attempt. Adopt the 1.0.132 action and workflow together to place future Android intent writes inside acquired Play ownership. For an existing receipt, prove the exact provider build/version or use supported retained-binary recovery; never relabel it building by hand or clear ownership on elapsed time."
|
|
25
25
|
},
|
|
26
|
+
{
|
|
27
|
+
"schema": "gowalk-cicd/mobile-release-refused.v1",
|
|
28
|
+
"code": "mobile_release_upload_unconfirmed_read_back_retained_binary_before_retry",
|
|
29
|
+
"fixed_in": "1.0.183",
|
|
30
|
+
"remedy": "Preserve the original upload owner and artifacts. If an iOS producer was cancelled after both Build and transfer iOS binary and Retain Apple verification handoff succeeded, use apple_upload_recovery.cjs RUN ATTEMPT DEPLOYMENT ARTIFACT from an authorized default-branch workflow_dispatch Actions job. It downloads and authenticates the original artifact, proves the terminal original and latest run, and reads fresh Apple upload/file/build/app evidence before reconciling that deployment. It never rebuilds, uploads or replays metadata. Retain its recovery proof, then rerun the whole original deployment workflow: admission reuses the uploaded receipt without another iOS binary. The old cancellation remains historical evidence; follow the new attempt to completion. Missing or mismatched evidence still refuses."
|
|
31
|
+
},
|
|
26
32
|
{
|
|
27
33
|
"schema": "gowalk-cicd/mobile-release-refused.v1",
|
|
28
34
|
"code": "mobile_release_http_500",
|