@adea-ai/app-framework 0.24.0 → 0.25.0
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 +49 -1
- package/dist/cli/macos-signing-cli.d.ts +2 -0
- package/dist/cli/macos-signing-cli.js +14 -0
- package/dist/desktop/channel-proof.js +7 -1
- package/dist/framework-source.json +1 -1
- package/dist/release/framework-package-publish.js +4 -2
- package/dist/release/local-release.d.ts +2 -0
- package/dist/release/local-release.js +25 -2
- package/dist/release/macos-signing.d.ts +27 -0
- package/dist/release/macos-signing.js +101 -0
- package/dist/shell/app-shell.js +21 -33
- package/dist/shell/navigation-drawer.d.ts +12 -0
- package/dist/shell/navigation-drawer.js +42 -0
- package/dist/updates/release-feed.d.ts +2 -0
- package/dist/updates/release-feed.js +11 -2
- package/package.json +16 -4
- package/src/shell/app-shell.tsx +29 -20
- package/src/shell/navigation-drawer.tsx +36 -0
- package/src/app/create-application.ts +0 -245
- package/src/app/service-registry.ts +0 -124
- package/src/ci/toolchain-identity.ts +0 -244
- package/src/cli/cef-helper-cli.ts +0 -21
- package/src/cli/cli-runner.ts +0 -29
- package/src/cli/create-application-cli.ts +0 -62
- package/src/cli/electrobun-shortcut-patch-cli.ts +0 -24
- package/src/cli/framework-update-cli.ts +0 -41
- package/src/cli/release-assets-plan-cli.ts +0 -14
- package/src/cli/release-cut-cli.ts +0 -41
- package/src/cli/release-descriptor-staging-cli.ts +0 -57
- package/src/cli/release-finalize-cli.ts +0 -34
- package/src/cli/release-promote-cli.ts +0 -31
- package/src/cli/release-publish-cli.ts +0 -46
- package/src/cli/release-sign-cli.ts +0 -24
- package/src/cli/release-step-cli.ts +0 -71
- package/src/cli/toolchain-identity-cli.ts +0 -12
- package/src/cli/update-helper-cli.ts +0 -12
- package/src/cli/windows-runtime-patch-cli.ts +0 -17
- package/src/desktop/application-command-client.ts +0 -43
- package/src/desktop/channel-handshake.ts +0 -136
- package/src/desktop/channel-proof.ts +0 -122
- package/src/desktop/desktop-client.ts +0 -303
- package/src/desktop/desktop-gateway.ts +0 -189
- package/src/desktop/desktop-host.ts +0 -335
- package/src/desktop/desktop-stream.ts +0 -324
- package/src/desktop/loopback-policy.ts +0 -41
- package/src/desktop/open-url-channel.ts +0 -79
- package/src/desktop/string-policy.ts +0 -9
- package/src/installer/archive-entry.ts +0 -32
- package/src/installer/command-artifact.ts +0 -307
- package/src/installer/command-qualification-command.ts +0 -75
- package/src/installer/hosted-runner.ts +0 -11
- package/src/installer/installed-payload.ts +0 -408
- package/src/installer/installer-ci-bootstrap.ts +0 -199
- package/src/installer/installer-ci-preflight.ts +0 -61
- package/src/installer/installer-ci-worker.ts +0 -105
- package/src/installer/installer-extraction.ts +0 -367
- package/src/installer/installer-fetch-guard.ts +0 -75
- package/src/installer/installer-identity.ts +0 -331
- package/src/installer/installer-layout.ts +0 -167
- package/src/installer/installer-observation.ts +0 -671
- package/src/installer/installer-process-cleanup.ts +0 -167
- package/src/installer/installer-qualification-command.ts +0 -81
- package/src/installer/installer-renderer-evidence.ts +0 -268
- package/src/installer/installer-upgrade-command.ts +0 -226
- package/src/installer/installer-worker-guard.ts +0 -112
- package/src/installer/native-executable.ts +0 -37
- package/src/installer/upgrade-asset-download.ts +0 -72
- package/src/installer/write-all.ts +0 -19
- package/src/native/app-bundle.ts +0 -86
- package/src/native/cef-helper.ts +0 -471
- package/src/native/desktop-build-hook.ts +0 -21
- package/src/native/electrobun-source-patch.ts +0 -107
- package/src/native/linux-cef-links.ts +0 -14
- package/src/native/native-secret-store.ts +0 -99
- package/src/native/native-utilities.ts +0 -166
- package/src/native/partitioned-window.ts +0 -62
- package/src/native/secure-window.ts +0 -115
- package/src/native/sidecar-services.ts +0 -71
- package/src/native/sidecar.ts +0 -387
- package/src/native/window-bootstrap.ts +0 -77
- package/src/native/windows-build-hook-internal.ts +0 -49
- package/src/native/windows-build-hook.ts +0 -12
- package/src/native/windows-runtime-patch-internal.ts +0 -48
- package/src/native/windows-runtime-patch.ts +0 -15
- package/src/release/feed-release-cut.ts +0 -110
- package/src/release/feed-state.ts +0 -135
- package/src/release/framework-package-publish.ts +0 -163
- package/src/release/framework-update.ts +0 -196
- package/src/release/github-cli.ts +0 -27
- package/src/release/github-release-assets.ts +0 -36
- package/src/release/github-release-cut.ts +0 -237
- package/src/release/github-release-lookup.ts +0 -39
- package/src/release/github-release-promotion.ts +0 -112
- package/src/release/github-release-provenance.ts +0 -65
- package/src/release/github-release-publisher.ts +0 -90
- package/src/release/github-release-qualification.ts +0 -144
- package/src/release/local-provenance.ts +0 -92
- package/src/release/local-release.ts +0 -525
- package/src/release/macos-dmg.ts +0 -113
- package/src/release/release-artifact.ts +0 -53
- package/src/release/release-assets-plan.ts +0 -118
- package/src/release/release-config.ts +0 -420
- package/src/release/release-cut-command.ts +0 -80
- package/src/release/release-cut.ts +0 -133
- package/src/release/release-descriptor-staging.ts +0 -242
- package/src/release/release-finalize.ts +0 -191
- package/src/release/release-promotion-command.ts +0 -36
- package/src/release/release-promotion.ts +0 -132
- package/src/release/release-publication.ts +0 -213
- package/src/release/release-publish-command.ts +0 -163
- package/src/release/release-qualification.ts +0 -397
- package/src/release/release-staging.ts +0 -87
- package/src/release/release-steps.ts +0 -173
- package/src/release/retained-release-build.ts +0 -217
- package/src/shell/application-menu-commands.ts +0 -6
- package/src/shell/application-menu.ts +0 -250
- package/src/updates/channel-update-manager.ts +0 -127
- package/src/updates/desktop-updater.ts +0 -440
- package/src/updates/release-feed.ts +0 -187
- package/src/updates/release-location.ts +0 -101
- package/src/updates/signed-release.ts +0 -311
- package/src/updates/stable-file.ts +0 -32
- package/src/updates/update-arm.ts +0 -107
- package/src/updates/update-channel-store.ts +0 -86
- package/src/updates/update-discovery.ts +0 -113
- package/src/updates/update-download.ts +0 -82
- package/src/updates/update-exclusive-rename.ts +0 -58
- package/src/updates/update-extraction.ts +0 -261
- package/src/updates/update-handoff-plan.ts +0 -75
- package/src/updates/update-helper.ts +0 -87
- package/src/updates/update-launch.ts +0 -33
- package/src/updates/update-manager.ts +0 -130
- package/src/updates/update-process-fence.ts +0 -125
- package/src/updates/update-resume.ts +0 -34
- package/src/updates/update-shutdown.ts +0 -37
- package/src/updates/update-swap-stage.ts +0 -75
- package/src/updates/update-swap.ts +0 -30
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { githubCli } from './github-cli'
|
|
2
|
-
import { qualifyGitHubRelease } from './github-release-qualification'
|
|
3
|
-
import { verifyReleaseProvenance } from './github-release-provenance'
|
|
4
|
-
import { lookupRelease } from './github-release-lookup'
|
|
5
|
-
import type { CutRelease, ReleaseCutProvider } from './release-cut'
|
|
6
|
-
import type { Requirements } from './release-qualification'
|
|
7
|
-
import { workflowFile } from './release-config'
|
|
8
|
-
import { containsAsciiControl } from '../desktop/string-policy'
|
|
9
|
-
import { isRepositorySlug } from '../updates/signed-release'
|
|
10
|
-
|
|
11
|
-
/** GitHub adapter for immutable release cuts from a trusted main workflow. */
|
|
12
|
-
export function createGitHubReleaseCutProvider(options: {
|
|
13
|
-
repository: string
|
|
14
|
-
appName: string
|
|
15
|
-
requirements(tag: string): Requirements
|
|
16
|
-
/** Caller release-assets workflow path, validated by parseReleaseConfig. */
|
|
17
|
-
assetsWorkflow: string
|
|
18
|
-
releasePleaseManifestPath: string
|
|
19
|
-
/** The caller's token cannot list draft releases (no push access). */
|
|
20
|
-
hiddenDrafts?: boolean
|
|
21
|
-
run?: (args: string[], input?: string) => Promise<string>
|
|
22
|
-
}): ReleaseCutProvider {
|
|
23
|
-
const { repository, appName } = options
|
|
24
|
-
if (
|
|
25
|
-
!isRepositorySlug(repository) ||
|
|
26
|
-
!appName.trim() ||
|
|
27
|
-
appName.length > 80 ||
|
|
28
|
-
containsAsciiControl(appName)
|
|
29
|
-
)
|
|
30
|
-
throw new Error('Invalid release configuration')
|
|
31
|
-
const run = options.run ?? githubCli()
|
|
32
|
-
const base = `repos/${repository}`,
|
|
33
|
-
assetsFile = workflowFile(options.assetsWorkflow)
|
|
34
|
-
const read = async (path: string): Promise<unknown> => JSON.parse(await run(['api', path]))
|
|
35
|
-
const releaseData = (tag: string) =>
|
|
36
|
-
lookupRelease({
|
|
37
|
-
tag,
|
|
38
|
-
base,
|
|
39
|
-
read,
|
|
40
|
-
includeDraft: true,
|
|
41
|
-
})
|
|
42
|
-
const isMainAncestor = async (sha: string) => {
|
|
43
|
-
if (!/^[a-f0-9]{40}$/.test(sha)) return false
|
|
44
|
-
const result = (await read(`${base}/compare/${sha}...main`)) as { status?: unknown }
|
|
45
|
-
return ['ahead', 'identical'].includes(String(result?.status))
|
|
46
|
-
}
|
|
47
|
-
const isAncestor = async (older: string, newer: string) => {
|
|
48
|
-
if (!/^[a-f0-9]{40}$/.test(older) || !/^[a-f0-9]{40}$/.test(newer)) return false
|
|
49
|
-
const result = (await read(`${base}/compare/${older}...${newer}`)) as { status?: unknown }
|
|
50
|
-
return result?.status === 'ahead'
|
|
51
|
-
}
|
|
52
|
-
async function tagExists(tag: string): Promise<boolean> {
|
|
53
|
-
if (!/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65)
|
|
54
|
-
throw new Error('Invalid release tag')
|
|
55
|
-
try {
|
|
56
|
-
const value = await read(`${base}/git/ref/tags/${encodeURIComponent(tag)}`)
|
|
57
|
-
if (
|
|
58
|
-
typeof value !== 'object' ||
|
|
59
|
-
value === null ||
|
|
60
|
-
Array.isArray(value) ||
|
|
61
|
-
(value as { ref?: unknown }).ref !== `refs/tags/${tag}`
|
|
62
|
-
)
|
|
63
|
-
throw new Error('Invalid tag response')
|
|
64
|
-
return true
|
|
65
|
-
} catch (error) {
|
|
66
|
-
const detail = error as { message?: unknown; stderr?: unknown }
|
|
67
|
-
if (/\bHTTP 404\b/.test(String(detail?.stderr ?? detail?.message ?? ''))) return false
|
|
68
|
-
throw error
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
tagExists,
|
|
73
|
-
isAncestor,
|
|
74
|
-
async highestDevCounter(version) {
|
|
75
|
-
if (
|
|
76
|
-
typeof version !== 'string' ||
|
|
77
|
-
version.length > 64 ||
|
|
78
|
-
!/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(version)
|
|
79
|
-
)
|
|
80
|
-
throw new Error('Invalid source version')
|
|
81
|
-
const prefix = `v${version}-dev.`
|
|
82
|
-
let highest = 0
|
|
83
|
-
for (let page = 1; page <= 100; page++) {
|
|
84
|
-
const result = await read(`${base}/releases?per_page=100&page=${page}`)
|
|
85
|
-
if (!Array.isArray(result) || result.length > 100)
|
|
86
|
-
throw new Error('Invalid release history')
|
|
87
|
-
for (const value of result) {
|
|
88
|
-
if (
|
|
89
|
-
typeof value !== 'object' ||
|
|
90
|
-
value === null ||
|
|
91
|
-
Array.isArray(value) ||
|
|
92
|
-
typeof (value as { tag_name?: unknown }).tag_name !== 'string'
|
|
93
|
-
)
|
|
94
|
-
throw new Error('Invalid release history')
|
|
95
|
-
const tag = (value as { tag_name: string }).tag_name
|
|
96
|
-
if (!tag.startsWith(prefix)) continue
|
|
97
|
-
const suffix = tag.slice(prefix.length)
|
|
98
|
-
if (!/^\d+$/.test(suffix) || suffix.length > 16 || !Number.isSafeInteger(Number(suffix)))
|
|
99
|
-
throw new Error('Invalid dev release counter')
|
|
100
|
-
highest = Math.max(highest, Number(suffix))
|
|
101
|
-
}
|
|
102
|
-
if (result.length < 100) return highest
|
|
103
|
-
}
|
|
104
|
-
throw new Error('Release history exceeds inspection limit')
|
|
105
|
-
},
|
|
106
|
-
async find(tag): Promise<CutRelease | null> {
|
|
107
|
-
if (!/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65)
|
|
108
|
-
throw new Error('Invalid release tag')
|
|
109
|
-
const kind = tag.includes('-dev.') ? 'dev' : 'daily'
|
|
110
|
-
const found = await releaseData(tag)
|
|
111
|
-
// A job token without push access cannot list drafts. There a Release Please daily
|
|
112
|
-
// tag with no visible release stands for its draft; publication, which can see
|
|
113
|
-
// drafts, still requires the draft itself.
|
|
114
|
-
if (!found && (!options.hiddenDrafts || kind !== 'daily' || !(await tagExists(tag))))
|
|
115
|
-
return null
|
|
116
|
-
const release = found ?? { tag_name: tag, draft: true, prerelease: false, body: '' }
|
|
117
|
-
if (
|
|
118
|
-
release.tag_name !== tag ||
|
|
119
|
-
typeof release.draft !== 'boolean' ||
|
|
120
|
-
typeof release.prerelease !== 'boolean' ||
|
|
121
|
-
typeof release.body !== 'string'
|
|
122
|
-
)
|
|
123
|
-
throw new Error('Invalid release response')
|
|
124
|
-
const target = (await read(`${base}/commits/${encodeURIComponent(tag)}`)) as { sha?: unknown }
|
|
125
|
-
if (
|
|
126
|
-
typeof target?.sha !== 'string' ||
|
|
127
|
-
!(await verifyReleaseProvenance({
|
|
128
|
-
tag,
|
|
129
|
-
sourceSha: target.sha,
|
|
130
|
-
body: release.body,
|
|
131
|
-
releasePleaseManifestPath: options.releasePleaseManifestPath,
|
|
132
|
-
read,
|
|
133
|
-
base,
|
|
134
|
-
}))
|
|
135
|
-
)
|
|
136
|
-
throw new Error('Release provenance mismatch')
|
|
137
|
-
const stageableDraft =
|
|
138
|
-
release.draft &&
|
|
139
|
-
kind === 'daily' &&
|
|
140
|
-
!release.body
|
|
141
|
-
.split(/\r?\n/)
|
|
142
|
-
.some((line) => line.startsWith('adea-channel:') || line.startsWith('Source: '))
|
|
143
|
-
return {
|
|
144
|
-
tag,
|
|
145
|
-
sourceSha: target.sha,
|
|
146
|
-
kind,
|
|
147
|
-
draft: release.draft,
|
|
148
|
-
prerelease: release.prerelease,
|
|
149
|
-
...(stageableDraft ? { stageableDraft: true } : {}),
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
isMainAncestor,
|
|
153
|
-
async create(identity) {
|
|
154
|
-
const body = {
|
|
155
|
-
tag_name: identity.tag,
|
|
156
|
-
target_commitish: identity.sourceSha,
|
|
157
|
-
name: `${appName} ${identity.tag}`,
|
|
158
|
-
prerelease: true,
|
|
159
|
-
make_latest: 'false',
|
|
160
|
-
body: `adea-channel:dev\n\nSource: ${identity.sourceSha}`,
|
|
161
|
-
}
|
|
162
|
-
await run(
|
|
163
|
-
['api', `${base}/releases`, '--method', 'POST', '--input', '-'],
|
|
164
|
-
JSON.stringify(body)
|
|
165
|
-
)
|
|
166
|
-
},
|
|
167
|
-
async qualification(release) {
|
|
168
|
-
try {
|
|
169
|
-
const current = await releaseData(release.tag)
|
|
170
|
-
if (!current || !Array.isArray(current.assets)) return 'unknown'
|
|
171
|
-
const candidates = current.assets.filter(
|
|
172
|
-
(value: unknown) =>
|
|
173
|
-
typeof value === 'object' &&
|
|
174
|
-
value !== null &&
|
|
175
|
-
/^qualification-[1-9]\d*-[1-9]\d*\.json$/.test(
|
|
176
|
-
String((value as { name?: unknown }).name)
|
|
177
|
-
)
|
|
178
|
-
)
|
|
179
|
-
if (!candidates.length) return 'not-qualified'
|
|
180
|
-
await qualifyGitHubRelease({
|
|
181
|
-
repository,
|
|
182
|
-
tag: release.tag,
|
|
183
|
-
requirements: options.requirements(release.tag),
|
|
184
|
-
assetsWorkflow: options.assetsWorkflow,
|
|
185
|
-
releasePleaseManifestPath: options.releasePleaseManifestPath,
|
|
186
|
-
run,
|
|
187
|
-
})
|
|
188
|
-
return 'qualified'
|
|
189
|
-
} catch {
|
|
190
|
-
return 'unknown'
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
async pendingBuild(release) {
|
|
194
|
-
try {
|
|
195
|
-
for (let page = 1; page <= 100; page++) {
|
|
196
|
-
const response = (await read(
|
|
197
|
-
`${base}/actions/workflows/${assetsFile}/runs?event=workflow_dispatch&per_page=100&page=${page}`
|
|
198
|
-
)) as { workflow_runs?: unknown }
|
|
199
|
-
if (!Array.isArray(response?.workflow_runs)) return 'unknown'
|
|
200
|
-
for (const value of response.workflow_runs) {
|
|
201
|
-
if (typeof value !== 'object' || value === null) return 'unknown'
|
|
202
|
-
const item = value as Record<string, unknown>
|
|
203
|
-
if (item.display_title !== `framework-release-assets:${release.tag}`) continue
|
|
204
|
-
if (
|
|
205
|
-
item.event !== 'workflow_dispatch' ||
|
|
206
|
-
item.head_branch !== 'main' ||
|
|
207
|
-
typeof item.head_sha !== 'string' ||
|
|
208
|
-
!(await isMainAncestor(item.head_sha)) ||
|
|
209
|
-
typeof item.status !== 'string'
|
|
210
|
-
)
|
|
211
|
-
return 'unknown'
|
|
212
|
-
if (['queued', 'in_progress', 'waiting', 'pending', 'requested'].includes(item.status))
|
|
213
|
-
return 'pending'
|
|
214
|
-
if (item.status !== 'completed') return 'unknown'
|
|
215
|
-
}
|
|
216
|
-
if (response.workflow_runs.length < 100) return 'idle'
|
|
217
|
-
}
|
|
218
|
-
return 'unknown'
|
|
219
|
-
} catch {
|
|
220
|
-
return 'unknown'
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
async dispatch(tag) {
|
|
224
|
-
await run([
|
|
225
|
-
'workflow',
|
|
226
|
-
'run',
|
|
227
|
-
assetsFile,
|
|
228
|
-
'--repo',
|
|
229
|
-
repository,
|
|
230
|
-
'--ref',
|
|
231
|
-
'main',
|
|
232
|
-
'-f',
|
|
233
|
-
`tag=${tag}`,
|
|
234
|
-
])
|
|
235
|
-
},
|
|
236
|
-
}
|
|
237
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/** GitHub's release-by-tag endpoint omits drafts, so inspect bounded listings when opted in. */
|
|
2
|
-
export async function lookupRelease(options: {
|
|
3
|
-
tag: string
|
|
4
|
-
base: string
|
|
5
|
-
read(path: string): Promise<unknown>
|
|
6
|
-
includeDraft: boolean
|
|
7
|
-
}): Promise<Record<string, unknown> | null> {
|
|
8
|
-
const { tag, base, read } = options
|
|
9
|
-
try {
|
|
10
|
-
const result = await read(`${base}/releases/tags/${encodeURIComponent(tag)}`)
|
|
11
|
-
if (typeof result !== 'object' || result === null || Array.isArray(result))
|
|
12
|
-
throw new Error('Invalid release response')
|
|
13
|
-
return result as Record<string, unknown>
|
|
14
|
-
} catch (error) {
|
|
15
|
-
const detail = error as { message?: unknown; stderr?: unknown }
|
|
16
|
-
if (!/\bHTTP 404\b/.test(String(detail?.stderr ?? detail?.message ?? ''))) throw error
|
|
17
|
-
}
|
|
18
|
-
if (!options.includeDraft) return null
|
|
19
|
-
let match: Record<string, unknown> | null = null
|
|
20
|
-
for (let page = 1; page <= 100; page++) {
|
|
21
|
-
const result = await read(`${base}/releases?per_page=100&page=${page}`)
|
|
22
|
-
if (!Array.isArray(result) || result.length > 100) throw new Error('Invalid release history')
|
|
23
|
-
for (const item of result) {
|
|
24
|
-
if (
|
|
25
|
-
typeof item !== 'object' ||
|
|
26
|
-
item === null ||
|
|
27
|
-
Array.isArray(item) ||
|
|
28
|
-
typeof item.tag_name !== 'string'
|
|
29
|
-
)
|
|
30
|
-
throw new Error('Invalid release history')
|
|
31
|
-
if (item.tag_name === tag) {
|
|
32
|
-
if (match) throw new Error('Duplicate release tag')
|
|
33
|
-
match = item
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (result.length < 100) return match
|
|
37
|
-
}
|
|
38
|
-
throw new Error('Release history exceeds inspection limit')
|
|
39
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { qualifyGitHubRelease } from './github-release-qualification'
|
|
2
|
-
import { githubCli } from './github-cli'
|
|
3
|
-
import type { Requirements } from './release-qualification'
|
|
4
|
-
import type { PromotionProvider, PromotionRelease } from './release-promotion'
|
|
5
|
-
import { assertRepositorySlug } from '../updates/signed-release'
|
|
6
|
-
|
|
7
|
-
function normalizePromotionRelease(value: unknown): PromotionRelease {
|
|
8
|
-
if (typeof value !== 'object' || value === null) throw new Error('Invalid GitHub release')
|
|
9
|
-
const item = value as Record<string, unknown>
|
|
10
|
-
if (
|
|
11
|
-
!Number.isSafeInteger(item.id) ||
|
|
12
|
-
typeof item.tag_name !== 'string' ||
|
|
13
|
-
(item.body !== null && typeof item.body !== 'string') ||
|
|
14
|
-
typeof item.draft !== 'boolean' ||
|
|
15
|
-
typeof item.prerelease !== 'boolean' ||
|
|
16
|
-
typeof item.published_at !== 'string'
|
|
17
|
-
)
|
|
18
|
-
throw new Error('Invalid GitHub release')
|
|
19
|
-
return {
|
|
20
|
-
id: item.id as number,
|
|
21
|
-
tag: item.tag_name,
|
|
22
|
-
body: typeof item.body === 'string' ? item.body : '',
|
|
23
|
-
draft: item.draft,
|
|
24
|
-
prerelease: item.prerelease,
|
|
25
|
-
publishedAt: item.published_at,
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** GitHub release provider for a trusted workflow, using GH_TOKEN for gh. */
|
|
30
|
-
export function createGitHubPromotionProvider(options: {
|
|
31
|
-
repository: string
|
|
32
|
-
requirements: (tag: string) => Requirements
|
|
33
|
-
assetsWorkflow: string
|
|
34
|
-
releasePleaseManifestPath: string
|
|
35
|
-
run?: (args: string[], input?: string) => Promise<string>
|
|
36
|
-
}): PromotionProvider {
|
|
37
|
-
const repository = options.repository
|
|
38
|
-
assertRepositorySlug(repository)
|
|
39
|
-
const run = options.run ?? githubCli()
|
|
40
|
-
const base = `repos/${repository}`
|
|
41
|
-
const read = async (path: string): Promise<unknown> => JSON.parse(await run(['api', path]))
|
|
42
|
-
const qualify = async (release: PromotionRelease) => {
|
|
43
|
-
await qualifyGitHubRelease({
|
|
44
|
-
repository,
|
|
45
|
-
tag: release.tag,
|
|
46
|
-
requirements: options.requirements(release.tag),
|
|
47
|
-
assetsWorkflow: options.assetsWorkflow,
|
|
48
|
-
releasePleaseManifestPath: options.releasePleaseManifestPath,
|
|
49
|
-
run,
|
|
50
|
-
})
|
|
51
|
-
return true
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
async list() {
|
|
55
|
-
const releases: PromotionRelease[] = []
|
|
56
|
-
for (let page = 1; page <= 100; page++) {
|
|
57
|
-
const data = await read(`${base}/releases?per_page=100&page=${page}`)
|
|
58
|
-
if (!Array.isArray(data)) throw new Error('Invalid GitHub release listing')
|
|
59
|
-
for (const item of data) {
|
|
60
|
-
if (
|
|
61
|
-
typeof item !== 'object' ||
|
|
62
|
-
item === null ||
|
|
63
|
-
typeof (item as { draft?: unknown }).draft !== 'boolean'
|
|
64
|
-
)
|
|
65
|
-
throw new Error('Invalid GitHub release listing')
|
|
66
|
-
if (!(item as { draft: boolean }).draft) releases.push(normalizePromotionRelease(item))
|
|
67
|
-
}
|
|
68
|
-
if (data.length < 100) return releases
|
|
69
|
-
}
|
|
70
|
-
throw new Error('Too many GitHub releases')
|
|
71
|
-
},
|
|
72
|
-
qualify,
|
|
73
|
-
async markStable(selected, at) {
|
|
74
|
-
const timestamp = new Date(at)
|
|
75
|
-
if (!Number.isFinite(timestamp.getTime())) throw new Error('Invalid promotion timestamp')
|
|
76
|
-
const current = normalizePromotionRelease(
|
|
77
|
-
await read(`${base}/releases/tags/${encodeURIComponent(selected.tag)}`)
|
|
78
|
-
)
|
|
79
|
-
if (
|
|
80
|
-
current.id !== selected.id ||
|
|
81
|
-
current.tag !== selected.tag ||
|
|
82
|
-
current.publishedAt !== selected.publishedAt ||
|
|
83
|
-
current.draft ||
|
|
84
|
-
current.body !== selected.body ||
|
|
85
|
-
current.prerelease !== selected.prerelease
|
|
86
|
-
)
|
|
87
|
-
throw new Error('Release changed during promotion')
|
|
88
|
-
await qualify(current)
|
|
89
|
-
const marker = `<!-- adea-stable:v1 ${current.tag} -->`
|
|
90
|
-
const body = current.body.split(/\r?\n/).includes(marker)
|
|
91
|
-
? current.body
|
|
92
|
-
: `${current.body}\n\n${marker}\n<!-- adea-stable-time:${timestamp.toISOString()} -->`
|
|
93
|
-
await run(
|
|
94
|
-
['api', `${base}/releases/${current.id}`, '--method', 'PATCH', '--input', '-'],
|
|
95
|
-
JSON.stringify({ prerelease: false, make_latest: 'true', body })
|
|
96
|
-
)
|
|
97
|
-
const after = normalizePromotionRelease(
|
|
98
|
-
await read(`${base}/releases/tags/${encodeURIComponent(current.tag)}`)
|
|
99
|
-
)
|
|
100
|
-
if (
|
|
101
|
-
after.id !== current.id ||
|
|
102
|
-
after.draft ||
|
|
103
|
-
after.prerelease ||
|
|
104
|
-
!after.body.split(/\r?\n/).includes(marker)
|
|
105
|
-
)
|
|
106
|
-
throw new Error('Stable release update could not be verified')
|
|
107
|
-
const latest = normalizePromotionRelease(await read(`${base}/releases/latest`))
|
|
108
|
-
if (latest.id !== current.id || latest.tag !== current.tag)
|
|
109
|
-
throw new Error('Latest stable release could not be verified')
|
|
110
|
-
},
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/** Check the tag and source independently; legacy release notes are never rewritten. */
|
|
2
|
-
export async function verifyReleaseProvenance(options: {
|
|
3
|
-
tag: string
|
|
4
|
-
sourceSha: string
|
|
5
|
-
body: string
|
|
6
|
-
releasePleaseManifestPath: string
|
|
7
|
-
read(path: string): Promise<unknown>
|
|
8
|
-
base: string
|
|
9
|
-
}): Promise<boolean> {
|
|
10
|
-
const { tag, sourceSha, body, releasePleaseManifestPath, read, base } = options
|
|
11
|
-
if (!/^[a-f0-9]{40}$/.test(sourceSha)) return false
|
|
12
|
-
const lines = body.split(/\r?\n/)
|
|
13
|
-
const markers = lines.filter((line) => line.startsWith('adea-channel:'))
|
|
14
|
-
const sources = lines.filter((line) => line.startsWith('Source: '))
|
|
15
|
-
const kind = tag.includes('-dev.') ? 'dev' : 'daily'
|
|
16
|
-
// Dev releases carry the cutter's marker; dailies are Release Please releases whose
|
|
17
|
-
// manifest at the tagged commit names the tag's version.
|
|
18
|
-
if (
|
|
19
|
-
kind === 'dev' &&
|
|
20
|
-
markers.length === 1 &&
|
|
21
|
-
markers[0] === 'adea-channel:dev' &&
|
|
22
|
-
sources.length === 1 &&
|
|
23
|
-
sources[0] === `Source: ${sourceSha}`
|
|
24
|
-
)
|
|
25
|
-
return true
|
|
26
|
-
if (
|
|
27
|
-
kind !== 'daily' ||
|
|
28
|
-
markers.length ||
|
|
29
|
-
sources.length ||
|
|
30
|
-
!/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) ||
|
|
31
|
-
!/^[A-Za-z0-9._/-]+\.json$/.test(releasePleaseManifestPath) ||
|
|
32
|
-
releasePleaseManifestPath.split('/').some((part) => !part || part === '.' || part === '..')
|
|
33
|
-
)
|
|
34
|
-
return false
|
|
35
|
-
const path = releasePleaseManifestPath.split('/').map(encodeURIComponent).join('/')
|
|
36
|
-
const result = await read(`${base}/contents/${path}?ref=${sourceSha}`)
|
|
37
|
-
if (typeof result !== 'object' || result === null || Array.isArray(result)) return false
|
|
38
|
-
const data = result as { type?: unknown; encoding?: unknown; size?: unknown; content?: unknown }
|
|
39
|
-
if (
|
|
40
|
-
data.type !== 'file' ||
|
|
41
|
-
data.encoding !== 'base64' ||
|
|
42
|
-
!Number.isSafeInteger(data.size) ||
|
|
43
|
-
Number(data.size) < 1 ||
|
|
44
|
-
Number(data.size) > 262144 ||
|
|
45
|
-
typeof data.content !== 'string' ||
|
|
46
|
-
data.content.length > 400000
|
|
47
|
-
)
|
|
48
|
-
return false
|
|
49
|
-
const encoded = data.content.replace(/\n/g, '')
|
|
50
|
-
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded))
|
|
51
|
-
return false
|
|
52
|
-
const bytes = Buffer.from(encoded, 'base64')
|
|
53
|
-
if (bytes.length !== data.size || bytes.toString('base64') !== encoded) return false
|
|
54
|
-
try {
|
|
55
|
-
const manifest: unknown = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes))
|
|
56
|
-
return (
|
|
57
|
-
typeof manifest === 'object' &&
|
|
58
|
-
manifest !== null &&
|
|
59
|
-
!Array.isArray(manifest) &&
|
|
60
|
-
(manifest as { version?: unknown }).version === tag.slice(1)
|
|
61
|
-
)
|
|
62
|
-
} catch {
|
|
63
|
-
return false
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { ReleaseIdentity } from './release-qualification'
|
|
2
|
-
import { githubCli } from './github-cli'
|
|
3
|
-
import { listGitHubReleaseAssets } from './github-release-assets'
|
|
4
|
-
import { verifyReleaseProvenance } from './github-release-provenance'
|
|
5
|
-
import { lookupRelease } from './github-release-lookup'
|
|
6
|
-
import type { ReleasePublisher, RemoteReleaseState } from './release-publication'
|
|
7
|
-
import { isRepositorySlug } from '../updates/signed-release'
|
|
8
|
-
|
|
9
|
-
/** GitHub adapter; callers must run it in a trusted release job with GH_TOKEN. */
|
|
10
|
-
export function createGitHubReleasePublisher(options: {
|
|
11
|
-
repository: string
|
|
12
|
-
identity: ReleaseIdentity
|
|
13
|
-
releasePleaseManifestPath: string
|
|
14
|
-
run?: (args: string[]) => Promise<string>
|
|
15
|
-
}): ReleasePublisher {
|
|
16
|
-
const { repository, identity } = options
|
|
17
|
-
if (
|
|
18
|
-
!isRepositorySlug(repository) ||
|
|
19
|
-
identity.tag.length > 65 ||
|
|
20
|
-
!/^v[0-9]+\.[0-9]+\.[0-9]+(?:-dev\.[0-9]+)?$/.test(identity.tag) ||
|
|
21
|
-
!/^[a-f0-9]{40}$/.test(identity.sourceSha) ||
|
|
22
|
-
!/^[a-f0-9]{40}$/.test(identity.workflowSha)
|
|
23
|
-
)
|
|
24
|
-
throw new Error('Invalid GitHub release identity')
|
|
25
|
-
const run = options.run ?? githubCli()
|
|
26
|
-
const base = `repos/${repository}`
|
|
27
|
-
const read = async (path: string): Promise<unknown> => JSON.parse(await run(['api', path]))
|
|
28
|
-
return {
|
|
29
|
-
async inspect(selected): Promise<RemoteReleaseState> {
|
|
30
|
-
if (
|
|
31
|
-
Object.keys(identity).some(
|
|
32
|
-
(key) => identity[key as keyof ReleaseIdentity] !== selected[key as keyof ReleaseIdentity]
|
|
33
|
-
)
|
|
34
|
-
)
|
|
35
|
-
throw new Error('Release identity changed')
|
|
36
|
-
const [releaseData, commitData, sourceComparison, workflowComparison] = await Promise.all([
|
|
37
|
-
lookupRelease({
|
|
38
|
-
tag: identity.tag,
|
|
39
|
-
base,
|
|
40
|
-
read,
|
|
41
|
-
includeDraft: true,
|
|
42
|
-
}),
|
|
43
|
-
read(`${base}/commits/${encodeURIComponent(identity.tag)}`),
|
|
44
|
-
read(`${base}/compare/${identity.sourceSha}...main`),
|
|
45
|
-
read(`${base}/compare/${identity.workflowSha}...main`),
|
|
46
|
-
])
|
|
47
|
-
const release = releaseData as {
|
|
48
|
-
tag_name?: unknown
|
|
49
|
-
draft?: unknown
|
|
50
|
-
body?: unknown
|
|
51
|
-
id?: unknown
|
|
52
|
-
}
|
|
53
|
-
const commit = commitData as { sha?: unknown }
|
|
54
|
-
const source = sourceComparison as { status?: unknown }
|
|
55
|
-
const workflow = workflowComparison as { status?: unknown }
|
|
56
|
-
if (
|
|
57
|
-
!release ||
|
|
58
|
-
typeof release.tag_name !== 'string' ||
|
|
59
|
-
typeof release.draft !== 'boolean' ||
|
|
60
|
-
typeof release.body !== 'string'
|
|
61
|
-
)
|
|
62
|
-
throw new Error('Invalid GitHub release response')
|
|
63
|
-
const assets = await listGitHubReleaseAssets(read, base, release.id)
|
|
64
|
-
const provenance =
|
|
65
|
-
(!release.draft ||
|
|
66
|
-
!release.body
|
|
67
|
-
.split(/\r?\n/)
|
|
68
|
-
.some((line) => line.startsWith('adea-channel:') || line.startsWith('Source: '))) &&
|
|
69
|
-
(await verifyReleaseProvenance({
|
|
70
|
-
tag: identity.tag,
|
|
71
|
-
sourceSha: identity.sourceSha,
|
|
72
|
-
body: release.body,
|
|
73
|
-
releasePleaseManifestPath: options.releasePleaseManifestPath,
|
|
74
|
-
read,
|
|
75
|
-
base,
|
|
76
|
-
}))
|
|
77
|
-
return {
|
|
78
|
-
tag: release.tag_name,
|
|
79
|
-
sourceSha: typeof commit?.sha === 'string' ? commit.sha : '',
|
|
80
|
-
sourceOnMain: provenance && ['ahead', 'identical'].includes(String(source?.status)),
|
|
81
|
-
workflowOnMain: ['ahead', 'identical'].includes(String(workflow?.status)),
|
|
82
|
-
draft: release.draft,
|
|
83
|
-
assets,
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
async upload(path) {
|
|
87
|
-
await run(['release', 'upload', identity.tag, path, '--repo', repository])
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto'
|
|
2
|
-
import { githubCli } from './github-cli'
|
|
3
|
-
import {
|
|
4
|
-
validateQualificationRun,
|
|
5
|
-
validateReleaseQualification,
|
|
6
|
-
type Qualification,
|
|
7
|
-
type Requirements,
|
|
8
|
-
} from './release-qualification'
|
|
9
|
-
import { listGitHubReleaseAssets } from './github-release-assets'
|
|
10
|
-
import { verifyReleaseProvenance } from './github-release-provenance'
|
|
11
|
-
import { lookupRelease } from './github-release-lookup'
|
|
12
|
-
import { isRepositorySlug } from '../updates/signed-release'
|
|
13
|
-
|
|
14
|
-
/** Verify immutable GitHub release assets and the exact successful workflow attempt. */
|
|
15
|
-
export async function qualifyGitHubRelease(options: {
|
|
16
|
-
repository: string
|
|
17
|
-
tag: string
|
|
18
|
-
requirements: Requirements
|
|
19
|
-
/** Caller release-assets workflow path every qualification run must come from. */
|
|
20
|
-
assetsWorkflow: string
|
|
21
|
-
releasePleaseManifestPath: string
|
|
22
|
-
allowDraft?: boolean
|
|
23
|
-
run?: (args: string[]) => Promise<string>
|
|
24
|
-
}): Promise<Qualification> {
|
|
25
|
-
const { repository, tag, requirements } = options
|
|
26
|
-
if (
|
|
27
|
-
!isRepositorySlug(repository) ||
|
|
28
|
-
tag.length > 65 ||
|
|
29
|
-
!/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag)
|
|
30
|
-
)
|
|
31
|
-
throw new Error('Invalid release identity')
|
|
32
|
-
const run = options.run ?? githubCli()
|
|
33
|
-
const base = `repos/${repository}`
|
|
34
|
-
const read = async (path: string): Promise<unknown> => JSON.parse(await run(['api', path]))
|
|
35
|
-
const [releaseData, commitData] = await Promise.all([
|
|
36
|
-
lookupRelease({ tag, base, read, includeDraft: options.allowDraft === true }),
|
|
37
|
-
read(`${base}/commits/${encodeURIComponent(tag)}`),
|
|
38
|
-
])
|
|
39
|
-
const release = releaseData as {
|
|
40
|
-
tag_name?: unknown
|
|
41
|
-
draft?: unknown
|
|
42
|
-
body?: unknown
|
|
43
|
-
id?: unknown
|
|
44
|
-
}
|
|
45
|
-
const sourceSha = (commitData as { sha?: unknown })?.sha
|
|
46
|
-
if (
|
|
47
|
-
!release ||
|
|
48
|
-
release.tag_name !== tag ||
|
|
49
|
-
(release.draft !== false && !(release.draft === true && options.allowDraft === true)) ||
|
|
50
|
-
typeof release.body !== 'string' ||
|
|
51
|
-
(release.draft === true &&
|
|
52
|
-
release.body
|
|
53
|
-
.split(/\r?\n/)
|
|
54
|
-
.some((line) => line.startsWith('adea-channel:') || line.startsWith('Source: '))) ||
|
|
55
|
-
typeof sourceSha !== 'string' ||
|
|
56
|
-
!(await verifyReleaseProvenance({
|
|
57
|
-
tag,
|
|
58
|
-
sourceSha,
|
|
59
|
-
body: release.body,
|
|
60
|
-
releasePleaseManifestPath: options.releasePleaseManifestPath,
|
|
61
|
-
read,
|
|
62
|
-
base,
|
|
63
|
-
}))
|
|
64
|
-
)
|
|
65
|
-
throw new Error('Invalid release source')
|
|
66
|
-
const assets = await listGitHubReleaseAssets(read, base, release.id)
|
|
67
|
-
const pattern = /^qualification-([1-9]\d*)-([1-9]\d*)\.json$/
|
|
68
|
-
const candidates = assets
|
|
69
|
-
.filter((asset) => pattern.test(asset.name))
|
|
70
|
-
// Sort a derived array without raising the runtime floor above ES2022.
|
|
71
|
-
// oxlint-disable-next-line unicorn/no-array-sort
|
|
72
|
-
.sort((a, b) => {
|
|
73
|
-
const first = a.name.match(pattern)!,
|
|
74
|
-
second = b.name.match(pattern)!
|
|
75
|
-
const runOrder = BigInt(second[1]!) - BigInt(first[1]!)
|
|
76
|
-
return runOrder < 0n ? -1 : runOrder > 0n ? 1 : Number(second[2]) - Number(first[2])
|
|
77
|
-
})
|
|
78
|
-
for (const asset of candidates) {
|
|
79
|
-
try {
|
|
80
|
-
if (
|
|
81
|
-
assets.filter((item) => item.name === asset.name).length !== 1 ||
|
|
82
|
-
!Number.isSafeInteger(asset.size) ||
|
|
83
|
-
asset.size < 1 ||
|
|
84
|
-
asset.size > 262144
|
|
85
|
-
)
|
|
86
|
-
throw new Error('Invalid qualification asset')
|
|
87
|
-
const text = await run([
|
|
88
|
-
'release',
|
|
89
|
-
'download',
|
|
90
|
-
tag,
|
|
91
|
-
'--repo',
|
|
92
|
-
repository,
|
|
93
|
-
'--pattern',
|
|
94
|
-
asset.name,
|
|
95
|
-
'--output',
|
|
96
|
-
'-',
|
|
97
|
-
])
|
|
98
|
-
const bytes = Buffer.from(text, 'utf8')
|
|
99
|
-
if (
|
|
100
|
-
bytes.length !== asset.size ||
|
|
101
|
-
'sha256:' + createHash('sha256').update(bytes).digest('hex') !== asset.digest
|
|
102
|
-
)
|
|
103
|
-
throw new Error('Qualification bytes changed')
|
|
104
|
-
const receipt = JSON.parse(text) as Qualification
|
|
105
|
-
if (asset.name !== `qualification-${receipt.runId}-${receipt.runAttempt}.json`)
|
|
106
|
-
throw new Error('Qualification filename mismatch')
|
|
107
|
-
validateReleaseQualification(
|
|
108
|
-
{ tag_name: tag, draft: false, assets },
|
|
109
|
-
receipt,
|
|
110
|
-
sourceSha,
|
|
111
|
-
requirements
|
|
112
|
-
)
|
|
113
|
-
const attempt = `${base}/actions/runs/${receipt.runId}/attempts/${receipt.runAttempt}`
|
|
114
|
-
const runData = (await read(attempt)) as Parameters<typeof validateQualificationRun>[0]
|
|
115
|
-
const jobs: Parameters<typeof validateQualificationRun>[1] = []
|
|
116
|
-
for (let page = 1; page <= 100; page++) {
|
|
117
|
-
const response = (await read(`${attempt}/jobs?per_page=100&page=${page}`)) as {
|
|
118
|
-
jobs?: unknown
|
|
119
|
-
}
|
|
120
|
-
if (!Array.isArray(response?.jobs)) throw new Error('Invalid qualification jobs')
|
|
121
|
-
jobs.push(...response.jobs)
|
|
122
|
-
if (response.jobs.length < 100) break
|
|
123
|
-
if (page === 100) throw new Error('Too many qualification jobs')
|
|
124
|
-
}
|
|
125
|
-
validateQualificationRun(
|
|
126
|
-
runData,
|
|
127
|
-
jobs,
|
|
128
|
-
receipt,
|
|
129
|
-
repository,
|
|
130
|
-
requirements,
|
|
131
|
-
options.assetsWorkflow
|
|
132
|
-
)
|
|
133
|
-
for (const commit of [sourceSha, receipt.workflowSha]) {
|
|
134
|
-
const result = (await read(`${base}/compare/${commit}...main`)) as { status?: unknown }
|
|
135
|
-
if (!['ahead', 'identical'].includes(String(result?.status)))
|
|
136
|
-
throw new Error('Untrusted release ancestry')
|
|
137
|
-
}
|
|
138
|
-
return receipt
|
|
139
|
-
} catch {
|
|
140
|
-
/* A later immutable attempt may still qualify. */
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
throw new Error('No successful immutable qualification matches this release')
|
|
144
|
-
}
|