@adea-ai/app-framework 0.38.1 → 0.39.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/ci/desktop-release.sh +34 -10
- package/dist/framework-source.json +1 -1
- package/package.json +1 -1
package/ci/desktop-release.sh
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# adea-desktop-release: publish a desktop release from a
|
|
3
|
-
# framework's local release mode. It builds this machine's platform (macOS arm64 or Linux x64),
|
|
2
|
+
# adea-desktop-release: publish a desktop release from a release tag pipeline (GitLab CI, CircleCI or
|
|
3
|
+
# GitHub Actions) with the framework's local release mode. It builds this machine's platform (macOS arm64 or Linux x64),
|
|
4
4
|
# signs the channel descriptors, uploads the staged tree to the app's release feed (an
|
|
5
5
|
# S3-compatible bucket such as Cloudflare R2) in plan order with the channel pointers last,
|
|
6
6
|
# verifies the feed and links every published file on the GitLab release.
|
|
@@ -17,12 +17,17 @@
|
|
|
17
17
|
# release:extend-plan <channel> <tag> <platform> <out> <source-sha>
|
|
18
18
|
# adds app files to the staged plan
|
|
19
19
|
#
|
|
20
|
-
#
|
|
20
|
+
# The tag, commit and run id come from GitLab's CI variables, else CircleCI's or GitHub Actions'.
|
|
21
|
+
#
|
|
22
|
+
# Environment (protected CI variables or contexts):
|
|
21
23
|
# DESKTOP_RELEASE_APP_DIR the app directory, relative to the repository (default .)
|
|
22
24
|
# DESKTOP_UPDATE_SIGNING_KEY_B64 base64 of the Ed25519 update key PEM (daily; refused when missing)
|
|
23
25
|
# R2_ENDPOINT or CLOUDFLARE_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY bucket credentials
|
|
24
26
|
# R2_BUCKET (default adea-releases), STABLE_PROMOTION_HELD (true holds promotion)
|
|
25
27
|
# DESKTOP_RELEASE_DRY_RUN=1 cut and plan only: builds, signs and uploads nothing
|
|
28
|
+
# GITLAB_RELEASE_TOKEN links the files on the GitLab release outside GitLab CI (which
|
|
29
|
+
# uses CI_JOB_TOKEN); GITLAB_PROJECT overrides the project path
|
|
30
|
+
# taken from the origin remote
|
|
26
31
|
# The update key is decoded into the signing process's environment only, never to disk.
|
|
27
32
|
set -euo pipefail
|
|
28
33
|
channel=${1:?daily|stable}
|
|
@@ -30,12 +35,19 @@ case "$channel" in daily|stable) ;; *) echo "channel must be daily or stable"; e
|
|
|
30
35
|
dry=${DESKTOP_RELEASE_DRY_RUN:-}
|
|
31
36
|
bucket=${R2_BUCKET:-adea-releases}
|
|
32
37
|
say() { printf '%s\n' "$*"; }
|
|
38
|
+
if [ -z "${CI_COMMIT_TAG:-}" ]; then
|
|
39
|
+
CI_COMMIT_TAG=${CIRCLE_TAG:-}
|
|
40
|
+
[ -n "$CI_COMMIT_TAG" ] || [ "${GITHUB_REF_TYPE:-}" != tag ] || CI_COMMIT_TAG=${GITHUB_REF_NAME:-}
|
|
41
|
+
fi
|
|
42
|
+
CI_COMMIT_SHA=${CI_COMMIT_SHA:-${CIRCLE_SHA1:-${GITHUB_SHA:-}}}
|
|
43
|
+
CI_PIPELINE_ID=${CI_PIPELINE_ID:-${CIRCLE_WORKFLOW_ID:-${GITHUB_RUN_ID:-}}}
|
|
33
44
|
sha256() { if command -v shasum >/dev/null; then shasum -a 256 "$1"; else sha256sum "$1"; fi | cut -d' ' -f1; }
|
|
34
45
|
b64d() { printf '%s' "$1" | base64 -d 2>/dev/null || printf '%s' "$1" | base64 -D; }
|
|
35
46
|
|
|
36
47
|
root=$(git rev-parse --show-toplevel)
|
|
37
48
|
cd "$root"
|
|
38
|
-
sha=${CI_COMMIT_SHA
|
|
49
|
+
sha=${CI_COMMIT_SHA:-}
|
|
50
|
+
[ -n "$sha" ] || sha=$(git rev-parse HEAD)
|
|
39
51
|
[ "$sha" = "$(git rev-parse HEAD)" ] || { say "refusing: checkout is not at $sha"; exit 1; }
|
|
40
52
|
# Provenance is checked against origin/main of this project (the framework records the GitLab
|
|
41
53
|
# project as owner/name). The runner's insteadOf rewrite can still put its job token into
|
|
@@ -113,19 +125,31 @@ upload() {
|
|
|
113
125
|
# Links every published file of <tag> on its GitLab release (creating the release when release
|
|
114
126
|
# tooling has not), pointing at the feed. Links that already exist are kept.
|
|
115
127
|
link_release() { # <tag>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
local header= token= project=${CI_PROJECT_ID:-}
|
|
129
|
+
if [ -n "${CI_JOB_TOKEN:-}" ]; then header=JOB-TOKEN token=$CI_JOB_TOKEN
|
|
130
|
+
elif [ -n "${GITLAB_RELEASE_TOKEN:-}" ]; then header=PRIVATE-TOKEN token=$GITLAB_RELEASE_TOKEN; fi
|
|
131
|
+
[ -z "$dry" ] && [ -n "$header" ] || { say "GitLab release links skipped"; return 0; }
|
|
132
|
+
if [ -z "$project" ]; then
|
|
133
|
+
# The origin remote's path (https://host/<path>.git or git@host:<path>.git), URL-encoded.
|
|
134
|
+
project=${GITLAB_PROJECT:-$(git -C "$root" remote get-url origin)}
|
|
135
|
+
project=${project%.git}
|
|
136
|
+
case "$project" in git@*:*) project=${project#*:} ;; *://*) project=${project#*://}; project=${project#*/} ;; esac
|
|
137
|
+
project=${project//\//%2F}
|
|
138
|
+
fi
|
|
139
|
+
# The token reaches bun through its environment, never its arguments.
|
|
140
|
+
LINK_TOKEN="$token" LINK_HEADER="$header" bun -e '
|
|
141
|
+
const [api, project, tag, base, app, outDir] = process.argv.slice(1)
|
|
142
|
+
const auth = { [process.env.LINK_HEADER]: process.env.LINK_TOKEN }
|
|
119
143
|
const fs = require("node:fs")
|
|
120
144
|
const release = JSON.parse(fs.readFileSync(`${outDir}/${app}/${tag}/release.json`, "utf8"))
|
|
121
145
|
const url = `${api}/projects/${project}/releases/${encodeURIComponent(tag)}`
|
|
122
146
|
const call = (method, path, body) => fetch(url + path, { method,
|
|
123
|
-
headers: {
|
|
147
|
+
headers: { ...auth, "content-type": "application/json" },
|
|
124
148
|
body: body && JSON.stringify(body) })
|
|
125
149
|
let res = await call("GET", "")
|
|
126
150
|
if (res.status === 404) {
|
|
127
151
|
res = await fetch(`${api}/projects/${project}/releases`, { method: "POST",
|
|
128
|
-
headers: {
|
|
152
|
+
headers: { ...auth, "content-type": "application/json" },
|
|
129
153
|
body: JSON.stringify({ tag_name: tag, name: tag, description: `Desktop release ${tag}.` }) })
|
|
130
154
|
if (!res.ok) throw new Error(`creating release ${tag}: ${res.status} ${await res.text()}`)
|
|
131
155
|
res = await call("GET", "")
|
|
@@ -139,7 +163,7 @@ link_release() { # <tag>
|
|
|
139
163
|
link_type: /\.(json)$/.test(name) ? "other" : "package" })
|
|
140
164
|
if (!link.ok) throw new Error(`linking ${name}: ${link.status} ${await link.text()}`)
|
|
141
165
|
console.log(` linked ${name}`)
|
|
142
|
-
}' "$CI_API_V4_URL" "$
|
|
166
|
+
}' "${CI_API_V4_URL:-https://gitlab.com/api/v4}" "$project" "$1" "$feed_base" "$repo" "$out"
|
|
143
167
|
}
|
|
144
168
|
|
|
145
169
|
if [ "$channel" = stable ]; then
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.39.0","commit":"a96af4fbc2012cc05a0fa1cfed906934dfdc7ac5"}
|