@adea-ai/app-framework 0.33.1 → 0.34.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 CHANGED
@@ -101,6 +101,7 @@ Commands (package `bin` entries):
101
101
  | `adea-finalize-release` | Publish a qualified Release Please draft as a prerelease. |
102
102
  | `adea-verify-macos-signing` | On a Mac, check every nested Mach-O in an app is signed alike and the seal verifies. |
103
103
  | `adea-promote-release` | Promote the newest qualified daily to stable after the soak. |
104
+ | `adea-desktop-release` | In a GitLab release tag pipeline, build, sign and publish this runner's platform, then promote. |
104
105
  | `adea-cef-helper` | Print the CEF helper cache key, or build the helper. |
105
106
  | `adea-patch-windows-runtime` | Apply the checksum-guarded Windows runtime correction. |
106
107
  | `adea-patch-electrobun-shortcuts` | Apply the shipped Windows shortcut patch to an Electrobun checkout. |
@@ -410,13 +411,30 @@ closed, closing the window, unless the window's single view reports the
410
411
  requested partition. Without a partition it is a plain constructor call, and it
411
412
  can wrap the `construct` callback given to `desktop-host`.
412
413
 
414
+ `adea-desktop-release daily|stable` is the provider-neutral desktop release
415
+ driver for GitLab release tag pipelines (and any checkout of a tagged main
416
+ commit). It uses the local release mode, so provenance comes from git (the tag
417
+ commit on `origin/main`, the version file at that commit), not from a CI
418
+ provider. A daily cut must equal `CI_COMMIT_TAG`. It builds the runner's own
419
+ platform, signs the descriptors with `DESKTOP_UPDATE_SIGNING_KEY_B64` (decoded
420
+ only into the signing process's environment), uploads the staged tree to an
421
+ S3-compatible bucket with the aws CLI in plan order (immutable files are never
422
+ overwritten, the channel pointers go last), verifies the feed and links every
423
+ file on the GitLab release with the job token. `stable` promotes the newest
424
+ qualified daily after the soak. Apps add their own files through the optional
425
+ `release:preflight` and `release:extend-plan` package scripts. An app that
426
+ releases only this way can leave `releaseWorkflows` out of
427
+ `release-config.json`; the GitHub-hosted release commands then refuse to run.
428
+
413
429
  The `create-adea-app` command generates a new application
414
430
  from an identity, framework package specifier and renderer choice. The starter
415
431
  provides the shared shell, appearance, one view and one desktop service. The
416
432
  generated GitLab validation job accepts optional comma-separated
417
433
  `--gitlab-runner-tags`; without them it requires an untagged Docker runner.
418
- The generated GitLab job validates the app but does not publish releases.
419
- The framework package specifier must refer to a distributable package available to
434
+ Its `.gitlab/desktop-release.yml` publishes desktop releases from release tag
435
+ pipelines with `adea-desktop-release` (below) on the runner named by
436
+ `--gitlab-release-runner-tags`, and stays off until the project sets
437
+ `DESKTOP_RELEASE_ENABLED=true`. The framework package specifier must refer to a distributable package available to
420
438
  the new project. Its GitHub Actions release workflows call this framework release's
421
439
  reusable workflows on the shared schedule (pinned to the release tag; run
422
440
  `bunx adea-update-app-framework` to pin the commit) and stay off until the
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env bash
2
+ # adea-desktop-release: publish a desktop release from a GitLab release tag pipeline with the
3
+ # framework's local release mode. It builds this machine's platform (macOS arm64 or Linux x64),
4
+ # signs the channel descriptors, uploads the staged tree to the app's release feed (an
5
+ # S3-compatible bucket such as Cloudflare R2) in plan order with the channel pointers last,
6
+ # verifies the feed and links every published file on the GitLab release.
7
+ #
8
+ # adea-desktop-release daily build and publish the tag's daily (CI_COMMIT_TAG = v<version>)
9
+ # adea-desktop-release stable promote the newest qualified daily after the soak
10
+ #
11
+ # Run it from the repository checkout after `bun install`. A second runner of another platform at
12
+ # the same tag adds its platform to the same release; a platform with no runner is never
13
+ # published or reported as passed.
14
+ #
15
+ # App hooks (optional package.json scripts in the app directory):
16
+ # release:preflight <tag> <platform> runs before the build (check extra keys)
17
+ # release:extend-plan <channel> <tag> <platform> <out> <source-sha>
18
+ # adds app files to the staged plan
19
+ #
20
+ # Environment (protected, masked GitLab CI variables reach only protected tags):
21
+ # DESKTOP_RELEASE_APP_DIR the app directory, relative to the repository (default .)
22
+ # DESKTOP_UPDATE_SIGNING_KEY_B64 base64 of the Ed25519 update key PEM (daily; refused when missing)
23
+ # R2_ENDPOINT or CLOUDFLARE_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY bucket credentials
24
+ # R2_BUCKET (default adea-releases), STABLE_PROMOTION_HELD (true holds promotion)
25
+ # DESKTOP_RELEASE_DRY_RUN=1 cut and plan only: builds, signs and uploads nothing
26
+ # The update key is decoded into the signing process's environment only, never to disk.
27
+ set -euo pipefail
28
+ channel=${1:?daily|stable}
29
+ case "$channel" in daily|stable) ;; *) echo "channel must be daily or stable"; exit 2;; esac
30
+ dry=${DESKTOP_RELEASE_DRY_RUN:-}
31
+ bucket=${R2_BUCKET:-adea-releases}
32
+ say() { printf '%s\n' "$*"; }
33
+ sha256() { if command -v shasum >/dev/null; then shasum -a 256 "$1"; else sha256sum "$1"; fi | cut -d' ' -f1; }
34
+ b64d() { printf '%s' "$1" | base64 -d 2>/dev/null || printf '%s' "$1" | base64 -D; }
35
+
36
+ root=$(git rev-parse --show-toplevel)
37
+ cd "$root"
38
+ sha=${CI_COMMIT_SHA:-$(git rev-parse HEAD)}
39
+ [ "$sha" = "$(git rev-parse HEAD)" ] || { say "refusing: checkout is not at $sha"; exit 1; }
40
+ # Provenance is checked against origin/main with a credential-free origin (the framework records
41
+ # the GitLab project as owner/name). The runner sets its own fetch URL again for the next job.
42
+ if [ -n "${CI_PROJECT_URL:-}" ]; then git remote set-url origin "$CI_PROJECT_URL.git"; fi
43
+ git fetch --quiet origin "+refs/heads/main:refs/remotes/origin/main"
44
+ git merge-base --is-ancestor "$sha" refs/remotes/origin/main ||
45
+ { say "refusing: $sha is not on origin/main"; exit 1; }
46
+ [ -z "$(git status --porcelain=v1 --untracked-files=all)" ] || { git status --short; say "refusing: the checkout has changes"; exit 1; }
47
+ cd "${DESKTOP_RELEASE_APP_DIR:-.}"
48
+ # This framework release's CLIs, beside this script in the installed package.
49
+ framework=$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)
50
+ cli="$framework/dist/cli"
51
+ [ -f "$framework/dist/release/local-release.js" ] || { say "refusing: $framework has no built release CLIs"; exit 1; }
52
+ read -r repo feed_base < <(bun -e 'const c=require("./release-config.json");if(!c.releaseFeed)process.exit(1);console.log(c.releaseFeed.app, c.releaseFeed.base)') ||
53
+ { say "refusing: release-config.json has no releaseFeed"; exit 1; }
54
+ has_script() { bun -e 'process.exit(require("./package.json").scripts?.[process.argv[1]] ? 0 : 3)' "$1"; }
55
+
56
+ case "$(uname -s)/$(uname -m)" in
57
+ Darwin/arm64) platform=macos-arm64 ;;
58
+ Linux/x86_64) platform=linux-x64 ;;
59
+ *) say "refusing: no release platform for $(uname -s)/$(uname -m)"; exit 1 ;;
60
+ esac
61
+
62
+ # Fail before a long build, not at upload, when the runner cannot publish.
63
+ if [ -z "$dry" ]; then
64
+ command -v aws >/dev/null || { say "refusing: aws CLI is not on this runner's PATH"; exit 1; }
65
+ for v in R2_ACCESS_KEY_ID R2_SECRET_ACCESS_KEY; do
66
+ [ -n "${!v:-}" ] || { say "refusing: CI variable $v is not set"; exit 1; }
67
+ done
68
+ [ -n "${R2_ENDPOINT:-}${CLOUDFLARE_ACCOUNT_ID:-}" ] || { say "refusing: set R2_ENDPOINT or CLOUDFLARE_ACCOUNT_ID"; exit 1; }
69
+ fi
70
+
71
+ work=$(mktemp -d "${TMPDIR:-/tmp}/desktop-release-$repo-XXXX")
72
+ out="$work/out"
73
+ # Build tooling written for GitHub Actions (an app's Linux preflight, for example) expects a
74
+ # run-owned RUNNER_TEMP, which only Actions sets.
75
+ export RUNNER_TEMP="${RUNNER_TEMP:-$work/runner-temp}"
76
+ mkdir -p "$RUNNER_TEMP"
77
+
78
+ # The app's own files (installer scripts, add-ons) join the staged plan before it is uploaded.
79
+ extend_plan() { # <channel> <tag> <released sha>
80
+ if has_script release:extend-plan; then bun run release:extend-plan "$1" "$2" "$platform" "$out" "$3"
81
+ else rc=$?; [ "$rc" = 3 ] || exit "$rc"; fi
82
+ }
83
+
84
+ # Uploads the staged plan in order: immutable files first (an existing one must already hold the
85
+ # same bytes), channel pointers last, each verified by size after the upload.
86
+ upload() {
87
+ local plan="$out/upload-plan.json"
88
+ bun -e '
89
+ const plan = JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8"))
90
+ for (const o of plan.objects) console.log([o.key, o.size, o.sha256, o.contentType, o.cacheControl].join("\t"))' "$plan" > "$work/objects.tsv"
91
+ say "upload plan ($(wc -l < "$work/objects.tsv" | tr -d ' ') objects, in order) to s3://$bucket via R2 S3 API:"
92
+ cut -f1,2 "$work/objects.tsv" | sed 's/^/ /'
93
+ [ -z "$dry" ] || { say "dry run: nothing uploaded"; return 0; }
94
+ local endpoint=${R2_ENDPOINT:-https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com}
95
+ s3() { AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID" AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY" \
96
+ AWS_DEFAULT_REGION=auto AWS_REQUEST_CHECKSUM_CALCULATION=when_required \
97
+ aws s3api "$@" --bucket "$bucket" --endpoint-url "$endpoint" --output text; }
98
+ while IFS=$'\t' read -r key size digest type cache; do
99
+ file="$out/$key"
100
+ [ "$(wc -c < "$file" | tr -d ' ')" = "$size" ] && [ "$(sha256 "$file")" = "$digest" ] ||
101
+ { say "refusing: $key changed after staging"; exit 1; }
102
+ if [ "$cache" != no-cache ] && existing=$(s3 head-object --key "$key" --query ContentLength 2>/dev/null); then
103
+ [ "$existing" = "$size" ] || { say "refusing: immutable $key exists with other bytes"; exit 1; }
104
+ say " exists $key"; continue
105
+ fi
106
+ s3 put-object --key "$key" --body "$file" --content-type "$type" --cache-control "$cache" >/dev/null
107
+ [ "$(s3 head-object --key "$key" --query ContentLength)" = "$size" ] || { say "upload of $key did not verify"; exit 1; }
108
+ say " uploaded $key"
109
+ done < "$work/objects.tsv"
110
+ }
111
+
112
+ # Links every published file of <tag> on its GitLab release (creating the release when release
113
+ # tooling has not), pointing at the feed. Links that already exist are kept.
114
+ link_release() { # <tag>
115
+ [ -z "$dry" ] && [ -n "${CI_JOB_TOKEN:-}" ] && [ -n "${CI_API_V4_URL:-}" ] || { say "GitLab release links skipped"; return 0; }
116
+ bun -e '
117
+ const [api, project, token, tag, base, app, outDir] = process.argv.slice(1)
118
+ const fs = require("node:fs")
119
+ const release = JSON.parse(fs.readFileSync(`${outDir}/${app}/${tag}/release.json`, "utf8"))
120
+ const url = `${api}/projects/${project}/releases/${encodeURIComponent(tag)}`
121
+ const call = (method, path, body) => fetch(url + path, { method,
122
+ headers: { "JOB-TOKEN": token, "content-type": "application/json" },
123
+ body: body && JSON.stringify(body) })
124
+ let res = await call("GET", "")
125
+ if (res.status === 404) {
126
+ res = await fetch(`${api}/projects/${project}/releases`, { method: "POST",
127
+ headers: { "JOB-TOKEN": token, "content-type": "application/json" },
128
+ body: JSON.stringify({ tag_name: tag, name: tag, description: `Desktop release ${tag}.` }) })
129
+ if (!res.ok) throw new Error(`creating release ${tag}: ${res.status} ${await res.text()}`)
130
+ res = await call("GET", "")
131
+ }
132
+ if (!res.ok) throw new Error(`reading release ${tag}: ${res.status}`)
133
+ const have = new Set((await res.json()).assets.links.map((link) => link.name))
134
+ const files = [...release.assets.map((a) => a.name), "release.json"]
135
+ for (const name of files) {
136
+ if (have.has(name)) continue
137
+ const link = await call("POST", "/assets/links", { name, url: `${base}${app}/${tag}/${name}`,
138
+ link_type: /\.(json)$/.test(name) ? "other" : "package" })
139
+ if (!link.ok) throw new Error(`linking ${name}: ${link.status} ${await link.text()}`)
140
+ console.log(` linked ${name}`)
141
+ }' "$CI_API_V4_URL" "$CI_PROJECT_ID" "$CI_JOB_TOKEN" "$1" "$feed_base" "$repo" "$out"
142
+ }
143
+
144
+ if [ "$channel" = stable ]; then
145
+ result=$(bun "$cli/release-promote-cli.js" --local release-config.json "$out")
146
+ say "promotion: $result"
147
+ tag=$(printf '%s' "$result" | bun -e 'const r=JSON.parse(require("node:fs").readFileSync(0,"utf8"));console.log(r.status==="stable"?r.tag:"")')
148
+ [ -n "$tag" ] || { say "nothing to promote"; exit 0; }
149
+ released=$(bun -e 'const l=require(process.argv[1]);console.log(l.releases.find(r=>r.tag===process.argv[2]).sourceSha)' "$out/$repo/index.json" "$tag")
150
+ extend_plan stable "$tag" "$released"
151
+ upload
152
+ [ -n "$dry" ] || bun "$cli/release-finalize-cli.js" --local release-config.json "$tag"
153
+ exit 0
154
+ fi
155
+
156
+ [ -n "${CI_COMMIT_TAG:-}" ] || { say "refusing: a daily publishes only from a release tag pipeline"; exit 1; }
157
+ [ -n "${DESKTOP_UPDATE_SIGNING_KEY_B64:-}" ] || { say "refusing: DESKTOP_UPDATE_SIGNING_KEY_B64 is not set"; exit 1; }
158
+ key_id=$(bun -e 'const k=Object.keys(require("./release-config.json").releaseSigningKeys||{});if(k.length!==1)process.exit(1);console.log(k[0])') ||
159
+ { say "refusing: release-config.json must list exactly one releaseSigningKeys entry"; exit 1; }
160
+
161
+ cut=$(bun "$cli/release-cut-cli.js" --local daily release-config.json "$sha")
162
+ say "cut: $cut"
163
+ read -r tag status < <(printf '%s' "$cut" | bun -e 'const r=JSON.parse(require("node:fs").readFileSync(0,"utf8"));console.log(r.tag, r.status)')
164
+ [ "$tag" = "$CI_COMMIT_TAG" ] || { say "refusing: the daily at $sha is $tag, not the pipeline's tag $CI_COMMIT_TAG"; exit 1; }
165
+ if [ "$status" != dispatched ]; then
166
+ say "$tag already publishes $platform; nothing to build"
167
+ link_release "$tag"
168
+ exit 0
169
+ fi
170
+ say "desktop $repo $tag at $sha: building $platform; windows-x64 SKIPPED (no Windows runner)"
171
+
172
+ if has_script release:preflight; then bun run release:preflight "$tag" "$platform"
173
+ else rc=$?; [ "$rc" = 3 ] || exit "$rc"; fi
174
+
175
+ export RELEASE_TAG="$tag" SOURCE_SHA="$sha" ADEA_APP_RELEASE_VERSION="${tag#v}"
176
+ staged="$work/staged"
177
+ if [ -n "$dry" ]; then say "dry run: would build, sign, stage and upload $tag for $platform"; exit 0; fi
178
+ bun run build:release
179
+ bun run release:stage-build "$platform" "$staged"
180
+ bun run release:inspect --local "$platform" "$staged"
181
+ # The private key reaches only the signing process, through its environment.
182
+ ADEA_RELEASE_SIGNING_KEY="$(b64d "$DESKTOP_UPDATE_SIGNING_KEY_B64")" ADEA_RELEASE_SIGNING_KEY_ID="$key_id" \
183
+ RELEASE_RUN_ID="${CI_PIPELINE_ID:-$(date -u +%Y%m%d%H%M%S)}" \
184
+ bun "$cli/release-descriptor-staging-cli.js" --local "$staged" release-config.json
185
+ bun "$cli/release-publish-cli.js" --local "$staged" release-config.json "$out"
186
+ # Command artifacts (an app's CLI) ride the same release: their archive and cli-daily/stable
187
+ # descriptors must be in the plan before anything is uploaded.
188
+ bun -e '
189
+ const [plan, cfg, app, tag, platform] = process.argv.slice(1)
190
+ const keys = new Set(JSON.parse(require("node:fs").readFileSync(plan, "utf8")).objects.map((o) => o.key))
191
+ const config = require(cfg), channels = ["daily", "stable"]
192
+ const missing = Object.values(config.commandArtifacts ?? {}).flatMap((artifact) => [
193
+ artifact.platforms[platform].replace("{tag}", tag),
194
+ ...channels.flatMap((channel) => config[`${channel}DiscoveryAssets`].filter((name) =>
195
+ config.descriptors[name].allowedPayloads.includes(artifact.platforms[platform]))),
196
+ ]).filter((name) => !keys.has(`${app}/${tag}/${name}`))
197
+ if (missing.length) { console.error("command artifacts missing from the plan: " + missing.join(", ")); process.exit(1) }' \
198
+ "$out/upload-plan.json" "$PWD/release-config.json" "$repo" "$tag" "$platform"
199
+ extend_plan daily "$tag" "$sha"
200
+ upload
201
+ verified=$(bun "$cli/release-finalize-cli.js" --local release-config.json "$tag")
202
+ say "verified from the feed: $verified"
203
+ link_release "$tag"
@@ -13,6 +13,8 @@ export declare function createApplication(options: {
13
13
  renderer?: DesktopRenderer;
14
14
  /** Runner tags required by the generated GitLab validation job. */
15
15
  gitlabRunnerTags?: readonly string[];
16
+ /** Runner tags of the generated GitLab desktop release jobs: a runner of the platform to build. */
17
+ gitlabReleaseRunnerTags?: readonly string[];
16
18
  }, dependencies?: {
17
19
  templateDirectory?: string;
18
20
  /** Synchronize publish races in tests; app creation does not need this hook. */
@@ -49,6 +49,10 @@ async function removeOwnedStaging(staging, identity, remove) {
49
49
  if (!info.isDirectory() || info.dev !== identity.dev || info.ino !== identity.ino) throw new Error("Application staging directory was replaced; it was not removed");
50
50
  await remove(staging);
51
51
  }
52
+ /** A GitLab job's `tags:` block, or nothing for an untagged runner. */
53
+ function runnerTagLines(tags) {
54
+ return tags.length ? ` tags:\n${tags.map((tag) => ` - ${JSON.stringify(tag)}\n`).join("")}` : "";
55
+ }
52
56
  /** Generate a new app without replacing an existing directory. */
53
57
  async function createApplication(options, dependencies = {}) {
54
58
  if (typeof options.directory !== "string" || !options.directory.trim() || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(options.slug) || options.slug.length > 64 || typeof options.name !== "string" || !options.name.trim() || options.name.length > 80 || containsAsciiControl(options.name) || !/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*){1,}$/.test(options.identifier) || typeof options.frameworkSpecifier !== "string" || !options.frameworkSpecifier.trim()) throw new Error("Invalid application identity or framework dependency");
@@ -77,7 +81,8 @@ async function createApplication(options, dependencies = {}) {
77
81
  }
78
82
  const renderer = createRendererProfile(options.renderer).renderer;
79
83
  const runnerTags = options.gitlabRunnerTags ?? [];
80
- if (!Array.isArray(runnerTags) || runnerTags.length > 49 || runnerTags.some((tag) => typeof tag !== "string" || !/^[A-Za-z0-9_.-]{1,128}$/.test(tag)) || new Set(runnerTags).size !== runnerTags.length) throw new Error("Invalid GitLab runner tags");
84
+ const releaseRunnerTags = options.gitlabReleaseRunnerTags ?? [];
85
+ for (const tags of [runnerTags, releaseRunnerTags]) if (!Array.isArray(tags) || tags.length > 49 || tags.some((tag) => typeof tag !== "string" || !/^[A-Za-z0-9_.-]{1,128}$/.test(tag)) || new Set(tags).size !== tags.length) throw new Error("Invalid GitLab runner tags");
81
86
  const frameworkManifest = JSON.parse(await readFile(resolve(import.meta.dir, "../../package.json"), "utf8"));
82
87
  const uiVersion = frameworkManifest.devDependencies?.["@adea-ai/ui"];
83
88
  if (typeof uiVersion !== "string" || !/^\d+\.\d+\.\d+$/.test(uiVersion)) throw new Error("Framework UI version is unavailable");
@@ -103,10 +108,19 @@ async function createApplication(options, dependencies = {}) {
103
108
  errorOnExist: true,
104
109
  force: false
105
110
  });
106
- const gitlabPath = resolve(staging, ".gitlab-ci.yml");
107
- const gitlabTemplate = await readFile(gitlabPath, "utf8");
108
- const tags = runnerTags.length ? ` tags:\n${runnerTags.map((tag) => ` - ${JSON.stringify(tag)}\n`).join("")}` : "";
109
- await writeFile(gitlabPath, gitlabTemplate.replace(" # {{GITLAB_RUNNER_TAGS}}\n", tags));
111
+ for (const [file, marker, tags] of [[
112
+ ".gitlab-ci.yml",
113
+ "GITLAB_RUNNER_TAGS",
114
+ runnerTags
115
+ ], [
116
+ ".gitlab/desktop-release.yml",
117
+ "GITLAB_RELEASE_RUNNER_TAGS",
118
+ releaseRunnerTags
119
+ ]]) {
120
+ const path = resolve(staging, file);
121
+ const content = await readFile(path, "utf8");
122
+ await writeFile(path, content.replace(` # {{${marker}}}\n`, runnerTagLines(tags)));
123
+ }
110
124
  for (const name of [
111
125
  "release.yml",
112
126
  "release-assets.yml",
@@ -2,7 +2,7 @@
2
2
  import { createApplication } from "../app/create-application.js";
3
3
  import { runCli } from "./cli-runner.js";
4
4
  // src/cli/create-application-cli.ts
5
- var usage = "Usage: create-adea-app --directory PATH --slug SLUG --name NAME --identifier REVERSE_DNS --source-url HTTPS_URL --framework SPECIFIER [--repository OWNER/NAME] [--renderer native|cef] [--gitlab-runner-tags TAG,TAG]";
5
+ var usage = "Usage: create-adea-app --directory PATH --slug SLUG --name NAME --identifier REVERSE_DNS --source-url HTTPS_URL --framework SPECIFIER [--repository OWNER/NAME] [--renderer native|cef] [--gitlab-runner-tags TAG,TAG] [--gitlab-release-runner-tags TAG,TAG]";
6
6
  var allowed = /* @__PURE__ */ new Set([
7
7
  "directory",
8
8
  "slug",
@@ -12,7 +12,8 @@ var allowed = /* @__PURE__ */ new Set([
12
12
  "framework",
13
13
  "repository",
14
14
  "renderer",
15
- "gitlab-runner-tags"
15
+ "gitlab-runner-tags",
16
+ "gitlab-release-runner-tags"
16
17
  ]);
17
18
  await runCli((error) => error instanceof Error ? error.message : "Could not create application", async () => {
18
19
  const args = process.argv.slice(2);
@@ -27,7 +28,7 @@ await runCli((error) => error instanceof Error ? error.message : "Could not crea
27
28
  if (!allowed.has(key) || values[key] !== void 0 || !value || value.startsWith("--")) throw new Error(usage);
28
29
  values[key] = value;
29
30
  }
30
- const { directory, slug, name, identifier, "source-url": sourceUrl, framework, repository, renderer, "gitlab-runner-tags": gitlabRunnerTags } = values;
31
+ const { directory, slug, name, identifier, "source-url": sourceUrl, framework, repository, renderer, "gitlab-runner-tags": gitlabRunnerTags, "gitlab-release-runner-tags": gitlabReleaseRunnerTags } = values;
31
32
  if (!directory || !slug || !name || !identifier || !sourceUrl || !framework || renderer && renderer !== "native" && renderer !== "cef") throw new Error(usage);
32
33
  const result = await createApplication({
33
34
  directory,
@@ -38,7 +39,8 @@ await runCli((error) => error instanceof Error ? error.message : "Could not crea
38
39
  repository,
39
40
  frameworkSpecifier: framework,
40
41
  renderer,
41
- gitlabRunnerTags: gitlabRunnerTags?.split(",").map((tag) => tag.trim())
42
+ gitlabRunnerTags: gitlabRunnerTags?.split(",").map((tag) => tag.trim()),
43
+ gitlabReleaseRunnerTags: gitlabReleaseRunnerTags?.split(",").map((tag) => tag.trim())
42
44
  });
43
45
  console.log(`Created application at ${result.directory}`);
44
46
  });
@@ -1 +1 @@
1
- {"version":"0.33.1","commit":"fdc518d937394cc69f360277a52a0ac578f401fe"}
1
+ {"version":"0.34.0","commit":"11d5efa8628889b5266a4283e754bb7641d3114f"}
@@ -1,7 +1,7 @@
1
1
  import { isGitSha } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
3
  import { isRepositorySlug } from "../updates/signed-release.js";
4
- import { parseReleaseConfig } from "./release-config.js";
4
+ import { hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
5
5
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
6
6
  // src/release/release-assets-plan.ts
7
7
  /** GitHub reads need credentials but must not inherit release signing keys. */
@@ -37,7 +37,9 @@ async function planReleaseAssets(options) {
37
37
  const { env, config, tag } = options;
38
38
  if (env.GITHUB_ACTIONS !== "true" || env.GITHUB_REF !== "refs/heads/main" || env.GITHUB_EVENT_NAME !== "workflow_dispatch" || !isRepositorySlug(env.GITHUB_REPOSITORY ?? "") || !isGitSha(env.GITHUB_SHA) || !/^[1-9]\d{0,19}$/.test(env.GITHUB_RUN_ID ?? "") || !/^[1-9]\d{0,8}$/.test(env.GITHUB_RUN_ATTEMPT ?? "") || !/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65) throw new Error("Asset planning requires a trusted main workflow and valid tag");
39
39
  if (typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string") throw new Error("Invalid release configuration");
40
- const { requirements, releasePleaseManifestPath, releaseWorkflows } = parseReleaseConfig(config);
40
+ const parsed = parseReleaseConfig(config);
41
+ const { requirements, releasePleaseManifestPath } = parsed;
42
+ const releaseWorkflows = hostedReleaseWorkflows(parsed.releaseWorkflows);
41
43
  requirements(tag);
42
44
  const run = options.run ?? githubCli(releasePlanGitHubEnvironment(env));
43
45
  const repository = env.GITHUB_REPOSITORY, workflowSha = env.GITHUB_SHA;
@@ -34,6 +34,11 @@ export type ReleaseWorkflows = {
34
34
  control: string;
35
35
  assets: string;
36
36
  };
37
+ /**
38
+ * The caller workflows a GitHub-hosted release step verifies its run against. An app that releases
39
+ * only with the local release mode (a GitLab tag pipeline or a machine) names none.
40
+ */
41
+ export declare function hostedReleaseWorkflows(workflows: ReleaseWorkflows | undefined): ReleaseWorkflows;
37
42
  /** The file name GitHub's workflow APIs and `gh workflow run` address a workflow by. */
38
43
  export declare const workflowFile: (path: string) => string;
39
44
  /** Validate shared daily, dev and stable asset requirements. */
@@ -47,7 +52,8 @@ export declare function parseReleaseConfig(config: unknown): {
47
52
  releasePleaseManifestPath: string;
48
53
  /** Sidecar executables every packaged payload must contain. */
49
54
  sidecars: readonly string[];
50
- releaseWorkflows: ReleaseWorkflows;
55
+ /** GitHub Actions callers, when the app releases there; see `hostedReleaseWorkflows`. */
56
+ releaseWorkflows: ReleaseWorkflows | undefined;
51
57
  /** The HTTPS feed releases are published to and discovered from. */
52
58
  feed: ReleaseFeed;
53
59
  commandArtifacts: readonly CommandArtifactPolicy[];
@@ -38,6 +38,14 @@ function parseCommandArtifacts(value, platforms) {
38
38
  });
39
39
  }
40
40
  var workflowDirectory = ".github/workflows/";
41
+ /**
42
+ * The caller workflows a GitHub-hosted release step verifies its run against. An app that releases
43
+ * only with the local release mode (a GitLab tag pipeline or a machine) names none.
44
+ */
45
+ function hostedReleaseWorkflows(workflows) {
46
+ if (!workflows) throw new Error("Release configuration names no releaseWorkflows; release with --local");
47
+ return workflows;
48
+ }
41
49
  /** The file name GitHub's workflow APIs and `gh workflow run` address a workflow by. */
42
50
  var workflowFile = (path) => path.slice(18);
43
51
  var workflowPath = (value) => typeof value === "string" && value.length <= 200 && value.startsWith(workflowDirectory) && /^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(workflowFile(value));
@@ -45,11 +53,14 @@ var workflowPath = (value) => typeof value === "string" && value.length <= 200 &
45
53
  function parseReleaseConfig(config) {
46
54
  if (!isRecord(config) || !isRecord(config.platforms) || !strings(config.releaseAssets) || !strings(config.dailyDiscoveryAssets) || !strings(config.stableDiscoveryAssets) || !strings(config.devDiscoveryAssets) || !Number.isSafeInteger(config.soakHours) || Number(config.soakHours) < 0 || Number(config.soakHours) > 8760) throw new Error("Invalid release configuration");
47
55
  const workflows = config.releaseWorkflows;
48
- if (!isRecord(workflows) || Object.keys(workflows).length !== 2 || !workflowPath(workflows.control) || !workflowPath(workflows.assets) || workflows.control === workflows.assets) throw new Error("Invalid release workflows");
49
- const releaseWorkflows = {
50
- control: workflows.control,
51
- assets: workflows.assets
52
- };
56
+ let releaseWorkflows;
57
+ if (workflows !== void 0) {
58
+ if (!isRecord(workflows) || Object.keys(workflows).length !== 2 || !workflowPath(workflows.control) || !workflowPath(workflows.assets) || workflows.control === workflows.assets) throw new Error("Invalid release workflows");
59
+ releaseWorkflows = {
60
+ control: workflows.control,
61
+ assets: workflows.assets
62
+ };
63
+ }
53
64
  const feed = parseReleaseFeed(config.releaseFeed);
54
65
  let sidecars;
55
66
  try {
@@ -195,4 +206,4 @@ function discoveryPolicies(config, tag) {
195
206
  }
196
207
  return result;
197
208
  }
198
- export { discoveryPolicies, parseHistoryRewrite, parseReleaseConfig, platformPayloads, platformTargets, releaseAssetNames, workflowFile };
209
+ export { discoveryPolicies, hostedReleaseWorkflows, parseHistoryRewrite, parseReleaseConfig, platformPayloads, platformTargets, releaseAssetNames, workflowFile };
@@ -1,6 +1,6 @@
1
1
  import { isGitSha } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
- import { parseReleaseConfig, workflowFile } from "./release-config.js";
3
+ import { hostedReleaseWorkflows, parseReleaseConfig, workflowFile } from "./release-config.js";
4
4
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
5
5
  import { cutRelease } from "./release-cut.js";
6
6
  import { readSourceVersion } from "./local-provenance.js";
@@ -12,7 +12,9 @@ var execute = promisify(execFile);
12
12
  async function runReleaseCutCommand(options) {
13
13
  const { env, kind } = options;
14
14
  if (env.GITHUB_ACTIONS !== "true" || env.GITHUB_REF !== "refs/heads/main" || !env.GITHUB_REPOSITORY || !isGitSha(env.GITHUB_SHA) || !/^[1-9]\d{0,19}$/.test(env.GITHUB_RUN_ID ?? "") || !/^[1-9]\d{0,8}$/.test(env.GITHUB_RUN_ATTEMPT ?? "") || (kind === "daily" ? !["schedule", "workflow_dispatch"].includes(env.GITHUB_EVENT_NAME ?? "") : kind === "dev" ? !["push", "workflow_dispatch"].includes(env.GITHUB_EVENT_NAME ?? "") : true)) throw new Error("Release cut requires a trusted main workflow");
15
- const { requirements, versionSource, releasePleaseManifestPath, releaseWorkflows } = parseReleaseConfig(options.config);
15
+ const parsed = parseReleaseConfig(options.config);
16
+ const { requirements, versionSource, releasePleaseManifestPath } = parsed;
17
+ const releaseWorkflows = hostedReleaseWorkflows(parsed.releaseWorkflows);
16
18
  const run = options.run ?? githubCli();
17
19
  const git = options.git ?? (async (args) => (await execute("git", args, { maxBuffer: 1048576 })).stdout.trim());
18
20
  const repository = env.GITHUB_REPOSITORY;
@@ -3,7 +3,7 @@ import { githubCli } from "./github-cli.js";
3
3
  import { lookupRelease } from "./github-release-lookup.js";
4
4
  import { isRepositorySlug } from "../updates/signed-release.js";
5
5
  import { qualifyGitHubRelease } from "./github-release-qualification.js";
6
- import { parseReleaseConfig } from "./release-config.js";
6
+ import { hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
7
7
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
8
8
  // src/release/release-finalize.ts
9
9
  /** Treat event payloads as hints; qualification independently checks the GitHub run. */
@@ -43,7 +43,7 @@ async function finalizeReleasePleaseDraft(options) {
43
43
  repository,
44
44
  appName: config.appName,
45
45
  requirements: parsed.requirements,
46
- assetsWorkflow: parsed.releaseWorkflows.assets,
46
+ assetsWorkflow: hostedReleaseWorkflows(parsed.releaseWorkflows).assets,
47
47
  releasePleaseManifestPath: parsed.releasePleaseManifestPath,
48
48
  run
49
49
  });
@@ -62,7 +62,7 @@ async function finalizeReleasePleaseDraft(options) {
62
62
  repository,
63
63
  tag,
64
64
  requirements,
65
- assetsWorkflow: parsed.releaseWorkflows.assets,
65
+ assetsWorkflow: hostedReleaseWorkflows(parsed.releaseWorkflows).assets,
66
66
  releasePleaseManifestPath: parsed.releasePleaseManifestPath,
67
67
  allowDraft: true,
68
68
  run
@@ -1,4 +1,4 @@
1
- import { parseReleaseConfig } from "./release-config.js";
1
+ import { hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
2
2
  import { promoteDailyRelease } from "./release-promotion.js";
3
3
  import { createGitHubPromotionProvider } from "./github-release-promotion.js";
4
4
  // src/release/release-promotion-command.ts
@@ -14,7 +14,7 @@ async function runPromotionCommand(options) {
14
14
  const provider = createGitHubPromotionProvider({
15
15
  repository: env.GITHUB_REPOSITORY,
16
16
  requirements,
17
- assetsWorkflow: releaseWorkflows.assets,
17
+ assetsWorkflow: hostedReleaseWorkflows(releaseWorkflows).assets,
18
18
  releasePleaseManifestPath,
19
19
  run: options.run
20
20
  });
@@ -2,7 +2,7 @@ import { isGitSha, isRecord } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
3
  import { assertRepositorySlug } from "../updates/signed-release.js";
4
4
  import { feedUrl } from "../updates/release-feed.js";
5
- import { discoveryPolicies, parseReleaseConfig } from "./release-config.js";
5
+ import { discoveryPolicies, hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
6
6
  import { publishQualifiedRelease } from "./release-publication.js";
7
7
  import { commandReceiptName } from "../installer/command-qualification-command.js";
8
8
  import { createGitHubReleasePublisher } from "./github-release-publisher.js";
@@ -66,7 +66,7 @@ async function runReleasePublishCommand(options) {
66
66
  expected: {
67
67
  headSha: env.GITHUB_SHA,
68
68
  event: "workflow_dispatch",
69
- path: releaseWorkflows.assets
69
+ path: hostedReleaseWorkflows(releaseWorkflows).assets
70
70
  },
71
71
  mismatch: "Release-assets workflow provenance mismatch"
72
72
  });
@@ -1,7 +1,7 @@
1
1
  import { isGitSha, isRecord } from "../app/value-guards.js";
2
2
  import { githubCli } from "./github-cli.js";
3
3
  import { lookupRelease } from "./github-release-lookup.js";
4
- import { parseReleaseConfig, platformPayloads, workflowFile } from "./release-config.js";
4
+ import { hostedReleaseWorkflows, parseReleaseConfig, platformPayloads, workflowFile } from "./release-config.js";
5
5
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
6
6
  import { planReleaseAssets, releasePlanGitHubEnvironment } from "./release-assets-plan.js";
7
7
  // src/release/retained-release-build.ts
@@ -27,7 +27,7 @@ async function selectRetainedReleaseBuild(options) {
27
27
  run
28
28
  });
29
29
  if (env.SOURCE_SHA !== plan.sourceSha) throw new Error("Retained build source mismatch");
30
- const parsed = parseReleaseConfig(config), assetsWorkflow = parsed.releaseWorkflows.assets, requirements = parsed.requirements(tag);
30
+ const parsed = parseReleaseConfig(config), assetsWorkflow = hostedReleaseWorkflows(parsed.releaseWorkflows).assets, requirements = parsed.requirements(tag);
31
31
  if (requirements.platforms[platform]?.length !== 2) throw new Error("Invalid platform requirements");
32
32
  const expected = platformPayloads(requirements, platform);
33
33
  const repository = env.GITHUB_REPOSITORY, base = `repos/${repository}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/app-framework",
3
- "version": "0.33.1",
3
+ "version": "0.34.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@
9
9
  "bin": {
10
10
  "adea-cef-helper": "./dist/cli/cef-helper-cli.js",
11
11
  "adea-cut-release": "./dist/cli/release-cut-cli.js",
12
+ "adea-desktop-release": "./ci/desktop-release.sh",
12
13
  "adea-finalize-release": "./dist/cli/release-finalize-cli.js",
13
14
  "adea-patch-electrobun-shortcuts": "./dist/cli/electrobun-shortcut-patch-cli.js",
14
15
  "adea-patch-windows-runtime": "./dist/cli/windows-runtime-patch-cli.js",
@@ -24,6 +25,7 @@
24
25
  "create-adea-app": "./dist/cli/create-application-cli.js"
25
26
  },
26
27
  "files": [
28
+ "ci/desktop-release.sh",
27
29
  "dist",
28
30
  "src/app/application.tsx",
29
31
  "src/appearance",
@@ -0,0 +1,42 @@
1
+ # Desktop releases from release tag pipelines (`adea-desktop-release`, from @adea-ai/app-framework).
2
+ # A `v<version>` tag on main (from Release Please) builds this runner's platform, signs the channel
3
+ # descriptors, publishes the release to `releaseFeed` and links the files on the GitLab release,
4
+ # then promotes the newest qualified daily to stable once its soak has passed.
5
+ #
6
+ # The runner needs bun, git and the aws CLI, and builds the platform it runs on: a macOS arm64
7
+ # shell runner builds macos-arm64, a Linux x64 runner linux-x64. Platforms without a runner are
8
+ # not published.
9
+ #
10
+ # Protected project variables (Settings > CI/CD > Variables), with protected `v*` tags:
11
+ # DESKTOP_RELEASE_ENABLED=true turns the jobs on (unset: tag pipelines publish nothing)
12
+ # DESKTOP_UPDATE_SIGNING_KEY_B64 masked, hidden: base64 of the Ed25519 update key PEM whose
13
+ # public key is in release-config.json releaseSigningKeys
14
+ # R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, and CLOUDFLARE_ACCOUNT_ID or R2_ENDPOINT masked
15
+ # R2_BUCKET the feed's bucket (default adea-releases)
16
+ # STABLE_PROMOTION_HELD=true holds stable promotion
17
+
18
+ .desktop-release:
19
+ stage: deploy
20
+ interruptible: false
21
+ # One release job at a time: a daily and a promotion never race on the feed.
22
+ resource_group: desktop-release
23
+ timeout: 90m
24
+ # {{GITLAB_RELEASE_RUNNER_TAGS}}
25
+ rules:
26
+ - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/ && $DESKTOP_RELEASE_ENABLED == "true"
27
+ before_script:
28
+ - bun install --frozen-lockfile
29
+
30
+ desktop-daily:
31
+ extends: .desktop-release
32
+ script:
33
+ - bun run adea-desktop-release daily
34
+
35
+ desktop-stable:
36
+ extends: .desktop-release
37
+ timeout: 20m
38
+ needs: [desktop-daily]
39
+ rules:
40
+ - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/ && $DESKTOP_RELEASE_ENABLED == "true" && $STABLE_PROMOTION_HELD != "true"
41
+ script:
42
+ - bun run adea-desktop-release stable
@@ -2,14 +2,23 @@ image:
2
2
  name: oven/bun:1.4.4
3
3
  entrypoint: ['']
4
4
 
5
+ include:
6
+ - local: .gitlab/desktop-release.yml
7
+
5
8
  workflow:
6
9
  rules:
7
10
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
8
11
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
12
+ # Release tags run only the desktop release jobs (.gitlab/desktop-release.yml).
13
+ - if: $CI_COMMIT_TAG
9
14
 
10
15
  validate:
11
16
  timeout: 20m
12
17
  # {{GITLAB_RUNNER_TAGS}}
18
+ rules:
19
+ - if: $CI_COMMIT_TAG
20
+ when: never
21
+ - when: on_success
13
22
  script:
14
23
  - bun install --frozen-lockfile
15
24
  - bun run format:check
@@ -9,9 +9,20 @@ with the same checks as the GitHub validation workflow. Commit `bun.lock`
9
9
  before running it. It uses an untagged Docker runner by default; if your GitLab
10
10
  runner requires tags, supply `--gitlab-runner-tags tag1,tag2` when generating
11
11
  the app or add the tags to the job afterward. The runner must have access to
12
- the package registry. This is validation only: the generated release workflows
13
- and release tooling below still require GitHub Actions and have not been migrated
14
- to GitLab.
12
+ the package registry.
13
+
14
+ `.gitlab/desktop-release.yml` publishes desktop releases from GitLab: a
15
+ `v<version>` tag on main (from Release Please) runs `adea-desktop-release`,
16
+ which builds the release runner's platform, signs the channel descriptors,
17
+ uploads the release to `releaseFeed` and links its files on the GitLab release,
18
+ then promotes the newest qualified daily to stable after `soakHours`. The release
19
+ runner needs bun, git and the aws CLI; pass its tags with
20
+ `--gitlab-release-runner-tags` (a macOS arm64 shell runner builds `macos-arm64`).
21
+ It stays off until the project sets the protected variable
22
+ `DESKTOP_RELEASE_ENABLED=true`, protects `v*` tags and adds the protected,
23
+ masked `DESKTOP_UPDATE_SIGNING_KEY_B64` (base64 of the private key PEM) and
24
+ bucket credentials listed in that file. A GitLab-only app may remove the
25
+ `.github` workflows and `releaseWorkflows` from `release-config.json`.
15
26
 
16
27
  The generated release control workflow uses `release-config.json` for daily,
17
28
  dev and stable channels. Run `bun install` and commit `bun.lock` before