Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat: prevent overwriting existing versioned artifacts in upload scripts

0xken156cd59b07249a
diff --git a/cli/scripts/upload-cli.sh b/cli/scripts/upload-cli.sh
index 2770461a1..a7d6bacd4 100755
--- a/cli/scripts/upload-cli.sh
+++ b/cli/scripts/upload-cli.sh
@@ -86,6 +86,20 @@ gcs_cp() {
gcloud "${args[@]}" "$src" "$dst"
}
+# gcs_refuse_republish <gs://…> — a versioned artifact is IMMUTABLE once published: the CDN in front of
+# it caches for a year and serves the FIRST bytes it saw for that path, so a re-upload of the same
+# version leaves the manifest naming bytes no daemon will ever receive (the self-updater verifies the
+# sha and refuses). Same guard as desktop/scripts/upload-desktop.sh; always a new version, never an
+# overwrite.
+gcs_refuse_republish() {
+ local dst="$1"
+ if gcloud storage ls "$dst" >/dev/null 2>&1; then
+ echo "error: $dst already exists — versioned artifacts are immutable (the CDN keeps the first bytes)." >&2
+ echo " Publish a NEW version instead of re-uploading this one (see cli/RELEASE.md)." >&2
+ exit 1
+ fi
+}
+
cleanup() { rm -f "${SRC:-}" "${DST:-}"; }
trap cleanup EXIT
@@ -138,6 +152,8 @@ NOTIFY_SHA="$(sha256_of "$NOTIFY")"; NOTIFY_SIZE="$(wc -c < "$NOTIFY" | tr -d '
echo ">> uploading cli.js ($CLI_SIZE bytes) + notify.mjs ($NOTIFY_SIZE bytes)"
# Immutable per-version path — see the CDN_ASSET_BASE_URL note above. Long max-age here is what
# actually lets the CDN cache these instead of hitting GCS on every daemon's install/update.
+gcs_refuse_republish "gs://${GCS_BUCKET}/${CLI_GCS}"
+gcs_refuse_republish "gs://${GCS_BUCKET}/${NOTIFY_GCS}"
gcs_cp "$CLI" "gs://${GCS_BUCKET}/${CLI_GCS}" "public, max-age=31536000, immutable"
gcs_cp "$NOTIFY" "gs://${GCS_BUCKET}/${NOTIFY_GCS}" "public, max-age=31536000, immutable"
diff --git a/desktop/scripts/upload-desktop-linux.sh b/desktop/scripts/upload-desktop-linux.sh
index 5c919a4a6..bfc72934e 100755
--- a/desktop/scripts/upload-desktop-linux.sh
+++ b/desktop/scripts/upload-desktop-linux.sh
@@ -140,6 +140,21 @@ gcs_cp() {
if [ -n "$ct" ]; then args+=("--content-type=$ct"); fi
gcloud "${args[@]}" "$src" "$dst"
}
+
+# gcs_refuse_republish <gs://…> — a versioned artifact is IMMUTABLE once published: the CDN in front of
+# it caches for a year and serves the FIRST bytes it saw for that path. Re-uploading the same version
+# (a re-run of a failed release workflow, a second tag on the same version) leaves the manifest naming
+# bytes the CDN will never serve — every updater then fails its size/sha check with "Could not
+# download and verify". Measured on 1.1.56 (2026-09-18): three workflow runs, one path, two different
+# zips, self-update broken for every Mac. The fix is always a new version, never an overwrite.
+gcs_refuse_republish() {
+ local dst="$1"
+ if gcloud storage ls "$dst" >/dev/null 2>&1; then
+ echo "error: $dst already exists — versioned artifacts are immutable (the CDN keeps the first bytes)." >&2
+ echo " Publish a NEW version instead of re-uploading this one (see RELEASE.md)." >&2
+ exit 1
+ fi
+}
command -v python3 >/dev/null 2>&1 || { echo "error: python3 not found" >&2; exit 1; }
command -v flutter >/dev/null 2>&1 || { echo "error: flutter not found" >&2; exit 1; }
command -v sha256sum >/dev/null 2>&1 || { echo "error: sha256sum not found" >&2; exit 1; }
@@ -236,6 +251,7 @@ echo ">> uploading release $VER ($SIZE bytes, sha256=$SHA)"
echo " dest: gs://${GCS_BUCKET}/${GCS_PATH}"
# Immutable per-version path — see the CDN_ASSET_BASE_URL note near the top of this script. Long
# max-age here is what actually lets the CDN cache it instead of hitting GCS on every install/update.
+gcs_refuse_republish "gs://${GCS_BUCKET}/${GCS_PATH}"
gcs_cp "$OUTPUT" "gs://${GCS_BUCKET}/${GCS_PATH}" "public, max-age=31536000, immutable"
echo ">> merging manifest: gs://${GCS_BUCKET}/${METADATA_PATH} (${OTA_KEY})"
diff --git a/desktop/scripts/upload-desktop.sh b/desktop/scripts/upload-desktop.sh
index 9952996b2..476377065 100755
--- a/desktop/scripts/upload-desktop.sh
+++ b/desktop/scripts/upload-desktop.sh
@@ -139,6 +139,21 @@ gcs_cp() {
if [ -n "$ct" ]; then args+=("--content-type=$ct"); fi
gcloud "${args[@]}" "$src" "$dst"
}
+
+# gcs_refuse_republish <gs://…> — a versioned artifact is IMMUTABLE once published: the CDN in front of
+# it caches for a year and serves the FIRST bytes it saw for that path. Re-uploading the same version
+# (a re-run of a failed release workflow, a second tag on the same version) leaves the manifest naming
+# bytes the CDN will never serve — every updater then fails its size/sha check with "Could not
+# download and verify". Measured on 1.1.56 (2026-09-18): three workflow runs, one path, two different
+# zips, self-update broken for every Mac. The fix is always a new version, never an overwrite.
+gcs_refuse_republish() {
+ local dst="$1"
+ if gcloud storage ls "$dst" >/dev/null 2>&1; then
+ echo "error: $dst already exists — versioned artifacts are immutable (the CDN keeps the first bytes)." >&2
+ echo " Publish a NEW version instead of re-uploading this one (see RELEASE.md)." >&2
+ exit 1
+ fi
+}
command -v python3 >/dev/null 2>&1 || { echo "error: python3 not found" >&2; exit 1; }
command -v flutter >/dev/null 2>&1 || { echo "error: flutter not found" >&2; exit 1; }
if [ "$DO_NOTARIZE" -eq 1 ]; then
@@ -302,8 +317,10 @@ echo ">> uploading release $VER"
# Immutable per-version path — see the CDN_ASSET_BASE_URL note near the top of this script. Long
# max-age here is what actually lets the CDN cache these instead of hitting GCS on every install/update.
echo " zip: gs://${GCS_BUCKET}/${GCS_PATH} ($SIZE bytes, sha256=$SHA)"
+gcs_refuse_republish "gs://${GCS_BUCKET}/${GCS_PATH}"
gcs_cp "$ZIP" "gs://${GCS_BUCKET}/${GCS_PATH}" "public, max-age=31536000, immutable"
echo " dmg: gs://${GCS_BUCKET}/${DMG_GCS_PATH} ($DMG_SIZE bytes, sha256=$DMG_SHA)"
+gcs_refuse_republish "gs://${GCS_BUCKET}/${DMG_GCS_PATH}"
gcs_cp "$DMG" "gs://${GCS_BUCKET}/${DMG_GCS_PATH}" "public, max-age=31536000, immutable"
echo ">> merging manifest: gs://${GCS_BUCKET}/${METADATA_PATH} (${OTA_KEY}, ${DMG_KEY})"