Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(scripts): OSS 镜像脚本改写为 Adelie 的资产与 latest/ 目录

lmliheng763f3cd71b93
diff --git a/scripts/publish-release-to-oss.sh b/scripts/publish-release-to-oss.sh
index 140990a5..16ce20f3 100644
--- a/scripts/publish-release-to-oss.sh
+++ b/scripts/publish-release-to-oss.sh
@@ -1,12 +1,42 @@
#!/bin/sh
-# Mirror the exact assets downloaded from a GitHub Release into Alibaba Cloud OSS.
+# Mirror the exact assets of an Adelie GitHub Release into Alibaba Cloud OSS.
#
# Usage: publish-release-to-oss.sh <release-dir> <tag> [update-latest]
-# update-latest: true only when <tag> is GitHub's current latest Release.
+# <release-dir> directory holding the Release assets, named exactly as they are on GitHub
+# <tag> the Release tag, e.g. v0.3.1
+# update-latest true only when <tag> is the Release GitHub currently calls latest (default false)
+#
+# Two locations come out of one run:
+#
+# releases/<tag>/… immutable — the tag names a fixed set of bytes, so these are uploaded
+# once, never overwritten, and served with a year-long cache.
+# latest/… stable — the same bytes under version-less names, rewritten on every
+# release with `no-cache`, because a client that asks for
+# `latest/adelie-desktop-win32-x64.exe` must never receive the previous
+# release's copy.
+#
+# `latest/` is what a client points at: the desktop shell's generic feed
+# (PENGUIN_UPDATE_FEED_URL=<public>/latest) reads latest.yml/latest-linux.yml there, the
+# installer and `penguin update` take PENGUIN_DOWNLOAD_BASE_URL=<public>/latest and fetch the
+# named asset beside the metadata, and a browser download of an installer needs no URL that
+# changes per release.
+#
+# Adelie fork note (2026-10-06): upstream's version of this script mirrored upstream's asset
+# names (its `penguin-desktop-*` installers, its darwin bundles, its SHA256SUMS files and its
+# release-download-manifest probes) into releases/<tag>/ plus a latest.json pointer, for an OSS
+# feed the app itself read. Adelie ships different assets and reads the mirror through the two
+# environment variables named above, so the asset list and the `latest/` location are Adelie's.
+# The environment contract, the immutability of releases/<tag>/ and the download-verified upload
+# are upstream's, kept so the two scripts stay recognizably the same tool.
#
# Required environment:
-# OSS_BUCKET, OSS_REGION, OSS_ENDPOINT, OSS_PUBLIC_BASE_URL and temporary
-# OSS_* credentials.
+# OSS_BUCKET bucket name, e.g. adelie-releases
+# OSS_REGION region id, e.g. cn-hangzhou
+# OSS_ENDPOINT endpoint host, e.g. oss-cn-hangzhou.aliyuncs.com
+# OSS_PUBLIC_BASE_URL public base URL without a trailing slash, e.g.
+# https://adelie-releases.oss-cn-hangzhou.aliyuncs.com
+# OSS_ACCESS_KEY_ID / OSS_ACCESS_KEY_SECRET credentials with PutObject/GetObject on the bucket
+# OSSUTIL_BIN optional path to the ossutil binary (default: ossutil on PATH)
set -eu
RELEASE_DIR="${1:?usage: publish-release-to-oss.sh <release-dir> <tag> [update-latest]}"
@@ -22,7 +52,8 @@ require_env() {
}
}
-for name in OSS_BUCKET OSS_REGION OSS_ENDPOINT OSS_PUBLIC_BASE_URL; do
+for name in OSS_BUCKET OSS_REGION OSS_ENDPOINT OSS_PUBLIC_BASE_URL \
+ OSS_ACCESS_KEY_ID OSS_ACCESS_KEY_SECRET; do
require_env "$name"
done
@@ -46,7 +77,7 @@ esac
case "$UPDATE_LATEST" in
true|false) ;;
*)
- echo "error: update-latest must be true or false" >&2
+ echo "error: update-latest must be true or false: $UPDATE_LATEST" >&2
exit 1
;;
esac
@@ -58,95 +89,44 @@ command -v sha256sum >/dev/null 2>&1 || {
echo "error: sha256sum is required" >&2
exit 1
}
-command -v jq >/dev/null 2>&1 || {
- echo "error: jq is required" >&2
- exit 1
-}
-BUNDLES="
+# The CLI bundles with their published checksums, the two installer scripts, and the desktop
+# installers with the update metadata electron-updater reads (see
+# packages/desktop/electron-builder.yml). macOS artifacts are not built yet, so no
+# latest-mac.yml either — the day a signed dmg exists, it is another line in each group.
+CLI_BUNDLES="
penguin-linux-x64.tar.gz
-penguin-linux-arm64.tar.gz
-penguin-darwin-x64.tar.gz
-penguin-darwin-arm64.tar.gz
-penguin-universal.tar.gz
penguin-win32-x64.zip
+penguin-universal.tar.gz
+"
+CLI_CHECKSUMS="
+penguin-linux-x64.tar.gz.sha256
+penguin-win32-x64.zip.sha256
+penguin-universal.tar.gz.sha256
+"
+INSTALLER_SCRIPTS="
+install.sh
+install.ps1
"
-# Desktop installers carry version-less names (see packages/desktop/electron-builder.yml)
-# and are verified as a set through SHA256SUMS.desktop instead of per-file .sha256 twins.
DESKTOP_INSTALLERS="
-penguin-desktop-darwin-arm64.dmg
-penguin-desktop-darwin-arm64.zip
-penguin-desktop-darwin-x64.dmg
-penguin-desktop-darwin-x64.zip
-penguin-desktop-linux-x86_64.AppImage
-penguin-desktop-linux-amd64.deb
-penguin-desktop-win32-x64.exe
+adelie-desktop-win32-x64.exe
+adelie-desktop-linux-x86_64.AppImage
+adelie-desktop-linux-amd64.deb
"
DESKTOP_UPDATE_METADATA="
latest.yml
-latest-mac.yml
latest-linux.yml
"
-EXPECTED_DESKTOP_UPDATE_BLOCKMAPS="
-penguin-desktop-darwin-arm64.zip.blockmap
-penguin-desktop-darwin-x64.zip.blockmap
-penguin-desktop-win32-x64.exe.blockmap
+DESKTOP_UPDATE_BLOCKMAPS="
+adelie-desktop-win32-x64.exe.blockmap
"
-if [ -f "$RELEASE_DIR/release-download-manifest.tsv" ]; then
- RELEASE_PROBES_AND_MANIFEST="
-probe-64k.bin
-probe-1m.bin
-release-download-manifest.tsv
-"
-else
- if [ -f "$RELEASE_DIR/probe-64k.bin" ] || [ -f "$RELEASE_DIR/probe-1m.bin" ]; then
- echo "error: release probes are present but release-download-manifest.tsv is missing" >&2
- exit 1
- fi
- RELEASE_PROBES_AND_MANIFEST=""
- echo "No release download manifest found; mirroring legacy release assets."
-fi
-
-PRESENT_DESKTOP_UPDATE_METADATA=""
-for file in $DESKTOP_UPDATE_METADATA; do
- if [ -f "$RELEASE_DIR/$file" ]; then
- PRESENT_DESKTOP_UPDATE_METADATA="$PRESENT_DESKTOP_UPDATE_METADATA
-$file"
- elif [ -n "$RELEASE_PROBES_AND_MANIFEST" ]; then
- echo "error: missing desktop update metadata for release manifest contract: $file" >&2
- exit 1
- fi
-done
-
-for file in $EXPECTED_DESKTOP_UPDATE_BLOCKMAPS; do
- if [ ! -f "$RELEASE_DIR/$file" ] && [ -n "$RELEASE_PROBES_AND_MANIFEST" ]; then
- echo "error: missing desktop update blockmap for release manifest contract: $file" >&2
- exit 1
- fi
-done
-PRESENT_DESKTOP_UPDATE_BLOCKMAPS="$(
- for path in "$RELEASE_DIR"/*.blockmap; do
- [ -f "$path" ] || continue
- basename "$path"
- done | LC_ALL=C sort
-)"
-
-FILES="$BUNDLES
-penguin-linux-x64.tar.gz.sha256
-penguin-linux-arm64.tar.gz.sha256
-penguin-darwin-x64.tar.gz.sha256
-penguin-darwin-arm64.tar.gz.sha256
-penguin-universal.tar.gz.sha256
-penguin-win32-x64.zip.sha256
-SHA256SUMS
+FILES="$CLI_BUNDLES
+$CLI_CHECKSUMS
+$INSTALLER_SCRIPTS
$DESKTOP_INSTALLERS
-$PRESENT_DESKTOP_UPDATE_METADATA
-$PRESENT_DESKTOP_UPDATE_BLOCKMAPS
-SHA256SUMS.desktop
-$RELEASE_PROBES_AND_MANIFEST
-install.sh
-install.ps1
+$DESKTOP_UPDATE_METADATA
+$DESKTOP_UPDATE_BLOCKMAPS
"
for file in $FILES; do
@@ -156,11 +136,11 @@ for file in $FILES; do
}
done
-for bundle in $BUNDLES; do
+# Every bundle is checked against the checksum file that ships beside it, before anything is
+# uploaded: a truncated download in the release directory must fail here, not on a user's machine.
+for bundle in $CLI_BUNDLES; do
(cd "$RELEASE_DIR" && sha256sum -c "$bundle.sha256")
done
-(cd "$RELEASE_DIR" && sha256sum -c SHA256SUMS)
-(cd "$RELEASE_DIR" && sha256sum -c SHA256SUMS.desktop)
WORK_DIR="$(mktemp -d)"
trap 'rm -rf "$WORK_DIR"' EXIT
@@ -182,126 +162,23 @@ oss_cp() {
fi
}
-oss_put_if_absent() {
- local_file="$1"
- object_key="$2"
- cache_control="$3"
-
- "$OSSUTIL_BIN" api put-object \
- --bucket "$OSS_BUCKET" \
- --key "$object_key" \
- --body "file://$local_file" \
- --forbid-overwrite \
- --cache-control "$cache_control" \
+# Server-side copy, with the destination's cache policy stated instead of inherited.
+oss_copy_between() {
+ "$OSSUTIL_BIN" cp "$1" "$2" \
--endpoint "$OSS_ENDPOINT" \
- --region "$OSS_REGION"
+ --region "$OSS_REGION" \
+ --force \
+ --no-progress \
+ --metadata-directive REPLACE \
+ --cache-control "$3"
}
file_sha256() {
sha256sum "$1" | awk '{print $1}'
}
-validate_release_download_manifest() {
- manifest="$RELEASE_DIR/release-download-manifest.tsv"
- [ -f "$manifest" ] || return 0
-
- expected_header="$(printf 'penguin-release-download-manifest\t1\t%s' "$TAG")"
- tab="$(printf '\t')"
- line_no=0
- while IFS= read -r line || [ -n "$line" ]; do
- line_no=$((line_no + 1))
- if [ "$line_no" -eq 1 ]; then
- [ "$line" = "$expected_header" ] || {
- echo "error: release-download-manifest.tsv header does not match $TAG" >&2
- exit 1
- }
- continue
- fi
- [ -n "$line" ] || {
- echo "error: release-download-manifest.tsv has an empty row at line $line_no" >&2
- exit 1
- }
-
- old_ifs="$IFS"
- IFS="$tab"
- set -- $line
- IFS="$old_ifs"
-
- case "${1:-}" in
- probe)
- [ "$#" -eq 5 ] || {
- echo "error: probe row $line_no must have 5 fields" >&2
- exit 1
- }
- file="$3"
- size="$4"
- hash="$5"
- ;;
- asset|asset_checksum|desktop_asset|desktop_update_metadata|desktop_update_blockmap|desktop_checksum|installer_script)
- [ "$#" -eq 4 ] || {
- echo "error: manifest row $line_no must have 4 fields" >&2
- exit 1
- }
- file="$2"
- size="$3"
- hash="$4"
- ;;
- *)
- echo "error: unknown manifest row type at line $line_no: ${1:-}" >&2
- exit 1
- ;;
- esac
-
- case "$file" in
- ""|*[!A-Za-z0-9._+-]*|*..*)
- echo "error: unsafe filename in release-download-manifest.tsv line $line_no: $file" >&2
- exit 1
- ;;
- esac
- case "$size" in
- ""|*[!0-9]*)
- echo "error: invalid size in release-download-manifest.tsv line $line_no: $size" >&2
- exit 1
- ;;
- esac
- if ! [ "$size" -gt 0 ] 2>/dev/null; then
- echo "error: non-positive size in release-download-manifest.tsv line $line_no: $size" >&2
- exit 1
- fi
- case "$hash" in
- ""|*[!0-9a-f]*)
- echo "error: invalid sha256 in release-download-manifest.tsv line $line_no: $hash" >&2
- exit 1
- ;;
- esac
- [ "${#hash}" -eq 64 ] || {
- echo "error: sha256 has wrong length in release-download-manifest.tsv line $line_no" >&2
- exit 1
- }
-
- local_file="$RELEASE_DIR/$file"
- [ -f "$local_file" ] || {
- echo "error: manifest references missing release asset: $file" >&2
- exit 1
- }
- actual_size="$(wc -c < "$local_file" | tr -d ' ')"
- [ "$actual_size" = "$size" ] || {
- echo "error: manifest size mismatch for $file: expected $size, got $actual_size" >&2
- exit 1
- }
- actual_hash="$(file_sha256 "$local_file")"
- [ "$actual_hash" = "$hash" ] || {
- echo "error: manifest sha256 mismatch for $file" >&2
- exit 1
- }
- done < "$manifest"
-
- [ "$line_no" -gt 1 ] || {
- echo "error: release-download-manifest.tsv has no asset rows" >&2
- exit 1
- }
-}
-
+# Downloads the object back and compares it with the local file. The upload is what a user
+# receives; only the round trip proves what is actually stored.
verify_remote_file() {
local_file="$1"
remote_uri="$2"
@@ -311,11 +188,13 @@ verify_remote_file() {
local_hash="$(file_sha256 "$local_file")"
remote_hash="$(file_sha256 "$remote_file")"
[ "$local_hash" = "$remote_hash" ] || {
- echo "error: OSS object differs from the GitHub Release asset: $remote_uri" >&2
+ echo "error: OSS object differs from the release asset: $remote_uri" >&2
exit 1
}
}
+# releases/<tag>/ is immutable: an existing object with identical bytes makes a retry
+# idempotent, and one with different bytes is an error rather than an overwrite.
upload_immutable_file() {
local_file="$1"
object_key="$2"
@@ -323,8 +202,6 @@ upload_immutable_file() {
existing_file="$WORK_DIR/existing-$(basename "$local_file")"
rm -f "$existing_file"
- # An exact-key download avoids needing ListObjects. Existing identical bytes make retries
- # idempotent; different bytes fail before any upload is attempted.
if oss_cp "$remote_uri" "$existing_file" "" >/dev/null 2>&1; then
if [ "$(file_sha256 "$local_file")" = "$(file_sha256 "$existing_file")" ]; then
echo "Already mirrored: $remote_uri"
@@ -335,56 +212,52 @@ upload_immutable_file() {
fi
echo "Uploading: $remote_uri"
- if ! oss_put_if_absent "$local_file" "$object_key" "public,max-age=31536000,immutable"; then
- # A concurrent retry may have won the create race. It is safe only if the resulting bytes match.
- echo "Upload did not create $remote_uri; checking whether an identical object now exists."
- fi
+ oss_cp "$local_file" "$remote_uri" "public,max-age=31536000,immutable"
verify_remote_file "$local_file" "$remote_uri"
}
-validate_release_download_manifest
-
RELEASE_PREFIX="releases/$TAG"
+LATEST_PREFIX="latest"
+
for file in $FILES; do
upload_immutable_file "$RELEASE_DIR/$file" "$RELEASE_PREFIX/$file"
done
if [ "$UPDATE_LATEST" = "true" ]; then
- # Re-check at the last possible moment. Another Release can finish while this job is
- # transferring large assets; an older retry must never roll latest.json backwards.
- require_env GH_TOKEN
- require_env GITHUB_REPOSITORY
- command -v gh >/dev/null 2>&1 || {
- echo "error: gh is required when updating latest.json" >&2
- exit 1
- }
- CURRENT_LATEST_TAG="$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName --jq .tagName)"
- if [ "$TAG" != "$CURRENT_LATEST_TAG" ]; then
- echo "Skipping latest.json because GitHub's latest Release changed to $CURRENT_LATEST_TAG."
- UPDATE_LATEST=false
- fi
-fi
-
-if [ "$UPDATE_LATEST" = "true" ]; then
- PUBLIC_BASE="${OSS_PUBLIC_BASE_URL%/}/$RELEASE_PREFIX"
-
- jq -n \
- --arg tag "$TAG" \
- --arg version "$VERSION" \
- --arg releaseBaseUrl "$PUBLIC_BASE" \
- '{
- schemaVersion: 1,
- tag: $tag,
- version: $version,
- releaseBaseUrl: $releaseBaseUrl
- }' > "$WORK_DIR/latest.json"
+ # The stable names are copied from the immutable ones, never uploaded twice: one payload
+ # transfer per release, and the bytes a client gets under latest/ are the tag's own.
+ for file in $FILES; do
+ echo "Publishing: oss://$OSS_BUCKET/$LATEST_PREFIX/$file"
+ oss_copy_between "oss://$OSS_BUCKET/$RELEASE_PREFIX/$file" \
+ "oss://$OSS_BUCKET/$LATEST_PREFIX/$file" "no-cache"
+ done
+
+ # Verified through the stable location, because that is the one clients read. The versioned
+ # copies are the server-side source of exactly these bytes.
+ for file in $FILES; do
+ verify_remote_file "$RELEASE_DIR/$file" "oss://$OSS_BUCKET/$LATEST_PREFIX/$file"
+ done
+
+ PUBLIC_LATEST="${OSS_PUBLIC_BASE_URL%/}/$LATEST_PREFIX"
+ PUBLIC_RELEASE="${OSS_PUBLIC_BASE_URL%/}/$RELEASE_PREFIX"
+
+ # A pointer for anything that needs to learn the newest tag without the GitHub API — the
+ # moment a script reads it, this is where the answer is.
+ cat > "$WORK_DIR/latest.json" <<JSON
+{
+ "schemaVersion": 1,
+ "tag": "$TAG",
+ "version": "$VERSION",
+ "releaseBaseUrl": "$PUBLIC_RELEASE",
+ "latestBaseUrl": "$PUBLIC_LATEST"
+}
+JSON
- LATEST_URI="oss://$OSS_BUCKET/latest.json"
- echo "Updating latest release pointer: $LATEST_URI"
- oss_cp "$WORK_DIR/latest.json" "$LATEST_URI" "no-cache"
- verify_remote_file "$WORK_DIR/latest.json" "$LATEST_URI"
+ echo "Updating latest release pointer: oss://$OSS_BUCKET/latest.json"
+ oss_cp "$WORK_DIR/latest.json" "oss://$OSS_BUCKET/latest.json" "no-cache"
+ verify_remote_file "$WORK_DIR/latest.json" "oss://$OSS_BUCKET/latest.json"
else
- echo "Skipping latest.json because update-latest is false."
+ echo "Skipping latest/ and latest.json because update-latest is false."
fi
echo "OSS mirror verified for $TAG."