Android / Build, or is the channel already serving this? (push) Successful in 3s
CI & Build / Build now, or wait for Android? (push) Successful in 3s
CI & Build / Python lint (push) Successful in 4s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 4s
CI & Build / TypeScript typecheck (push) Successful in 7s
CI & Build / Python tests (push) Successful in 12s
CI & Build / integration (push) Successful in 18s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 3m0s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 5m17s
Desktop (Tauri) / Update manifest (push) Successful in 4s
Android / Kotlin + Rust (APK) (push) Successful in 8m4s
Step 7 of M314, the last one. Rule 22 — the old path comes out completely. ## A release stops building `desktop.yml` no longer triggers on `v*`, and its two `Publish release` steps are gone. `ci.yml` lost its tag trigger in step 6. So a tag now reaches exactly one lane: the new `release.yml`, which builds nothing. That is not a simplification for its own sake. The merge to `main` already published everything a user can receive — `:latest` + `:<sha>`, both channel feeds, the updater manifest. A tag rebuilding that source produces identical artifacts under identical names and re-pushes `:<sha>` with different bytes, which rule 145 forbids even when they match. ## So what a release is FOR The changelog (note 3127 §5). Two halves to "what am I running", and the version answers only the first: which build is this (the footer, /api/config, the APK's versionName) and what is in it that was not in the one I ran last month (nothing, until now). `packaging/release-notes.sh` derives it from git rather than a hand-maintained CHANGELOG, which drifts into recording what someone MEANT to ship. Capped at 60 entries with the omitted count stated — the first dated release spans 181 commits since `v0.1.0`, and a truncated list that does not say it is truncated is a lie. It publishes through `publish-release.sh` rather than making its own API calls, for the create-or-PATCH-on-409 path: a fixed-tag release that only ever POSTs keeps whatever body its first run wrote, which is #2182, and reimplementing that correctly in a second place is how it comes back. ## Retired `MANIFEST_TAG` and the whole branch behind it. It let the manifest live on a `stable` pointer release while the bundles sat on a versioned one — a split step 3 removed when `stable` started holding its own bundles. Nothing had passed it since; a parameter that can only ever receive its own default is a branch nobody exercises and a comment that goes stale, and its stale text was still telling readers the installable builds live on the versioned releases. `desktop/src-tauri/Cargo.toml`'s version and `thoughtsync/__init__.py`'s both now say out loud that they are not shipped values. The Cargo one carries the history worth keeping: the old scheme took its base from that line, so `0.2.<run>` on dev outranked a bare `0.2.0` on main, and the remedy was "remember to bump the minor before tagging" — documented in a comment, enforced nowhere. #2183 is what that looked like in the field. **That ritual is now formally dead**, and this is the deliberate act of killing it rather than a side effect. ## Still there on purpose `install.sh`'s transitional stable fallback. It cannot go until `main` has published to `stable` at least once, and that is gated on an operator request. Removing it now would break the DEFAULT install channel. #3147 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
180 lines
8.9 KiB
Bash
180 lines
8.9 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Write the updater manifest (`latest.json`) for one channel and attach it to that
|
|
# channel's release.
|
|
#
|
|
# WHY A SEPARATE STEP: the Linux and Windows bundles are built by two jobs in two
|
|
# workspaces, and neither can see the other's output — but ONE manifest has to
|
|
# describe both platforms. So this runs after both, reads what actually landed on
|
|
# the release, and writes the manifest from that. Building it inside either job
|
|
# would produce a manifest that silently omits the other platform, and a missing
|
|
# platform reads to a user as "no update available" rather than as a broken feed.
|
|
#
|
|
# WHAT IT READS: the release's own asset list. The signature for each bundle is a
|
|
# `.sig` asset published beside it (see publish-release.sh); its CONTENT is what
|
|
# goes in the manifest, which is why each one is downloaded rather than linked.
|
|
#
|
|
# Tauri's expected shape:
|
|
# { "version": "0.1.0", "pub_date": "...", "notes": "...",
|
|
# "platforms": { "<target>-<arch>": { "signature": "...", "url": "..." } } }
|
|
set -euo pipefail
|
|
|
|
: "${GITHUB_TOKEN:?GITHUB_TOKEN is required}"
|
|
: "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}"
|
|
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required (owner/repo)}"
|
|
: "${RELEASE_TAG:?RELEASE_TAG is required (the release holding the bundles)}"
|
|
: "${APP_VERSION:?APP_VERSION is required (the version the bundles carry)}"
|
|
|
|
# The manifest is published to the release that HOLDS the bundles. There is no
|
|
# second place any more.
|
|
#
|
|
# There used to be: `MANIFEST_TAG` let the manifest live on a `stable` pointer
|
|
# release while the bundles sat on a versioned `v*` one, because the app can only
|
|
# read a URL that never changes and a versioned tag is not that. M314 step 3 made
|
|
# `stable` a rolling release that holds its own bundles, exactly like `dev`, so the
|
|
# split had nothing left to bridge — and a parameter that can only ever be passed
|
|
# its own default is a branch nobody exercises and a comment that goes stale.
|
|
|
|
API="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
|
|
AUTH=(-H "Authorization: token $GITHUB_TOKEN")
|
|
NOTES="${RELEASE_NOTES:-}"
|
|
|
|
work="$(mktemp -d)"
|
|
trap 'rm -rf "$work"' EXIT INT TERM
|
|
|
|
echo "==> Reading assets on release $RELEASE_TAG"
|
|
release="$(curl -sS "${AUTH[@]}" "$API/releases/tags/$RELEASE_TAG")"
|
|
release_id="$(printf '%s' "$release" | grep -oE '"id"[[:space:]]*:[[:space:]]*[0-9]+' | head -1 | grep -oE '[0-9]+')"
|
|
[ -n "$release_id" ] || { echo "ERROR: no release tagged $RELEASE_TAG" >&2; exit 1; }
|
|
assets="$(curl -sS "${AUTH[@]}" "$API/releases/$release_id/assets")"
|
|
|
|
# Asset names, one per line. The API returns them in a single JSON blob; this is
|
|
# the only field needed, and grep beats adding a jq dependency to the CI image.
|
|
names="$(printf '%s' "$assets" | grep -oE '"name"[[:space:]]*:[[:space:]]*"[^"]+"' | sed -E 's/.*"([^"]+)"$/\1/')"
|
|
|
|
download_url() { printf '%s/%s/releases/download/%s/%s' "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$RELEASE_TAG" "$1"; }
|
|
|
|
# One platform entry, or nothing if that platform's bundle or signature is absent.
|
|
# Emitting a partial entry would be worse than emitting none: the app would try to
|
|
# install something it can't verify.
|
|
platform_entry() {
|
|
local target="$1" pattern="$2" bundle sig_name
|
|
# Matched on THIS build's version, not just the file extension.
|
|
#
|
|
# The rolling dev release accumulates every build's assets, and picking the first
|
|
# extension match returned the OLDEST one — so the manifest advertised the new
|
|
# version while pointing at an old binary. The client would install the older
|
|
# build, still be told the newer version was available, and update forever. The
|
|
# signature check couldn't catch it either: the old bundle's signature is
|
|
# perfectly valid FOR THE OLD BUNDLE.
|
|
bundle="$(printf '%s\n' "$names" | grep -F "_${APP_VERSION}_" | grep -E "$pattern" | head -1 || true)"
|
|
# A hard failure, not a skip: reaching here means this platform's build didn't
|
|
# upload, and the whole point is to never advertise a bundle that isn't there.
|
|
[ -n "$bundle" ] || { echo " no $APP_VERSION bundle matching $pattern — skipping $target" >&2; return; }
|
|
sig_name="$bundle.sig"
|
|
if ! printf '%s\n' "$names" | grep -qxF "$sig_name"; then
|
|
echo " $bundle has no $sig_name — skipping $target (was the build signed?)" >&2
|
|
return
|
|
fi
|
|
curl -fsSL "${AUTH[@]}" -o "$work/sig" "$(download_url "$sig_name")"
|
|
# The signature is base64 on one line already; strip any stray newline so it
|
|
# can't break the JSON string it's about to become.
|
|
local signature
|
|
signature="$(tr -d '\r\n' < "$work/sig")"
|
|
printf ' "%s": { "signature": "%s", "url": "%s" }' "$target" "$signature" "$(download_url "$bundle")"
|
|
}
|
|
|
|
echo "==> Building the manifest"
|
|
entries=()
|
|
# `.AppImage` only on Linux: the updater replaces the running bundle in place, which
|
|
# a package-manager install (deb/pacman) must never have done to it.
|
|
if entry="$(platform_entry "linux-x86_64" '\.AppImage$')" && [ -n "$entry" ]; then entries+=("$entry"); fi
|
|
if entry="$(platform_entry "windows-x86_64" '\.exe$')" && [ -n "$entry" ]; then entries+=("$entry"); fi
|
|
|
|
if [ ${#entries[@]} -eq 0 ]; then
|
|
echo "ERROR: no signed bundle on $RELEASE_TAG — refusing to publish an empty manifest." >&2
|
|
echo " (An empty manifest would tell every client it is up to date.)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# No `date -u -Is` — busybox date in the CI image doesn't take it.
|
|
pub_date="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
|
|
{
|
|
printf '{\n'
|
|
printf ' "version": "%s",\n' "$APP_VERSION"
|
|
printf ' "pub_date": "%s",\n' "$pub_date"
|
|
printf ' "notes": "%s",\n' "$NOTES"
|
|
printf ' "platforms": {\n'
|
|
for i in "${!entries[@]}"; do
|
|
[ "$i" -eq 0 ] || printf ',\n'
|
|
printf '%s' "${entries[$i]}"
|
|
done
|
|
printf '\n }\n'
|
|
printf '}\n'
|
|
} > "$work/latest.json"
|
|
|
|
echo "==> Manifest:"
|
|
cat "$work/latest.json"
|
|
|
|
# The manifest goes on the same release the bundles were just read from — which is
|
|
# also the one `publish-release.sh` created or refreshed moments earlier, so it is
|
|
# guaranteed to exist by the time this runs.
|
|
target_id="$release_id"
|
|
target_assets="$assets"
|
|
|
|
# Replace rather than duplicate: Forgejo rejects a second asset with the same name,
|
|
# and this file is rewritten on every publish by design.
|
|
old_id="$(printf '%s' "$target_assets" \
|
|
| grep -oE "\"id\"[[:space:]]*:[[:space:]]*[0-9]+[^}]*\"name\"[[:space:]]*:[[:space:]]*\"latest\.json\"" \
|
|
| head -1 | grep -oE '[0-9]+' | head -1 || true)"
|
|
if [ -n "${old_id:-}" ]; then
|
|
echo "==> Removing the previous latest.json (id $old_id)"
|
|
curl -fsS -X DELETE "${AUTH[@]}" "$API/releases/$target_id/assets/$old_id" >/dev/null
|
|
fi
|
|
|
|
echo "==> Uploading latest.json to $RELEASE_TAG"
|
|
curl -fsS -X POST "${AUTH[@]}" "$API/releases/$target_id/assets?name=latest.json" \
|
|
-F "attachment=@$work/latest.json" >/dev/null
|
|
|
|
echo "==> Done. $RELEASE_TAG now advertises $APP_VERSION for ${#entries[@]} platform(s)."
|
|
|
|
# --- prune superseded builds from a rolling channel ---------------------------
|
|
#
|
|
# The dev release is republished on every push and its assets otherwise accumulate
|
|
# forever — an AppImage alone is ~100 MB, so a week of pushes is gigabytes on the
|
|
# Git host for builds nobody can reach (the manifest only ever names the newest).
|
|
#
|
|
# Only for a rolling channel. A versioned release must keep its assets: that IS the
|
|
# archive, and the stable pointer's URLs aim at it.
|
|
if [ "${PRUNE_OLD_ASSETS:-false}" = "true" ]; then
|
|
echo "==> Pruning superseded assets from $RELEASE_TAG"
|
|
# Re-read: the manifest upload above changed the asset list.
|
|
current="$(curl -sS "${AUTH[@]}" "$API/releases/$release_id/assets")"
|
|
printf '%s' "$current" \
|
|
| grep -oE '"id"[[:space:]]*:[[:space:]]*[0-9]+[^}]*"name"[[:space:]]*:[[:space:]]*"[^"]+"' \
|
|
| while IFS= read -r row; do
|
|
asset_id="$(printf '%s' "$row" | grep -oE '[0-9]+' | head -1)"
|
|
asset_name="$(printf '%s' "$row" | sed -E 's/.*"name"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')"
|
|
# Keep FIXED-NAME assets and everything belonging to the current build.
|
|
#
|
|
# A fixed name is self-limiting: each publish replaces that same name, so
|
|
# it cannot accumulate and the reason this prune exists does not apply to
|
|
# it. It is also the only kind of URL that stays addressable on a rolling
|
|
# tag, which is the whole point of having one — deleting it breaks
|
|
# whatever was pointing at it.
|
|
#
|
|
# The Android client is on that list for a second reason too: it is built
|
|
# by a DIFFERENT workflow with its own run number, so its version never
|
|
# matches $APP_VERSION here and a version-stamped name would be pruned on
|
|
# every desktop push regardless. That is exactly what happened on run
|
|
# 4098, which swept the APK run 4092 had just published.
|
|
case "$asset_name" in
|
|
latest.json|thoughtsync.apk|thoughtsync-android.json) continue ;;
|
|
*"$APP_VERSION"*) continue ;;
|
|
esac
|
|
echo " removing $asset_name"
|
|
curl -fsS -X DELETE "${AUTH[@]}" "$API/releases/$release_id/assets/$asset_id" >/dev/null || \
|
|
echo " (couldn't remove $asset_name — leaving it)" >&2
|
|
done
|
|
fi
|