Skip to content

Commit 5b530c4

Browse files
EVWorthclaude
andauthored
fix(release): build the update manifest from the artifacts the updater can use (#572)
Closes #566, #567, #568. Run against the asset names v0.4.0 actually published, the manifest step maps macOS to the wrong file and discards the right one: SQLPilot_0.4.0_x64.dmg -> darwin-x86_64 SQLPilot_0.4.0_x64.app.tar.gz -> SKIPPED (unknown platform) SQLPilot_0.4.0_aarch64.dmg -> darwin-aarch64 SQLPilot_0.4.0_aarch64.app.tar.gz -> SKIPPED (unknown platform) A .dmg is a distribution format; the macOS updater extracts a .app.tar.gz. The tarballs are built and signed, then dropped by the unknown-platform branch, which prints to the log and continues. This has not shipped. v0.4.0's manifest was produced by tauri-action under an earlier workflow and points at the tarballs correctly. The hand-rolled step that replaced it would have broken macOS on the next release. Three of the eight keys it emits — linux-deb, linux-rpm, windows-x86_64-nsis — are names the updater never looks up, and linux-aarch64 was mapped to an RPM, which the Linux updater cannot apply either. Inert entries are worse than absent ones: they read as though those formats are covered. min_app_version is gone. It was set to the previous tag, and I could not confirm the updater reads the field at all — the only min_app_version documented in this repo belongs to the plugin manifest spec, which is unrelated. If it is ignored, the comment claiming otherwise was wrong; if it is honoured, anyone skipping a single release could never update again. A compatibility floor belongs there only when there is a real incompatibility to describe. Generation moves to scripts/build-update-manifest.sh, which can be run and tested without cutting a release. It emits exactly the four keys the updater reads, each pointing at the one format that platform accepts, and refuses rather than shipping something partial: - a platform with no artifact fails the release, instead of quietly stranding every user on it - an artifact with no .sig, or an empty one, fails - two files matching one glob fails, because choosing between them is not a decision a release script should make - the JSON is assembled by python and read back and checked, so a filename or signature containing a quote cannot produce a manifest that parses as something else The job no longer signs. The bundles were signed during the build, so it reads the .sig files already beside them — which keeps the signing key out of a job that talks to the releases API, and removes the npm install it only needed for `tauri signer`. Eleven tests, run in CI whenever scripts or workflows change. The macOS ones fail against the previous mapping, which is the point: the manifest is the one release artifact nothing downstream validates, so a wrong entry does not fail a build — it fails on a user's machine as an update that never arrives. Co-authored-by: Claude Opus 5 <[email protected]>
1 parent 932ec3b commit 5b530c4

4 files changed

Lines changed: 344 additions & 75 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ jobs:
8181
- '.opencode/AGENTS.md'
8282
workflows:
8383
- '.github/workflows/**'
84+
# Release tooling lives here and is exercised by the same job.
85+
- 'scripts/**'
8486
config:
8587
- 'lefthook.yml'
8688
- 'eslint.config.js'
@@ -144,6 +146,12 @@ jobs:
144146
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145147
run: scripts/check-action-pins.sh
146148

149+
# The update manifest is the one release artifact nothing downstream
150+
# validates: a wrong entry does not fail the build, it fails on a
151+
# user's machine as an update that never arrives (#566).
152+
- name: Test the update manifest builder
153+
run: scripts/test-build-update-manifest.sh
154+
147155
npm-audit:
148156
name: npm Audit
149157
needs: detect-changes

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -285,87 +285,18 @@ jobs:
285285
steps:
286286
- name: Checkout
287287
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
288-
- name: Setup Node.js
289-
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
290-
with:
291-
node-version-file: ".node-version"
292-
cache: "npm"
293-
- name: Install dependencies
294-
run: npm ci
288+
# No Node and no signing key here. The bundles were signed during the
289+
# build, so this job only reads the .sig files already beside them —
290+
# which keeps the signing key out of a job that talks to the releases
291+
# API.
295292
- name: Download release artifacts
296293
env:
297294
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
298295
run: gh release download ${{ github.ref_name }}
299-
- name: Sign artifacts and generate manifest
300-
env:
301-
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
302-
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
303-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
296+
- name: Build the update manifest
304297
run: |
305298
TAG="${{ github.ref_name }}"
306-
VERSION="${TAG#v}"
307-
308-
# Generate signatures for each platform binary
309-
for file in *.AppImage *.deb *.rpm *.msi *.exe *.dmg *.tar.gz; do
310-
[ -f "$file" ] || continue
311-
echo "Signing $file..."
312-
npx tauri signer sign "$file"
313-
done
314-
315-
rm -f /tmp/sign-key
316-
317-
# Build the manifest JSON
318-
echo "{" > update-manifest.json
319-
echo " \"version\": \"$VERSION\"," >> update-manifest.json
320-
321-
# min_app_version: most recent tag excluding the one being shipped.
322-
# Plugin honors this: current-version users whose app is below the
323-
# threshold don't see the update. Falls back to omitting the field
324-
# on the very first release.
325-
PREV_TAG=$(git tag --sort=-v:refname 2>/dev/null | grep -v "^${TAG}$" | head -1 | sed 's/^v//')
326-
if [ -n "$PREV_TAG" ]; then
327-
echo " \"min_app_version\": \"$PREV_TAG\"," >> update-manifest.json
328-
fi
329-
330-
echo " \"notes\": \"See https://github.com/EVWorth/sqlpilot/releases/tag/$TAG\"," >> update-manifest.json
331-
echo " \"pub_date\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"," >> update-manifest.json
332-
echo " \"platforms\": {" >> update-manifest.json
333-
334-
first=true
335-
for sigfile in *.sig; do
336-
[ -f "$sigfile" ] || continue
337-
base="${sigfile%.sig}"
338-
339-
case "$base" in
340-
*_amd64.AppImage) key="linux-x86_64" ;;
341-
*_amd64.deb) key="linux-deb" ;;
342-
*aarch64.rpm) key="linux-aarch64" ;;
343-
*x86_64.rpm) key="linux-rpm" ;;
344-
*_x64_en-US.msi) key="windows-x86_64" ;;
345-
*_x64-setup.exe) key="windows-x86_64-nsis" ;;
346-
*_x64.dmg) key="darwin-x86_64" ;;
347-
*_aarch64.dmg) key="darwin-aarch64" ;;
348-
*) echo "Unknown platform for $sigfile, skipping..." ; continue ;;
349-
esac
350-
351-
# Build download URL matching GitHub's asset naming
352-
url="https://github.com/EVWorth/sqlpilot/releases/download/$TAG/$base"
353-
sig=$(cat "$sigfile")
354-
355-
$first || echo "," >> update-manifest.json
356-
echo " \"$key\": {" >> update-manifest.json
357-
echo " \"url\": \"$url\"," >> update-manifest.json
358-
echo " \"signature\": \"$sig\"" >> update-manifest.json
359-
echo " }" >> update-manifest.json
360-
first=false
361-
done
362-
363-
echo " }" >> update-manifest.json
364-
echo "}" >> update-manifest.json
365-
366-
echo "Generated manifest:"
367-
cat update-manifest.json
368-
mv update-manifest.json latest.json
299+
scripts/build-update-manifest.sh "${TAG#v}" "$TAG" . latest.json
369300

370301
- name: Upload update manifest
371302
env:

‎scripts/build-update-manifest.sh‎

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/usr/bin/env bash
2+
# scripts/build-update-manifest.sh
3+
#
4+
# Build the `latest.json` that tauri-plugin-updater reads.
5+
#
6+
# Usage:
7+
# scripts/build-update-manifest.sh <version> <tag> <artifact-dir> [out-file]
8+
#
9+
# The updater looks up exactly one key per platform, of the form
10+
# {os}-{arch}, and each platform accepts exactly one artifact format:
11+
#
12+
# linux-x86_64 .AppImage (the Linux updater handles no other format)
13+
# windows-x86_64 .msi
14+
# darwin-x86_64 .app.tar.gz (a .dmg is a distribution format the
15+
# darwin-aarch64 .app.tar.gz updater cannot apply)
16+
#
17+
# Anything else the release publishes — .deb, .rpm, .dmg, the NSIS installer,
18+
# the portable .exe — is a download for humans, not an update source. Listing
19+
# them under invented keys like `linux-deb` made the manifest read as though
20+
# they were covered when nothing reads those entries (#566, #567).
21+
#
22+
# Every expected platform must be present. A missing artifact fails the
23+
# release rather than quietly shipping a manifest that strands those users on
24+
# their current version with no signal.
25+
#
26+
# Signatures come from the .sig files the build already produced. This script
27+
# does not sign, and does not need the signing key.
28+
29+
set -euo pipefail
30+
31+
version="${1:?usage: build-update-manifest.sh <version> <tag> <artifact-dir> [out-file]}"
32+
tag="${2:?missing tag}"
33+
dir="${3:?missing artifact directory}"
34+
out="${4:-latest.json}"
35+
36+
repo="${MANIFEST_REPO:-EVWorth/sqlpilot}"
37+
38+
# platform key : glob for the updater artifact
39+
platforms=(
40+
"linux-x86_64:*_amd64.AppImage"
41+
"windows-x86_64:*_x64_en-US.msi"
42+
"darwin-x86_64:*_x64.app.tar.gz"
43+
"darwin-aarch64:*_aarch64.app.tar.gz"
44+
)
45+
46+
missing=()
47+
entries=()
48+
49+
for spec in "${platforms[@]}"; do
50+
key="${spec%%:*}"
51+
glob="${spec#*:}"
52+
53+
# Exactly one match, or the naming has changed under us and guessing which
54+
# one to ship is not a decision a release script should make.
55+
shopt -s nullglob
56+
# Deliberate: $glob is a pattern this script defines, and expanding it is
57+
# the point of the line.
58+
# shellcheck disable=SC2206
59+
matches=("$dir"/$glob)
60+
shopt -u nullglob
61+
62+
if [ ${#matches[@]} -eq 0 ]; then
63+
missing+=("$key (no file matching $glob)")
64+
continue
65+
fi
66+
if [ ${#matches[@]} -gt 1 ]; then
67+
missing+=("$key (${#matches[@]} files match $glob: ${matches[*]##*/})")
68+
continue
69+
fi
70+
71+
artifact="${matches[0]}"
72+
name="$(basename "$artifact")"
73+
sig="$artifact.sig"
74+
75+
if [ ! -f "$sig" ]; then
76+
missing+=("$key ($name has no $name.sig beside it)")
77+
continue
78+
fi
79+
80+
signature="$(cat "$sig")"
81+
if [ -z "$signature" ]; then
82+
missing+=("$key ($name.sig is empty)")
83+
continue
84+
fi
85+
86+
entries+=("$key|https://github.com/$repo/releases/download/$tag/$name|$signature")
87+
done
88+
89+
if [ ${#missing[@]} -gt 0 ]; then
90+
echo "Cannot build the update manifest — these platforms have no usable artifact:" >&2
91+
printf ' %s\n' "${missing[@]}" >&2
92+
echo >&2
93+
echo "Files present in $dir:" >&2
94+
ls -1 "$dir" >&2 || true
95+
exit 1
96+
fi
97+
98+
# Assembled with python rather than string-concatenated, so a signature or a
99+
# filename containing a quote cannot produce a file that is not valid JSON.
100+
python3 - "$version" "$out" "${entries[@]}" <<'PY'
101+
import json
102+
import sys
103+
104+
version, out, *rows = sys.argv[1:]
105+
platforms = {}
106+
for row in rows:
107+
key, url, signature = row.split("|", 2)
108+
platforms[key] = {"url": url, "signature": signature}
109+
110+
# No min_app_version. Set to the previous tag it would strand anyone who
111+
# skipped a release, with no signal to them at all (#568). A compatibility
112+
# floor belongs here only when there is a real incompatibility to describe.
113+
manifest = {
114+
"version": version,
115+
"notes": f"See https://github.com/{__import__('os').environ.get('MANIFEST_REPO', 'EVWorth/sqlpilot')}/releases/tag/v{version}",
116+
"pub_date": __import__("datetime").datetime.now(__import__("datetime").timezone.utc)
117+
.replace(microsecond=0)
118+
.isoformat()
119+
.replace("+00:00", "Z"),
120+
"platforms": platforms,
121+
}
122+
with open(out, "w") as f:
123+
json.dump(manifest, f, indent=2)
124+
f.write("\n")
125+
PY
126+
127+
# Read it back and check it says what it should. A manifest that parses but
128+
# describes the wrong release is the failure this catches.
129+
python3 - "$out" "$version" <<'PY'
130+
import json
131+
import sys
132+
133+
path, expected_version = sys.argv[1], sys.argv[2]
134+
with open(path) as f:
135+
manifest = json.load(f)
136+
137+
problems = []
138+
if manifest.get("version") != expected_version:
139+
problems.append(f"version is {manifest.get('version')!r}, expected {expected_version!r}")
140+
141+
expected = {"linux-x86_64", "windows-x86_64", "darwin-x86_64", "darwin-aarch64"}
142+
actual = set(manifest.get("platforms", {}))
143+
if actual != expected:
144+
problems.append(f"platforms are {sorted(actual)}, expected {sorted(expected)}")
145+
146+
for key, entry in manifest.get("platforms", {}).items():
147+
if not entry.get("url", "").startswith("https://"):
148+
problems.append(f"{key}: url is not https")
149+
if not entry.get("signature"):
150+
problems.append(f"{key}: empty signature")
151+
152+
if problems:
153+
print("The generated manifest is not usable:", file=sys.stderr)
154+
for p in problems:
155+
print(f" {p}", file=sys.stderr)
156+
sys.exit(1)
157+
PY
158+
159+
echo "Wrote $out"
160+
cat "$out"

0 commit comments

Comments
 (0)