@adea-ai/app-framework 0.39.0 → 0.39.1
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-feed.sh +100 -0
- package/ci/desktop-release.sh +13 -33
- package/dist/framework-source.json +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# shellcheck shell=bash
|
|
2
|
+
# Release-feed steps (an S3-compatible bucket such as Cloudflare R2) of adea-desktop-release,
|
|
3
|
+
# sourced by ci/desktop-release.sh and by its tests. The caller defines `say` and `sha256` and sets
|
|
4
|
+
# bucket, work, out and dry, plus R2_ENDPOINT or CLOUDFLARE_ACCOUNT_ID, R2_ACCESS_KEY_ID and
|
|
5
|
+
# R2_SECRET_ACCESS_KEY.
|
|
6
|
+
|
|
7
|
+
feed_s3() {
|
|
8
|
+
AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID" AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY" \
|
|
9
|
+
AWS_DEFAULT_REGION=auto AWS_REQUEST_CHECKSUM_CALCULATION=when_required \
|
|
10
|
+
aws s3api "$@" --bucket "$bucket" \
|
|
11
|
+
--endpoint-url "${R2_ENDPOINT:-https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com}" --output text
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Prints "<size> <sha256>" for the stored <key> (the digest from its sha256 metadata, or "None"
|
|
15
|
+
# for an object uploaded without it), or nothing when the feed has no such object. Any other HEAD
|
|
16
|
+
# failure (credentials, network, throttling) is not evidence of absence, so it fails.
|
|
17
|
+
feed_object_head() { # <key>
|
|
18
|
+
local head err
|
|
19
|
+
if head=$(feed_s3 head-object --key "$1" --query '[ContentLength, Metadata.sha256]' 2>"$work/head.err"); then
|
|
20
|
+
printf '%s\n' "$head" | tr '\t' ' '
|
|
21
|
+
return 0
|
|
22
|
+
fi
|
|
23
|
+
err=$(cat "$work/head.err")
|
|
24
|
+
case "$err" in
|
|
25
|
+
*'(404)'* | *'Not Found'* | *NoSuchKey*) return 0 ;;
|
|
26
|
+
esac
|
|
27
|
+
say "refusing: could not tell whether $1 exists: $err" >&2
|
|
28
|
+
return 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# True only when the stored <key> holds exactly <size> bytes whose SHA-256 is <digest>. An object
|
|
32
|
+
# of the same size from an interrupted or different upload is not the staged file: the digest is
|
|
33
|
+
# compared from the object's sha256 metadata, or from its downloaded bytes when it has none.
|
|
34
|
+
feed_object_matches() { # <key> <size> <digest>
|
|
35
|
+
local head stored_size stored_digest copy="$work/existing-object" actual
|
|
36
|
+
head=$(feed_object_head "$1") || return 1
|
|
37
|
+
[ -n "$head" ] || return 1
|
|
38
|
+
read -r stored_size stored_digest <<<"$head"
|
|
39
|
+
[ "$stored_size" = "$2" ] || return 1
|
|
40
|
+
if [ -n "$stored_digest" ] && [ "$stored_digest" != None ]; then
|
|
41
|
+
[ "$stored_digest" = "$3" ]
|
|
42
|
+
return
|
|
43
|
+
fi
|
|
44
|
+
rm -f "$copy"
|
|
45
|
+
feed_s3 get-object --key "$1" "$copy" >/dev/null || { say "refusing: could not read the existing $1"; return 1; }
|
|
46
|
+
actual=$(sha256 "$copy")
|
|
47
|
+
rm -f "$copy"
|
|
48
|
+
[ "$actual" = "$3" ]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# What clients follow to find a release: the channel pointers and any installers. They go up
|
|
52
|
+
# only after the release they name has verified from the feed.
|
|
53
|
+
feed_live_key() { # <key>
|
|
54
|
+
case "$1" in */channels/* | */install/*) return 0 ;; *) return 1 ;; esac
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Uploads one phase of the staged plan, in plan order. `content` is the release itself (immutable
|
|
58
|
+
# files, release.json and the ledger); `live` is the channel pointers and installers, uploaded
|
|
59
|
+
# after the content verified. An immutable file is written only if absent (If-None-Match), and an
|
|
60
|
+
# existing one must already hold the same bytes. Every write stores its SHA-256 as metadata and is
|
|
61
|
+
# read back by size and digest.
|
|
62
|
+
upload() { # <content|live>
|
|
63
|
+
local phase=${1:?content|live} plan="$out/upload-plan.json" key size digest type cache file put_err
|
|
64
|
+
bun -e '
|
|
65
|
+
const plan = JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8"))
|
|
66
|
+
for (const o of plan.objects) console.log([o.key, o.size, o.sha256, o.contentType, o.cacheControl].join("\t"))' "$plan" |
|
|
67
|
+
while IFS=$'\t' read -r key rest; do
|
|
68
|
+
if feed_live_key "$key"; then [ "$phase" = live ] || continue; else [ "$phase" = content ] || continue; fi
|
|
69
|
+
printf '%s\t%s\n' "$key" "$rest"
|
|
70
|
+
done > "$work/objects-$phase.tsv"
|
|
71
|
+
say "upload $phase ($(wc -l < "$work/objects-$phase.tsv" | tr -d ' ') objects, in order) to s3://$bucket via R2 S3 API:"
|
|
72
|
+
cut -f1,2 "$work/objects-$phase.tsv" | sed 's/^/ /'
|
|
73
|
+
[ -z "$dry" ] || { say "dry run: nothing uploaded"; return 0; }
|
|
74
|
+
while IFS=$'\t' read -r key size digest type cache; do
|
|
75
|
+
file="$out/$key"
|
|
76
|
+
[ "$(wc -c < "$file" | tr -d ' ')" = "$size" ] && [ "$(sha256 "$file")" = "$digest" ] ||
|
|
77
|
+
{ say "refusing: $key changed after staging"; exit 1; }
|
|
78
|
+
if [ "$cache" != no-cache ]; then
|
|
79
|
+
if feed_s3 put-object --key "$key" --body "$file" --content-type "$type" --cache-control "$cache" \
|
|
80
|
+
--metadata "sha256=$digest" --if-none-match '*' >/dev/null 2>"$work/put.err"; then
|
|
81
|
+
say " uploaded $key"
|
|
82
|
+
else
|
|
83
|
+
put_err=$(cat "$work/put.err")
|
|
84
|
+
case "$put_err" in
|
|
85
|
+
*'(412)'* | *PreconditionFailed*) ;;
|
|
86
|
+
*) say "refusing: upload of $key failed: $put_err"; exit 1 ;;
|
|
87
|
+
esac
|
|
88
|
+
feed_object_matches "$key" "$size" "$digest" ||
|
|
89
|
+
{ say "refusing: immutable $key exists with other bytes"; exit 1; }
|
|
90
|
+
say " exists $key"
|
|
91
|
+
continue
|
|
92
|
+
fi
|
|
93
|
+
else
|
|
94
|
+
feed_s3 put-object --key "$key" --body "$file" --content-type "$type" --cache-control "$cache" \
|
|
95
|
+
--metadata "sha256=$digest" >/dev/null
|
|
96
|
+
say " uploaded $key"
|
|
97
|
+
fi
|
|
98
|
+
feed_object_matches "$key" "$size" "$digest" || { say "upload of $key did not verify"; exit 1; }
|
|
99
|
+
done < "$work/objects-$phase.tsv"
|
|
100
|
+
}
|
package/ci/desktop-release.sh
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# adea-desktop-release: publish a desktop release from a release tag pipeline (GitLab CI, CircleCI or
|
|
3
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
|
-
# S3-compatible bucket such as Cloudflare R2)
|
|
6
|
-
#
|
|
5
|
+
# S3-compatible bucket such as Cloudflare R2), verifies the release from the feed, then uploads the
|
|
6
|
+
# channel pointers clients follow, and links every published file on the GitLab release.
|
|
7
7
|
#
|
|
8
8
|
# adea-desktop-release daily build and publish the tag's daily (CI_COMMIT_TAG = v<version>)
|
|
9
9
|
# adea-desktop-release stable promote the newest qualified daily after the soak
|
|
@@ -40,10 +40,16 @@ if [ -z "${CI_COMMIT_TAG:-}" ]; then
|
|
|
40
40
|
[ -n "$CI_COMMIT_TAG" ] || [ "${GITHUB_REF_TYPE:-}" != tag ] || CI_COMMIT_TAG=${GITHUB_REF_NAME:-}
|
|
41
41
|
fi
|
|
42
42
|
CI_COMMIT_SHA=${CI_COMMIT_SHA:-${CIRCLE_SHA1:-${GITHUB_SHA:-}}}
|
|
43
|
-
|
|
43
|
+
# The run id signs into the descriptors and must be a positive integer: CircleCI's build number,
|
|
44
|
+
# not its workflow id (a UUID).
|
|
45
|
+
CI_PIPELINE_ID=${CI_PIPELINE_ID:-${CIRCLE_BUILD_NUM:-${GITHUB_RUN_ID:-}}}
|
|
44
46
|
sha256() { if command -v shasum >/dev/null; then shasum -a 256 "$1"; else sha256sum "$1"; fi | cut -d' ' -f1; }
|
|
45
47
|
b64d() { printf '%s' "$1" | base64 -d 2>/dev/null || printf '%s' "$1" | base64 -D; }
|
|
46
48
|
|
|
49
|
+
# upload and the feed's other bucket steps, beside this script in the installed package.
|
|
50
|
+
# shellcheck source=ci/desktop-release-feed.sh
|
|
51
|
+
source "$(dirname "$(readlink -f "$0")")/desktop-release-feed.sh"
|
|
52
|
+
|
|
47
53
|
root=$(git rev-parse --show-toplevel)
|
|
48
54
|
cd "$root"
|
|
49
55
|
sha=${CI_COMMIT_SHA:-}
|
|
@@ -94,34 +100,6 @@ extend_plan() { # <channel> <tag> <released sha>
|
|
|
94
100
|
else rc=$?; [ "$rc" = 3 ] || exit "$rc"; fi
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
# Uploads the staged plan in order: immutable files first (an existing one must already hold the
|
|
98
|
-
# same bytes), channel pointers last, each verified by size after the upload.
|
|
99
|
-
upload() {
|
|
100
|
-
local plan="$out/upload-plan.json"
|
|
101
|
-
bun -e '
|
|
102
|
-
const plan = JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8"))
|
|
103
|
-
for (const o of plan.objects) console.log([o.key, o.size, o.sha256, o.contentType, o.cacheControl].join("\t"))' "$plan" > "$work/objects.tsv"
|
|
104
|
-
say "upload plan ($(wc -l < "$work/objects.tsv" | tr -d ' ') objects, in order) to s3://$bucket via R2 S3 API:"
|
|
105
|
-
cut -f1,2 "$work/objects.tsv" | sed 's/^/ /'
|
|
106
|
-
[ -z "$dry" ] || { say "dry run: nothing uploaded"; return 0; }
|
|
107
|
-
local endpoint=${R2_ENDPOINT:-https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com}
|
|
108
|
-
s3() { AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID" AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY" \
|
|
109
|
-
AWS_DEFAULT_REGION=auto AWS_REQUEST_CHECKSUM_CALCULATION=when_required \
|
|
110
|
-
aws s3api "$@" --bucket "$bucket" --endpoint-url "$endpoint" --output text; }
|
|
111
|
-
while IFS=$'\t' read -r key size digest type cache; do
|
|
112
|
-
file="$out/$key"
|
|
113
|
-
[ "$(wc -c < "$file" | tr -d ' ')" = "$size" ] && [ "$(sha256 "$file")" = "$digest" ] ||
|
|
114
|
-
{ say "refusing: $key changed after staging"; exit 1; }
|
|
115
|
-
if [ "$cache" != no-cache ] && existing=$(s3 head-object --key "$key" --query ContentLength 2>/dev/null); then
|
|
116
|
-
[ "$existing" = "$size" ] || { say "refusing: immutable $key exists with other bytes"; exit 1; }
|
|
117
|
-
say " exists $key"; continue
|
|
118
|
-
fi
|
|
119
|
-
s3 put-object --key "$key" --body "$file" --content-type "$type" --cache-control "$cache" >/dev/null
|
|
120
|
-
[ "$(s3 head-object --key "$key" --query ContentLength)" = "$size" ] || { say "upload of $key did not verify"; exit 1; }
|
|
121
|
-
say " uploaded $key"
|
|
122
|
-
done < "$work/objects.tsv"
|
|
123
|
-
}
|
|
124
|
-
|
|
125
103
|
# Links every published file of <tag> on its GitLab release (creating the release when release
|
|
126
104
|
# tooling has not), pointing at the feed. Links that already exist are kept.
|
|
127
105
|
link_release() { # <tag>
|
|
@@ -173,8 +151,9 @@ if [ "$channel" = stable ]; then
|
|
|
173
151
|
[ -n "$tag" ] || { say "nothing to promote"; exit 0; }
|
|
174
152
|
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")
|
|
175
153
|
extend_plan stable "$tag" "$released"
|
|
176
|
-
upload
|
|
154
|
+
upload content
|
|
177
155
|
[ -n "$dry" ] || bun "$cli/release-finalize-cli.js" --local release-config.json "$tag"
|
|
156
|
+
upload live
|
|
178
157
|
exit 0
|
|
179
158
|
fi
|
|
180
159
|
|
|
@@ -222,7 +201,8 @@ bun -e '
|
|
|
222
201
|
if (missing.length) { console.error("command artifacts missing from the plan: " + missing.join(", ")); process.exit(1) }' \
|
|
223
202
|
"$out/upload-plan.json" "$PWD/release-config.json" "$repo" "$tag" "$platform"
|
|
224
203
|
extend_plan daily "$tag" "$sha"
|
|
225
|
-
upload
|
|
204
|
+
upload content
|
|
226
205
|
verified=$(bun "$cli/release-finalize-cli.js" --local release-config.json "$tag")
|
|
227
206
|
say "verified from the feed: $verified"
|
|
207
|
+
upload live
|
|
228
208
|
link_release "$tag"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.39.
|
|
1
|
+
{"version":"0.39.1","commit":"4b9894a73bdbe3960175c897fa65c64447551953"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/app-framework",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"ci/desktop-release.sh",
|
|
31
|
+
"ci/desktop-release-feed.sh",
|
|
31
32
|
"dist",
|
|
32
33
|
"src/app/application.tsx",
|
|
33
34
|
"src/appearance",
|