feat #14740: fallback update endpoint

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-06 11:41:12 +01:00
co-authored by Claude Opus 5.5
parent 74511d791a
commit bda584deda
4 changed files with 57 additions and 42 deletions
+36 -29
View File
@@ -45,47 +45,53 @@ restarts the app. Debian builds do not update themselves.
- `RELEASE_BASE_URL`: the Gitea repository, - `RELEASE_BASE_URL`: the Gitea repository,
`https://gitea.euvino.eu/public/call-recorder`. The download URLs in `latest.json` `https://gitea.euvino.eu/public/call-recorder`. The download URLs in `latest.json`
point to `${RELEASE_BASE_URL}/releases/download/v<version>/<file>`. point to `${RELEASE_BASE_URL}/releases/download/v<version>/<file>`.
- `UPDATE_JSON_URL`: where the app looks for `latest.json`. `build-release.sh` writes - `UPDATE_JSON_URLS`: where the app looks for `latest.json`. `build-release.sh`
it into `plugins.updater.endpoints` in `src-tauri/tauri.conf.json`. writes them, in this order, into `plugins.updater.endpoints` in
`src-tauri/tauri.conf.json`.
Do not edit the endpoint in `tauri.conf.json` by hand. Change `release.env`; the next Do not edit the endpoints in `tauri.conf.json` by hand. Change `release.env`; the
release build writes the endpoint into `tauri.conf.json`. next release build writes them into `tauri.conf.json`.
The repository and its releases must be readable without logging in: the app The repository and its releases must be readable without logging in: the app
downloads anonymously. downloads anonymously.
### Hosting the feed: two options ### The two feed URLs
The endpoint is compiled into the app. Changing it only affects versions built after The app tries the endpoints in order and uses the first one that returns a release.
the change; installed versions keep asking the old URL. So check the URL right after A `404` or a network error on one moves on to the next one:
the first release, before anyone relies on updates.
**A: `latest.json` as a release asset (default)** 1. `https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json`:
`latest.json` as an asset of the newest release (not a draft, not a pre-release).
This works only if Gitea redirects `releases/latest/download/<file>` to the newest
release.
2. `https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json`:
`latest.json` committed to the root of `master`.
``` Each release serves both:
UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json"
→ https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json
```
Gitea has to redirect `releases/latest/download/<file>` to the newest release (not a - uploading the release assets covers URL 1 (step 7 below);
draft, not a pre-release). That cannot be checked before the first release exists. - committing `latest.json` to the root of `master` covers URL 2 (step 8 below).
Check it right after publishing the first release:
The endpoints are compiled into the app. Installed versions keep asking the URLs
they were built with, which is why both are configured from the start.
After the first release, check which URL works:
```sh ```sh
curl -sIL https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json curl -sIL https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json
curl -sIL https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json
``` ```
The final status must be `200`. If it is `404`, switch to B and release again. The final status of a working URL is `200`. Then:
**B: `latest.json` committed to `master`** - **URL 1 works:** a later version may drop URL 2 from `UPDATE_JSON_URLS`. Every
installed version also asks URL 1, so step 8 is no longer needed.
- **Only URL 2 works:** a later version may drop URL 1. Step 8 (committing
`latest.json`) stays part of every release.
``` Caveat: if URL 1 answered `200` with something that is not JSON (e.g. an HTML page),
UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json" the updater would stop there instead of trying URL 2. Gitea answers a missing file
→ https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json with `404`, which falls through as intended.
```
Comment out the A line in `release.env` and uncomment the B line. As the last step of
every release, commit `latest.json` to the repository root (step 8 below).
## Releasing a version ## Releasing a version
@@ -105,7 +111,7 @@ installed one.
- checks the key and password by signing a probe file, and stops if the key does - checks the key and password by signing a probe file, and stops if the key does
not belong to `plugins.updater.pubkey`, not belong to `plugins.updater.pubkey`,
- sets the version in `src-tauri/tauri.conf.json`, `src-tauri/Cargo.toml` and - sets the version in `src-tauri/tauri.conf.json`, `src-tauri/Cargo.toml` and
`ui/package.json` (the build updates `Cargo.lock` too), and writes the endpoint `ui/package.json` (the build updates `Cargo.lock` too), and writes the endpoints
from `release.env` into `tauri.conf.json`, from `release.env` into `tauri.conf.json`,
- builds the Windows installer (`scripts/build-windows.sh`), the `.deb` and the - builds the Windows installer (`scripts/build-windows.sh`), the `.deb` and the
`.AppImage`, each with its `.sig`, `.AppImage`, each with its `.sig`,
@@ -145,7 +151,7 @@ installed one.
7. Upload **every** file from `dist-release/0.1.1/` as a release asset, including the 7. Upload **every** file from `dist-release/0.1.1/` as a release asset, including the
`.sig` files and `latest.json`. Keep the file names: `latest.json` points to them. `.sig` files and `latest.json`. Keep the file names: `latest.json` points to them.
8. Option B only: once the assets are uploaded, publish the feed: 8. Once the assets are uploaded, publish the feed for URL 2 as well:
```sh ```sh
cp dist-release/0.1.1/latest.json latest.json cp dist-release/0.1.1/latest.json latest.json
@@ -158,10 +164,11 @@ installed one.
```sh ```sh
curl -sL https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json | jq . curl -sL https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json | jq .
curl -sL https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json | jq .
``` ```
(Option B: the `raw/branch/master/latest.json` URL.) It must show the new version, The URL(s) that work must show the new version, and the `url` entries must
and the `url` entries must download. download.
## Checking an update on Windows 11 ## Checking an update on Windows 11
+8 -5
View File
@@ -91,16 +91,19 @@ if [ "${key_of_signature}" != "${key_of_config}" ]; then
fi fi
# --- Version and update feed ------------------------------------------------ # --- Version and update feed ------------------------------------------------
echo "Setting version ${VERSION} and update feed ${UPDATE_JSON_URL}" [ "${#UPDATE_JSON_URLS[@]}" -gt 0 ] || die "UPDATE_JSON_URLS in release.env is empty"
# Rewrites a JSON file in place, keeping its permissions. echo "Setting version ${VERSION} and update feeds ${UPDATE_JSON_URLS[*]}"
# Rewrites a JSON file in place (read from stdin, so `--args` can come
# last), keeping its permissions.
jq_in_place() { jq_in_place() {
local file="$1" local file="$1"
shift shift
jq "$@" "${file}" >"${WORK_DIR}/edit.json" jq "$@" <"${file}" >"${WORK_DIR}/edit.json"
cat "${WORK_DIR}/edit.json" >"${file}" cat "${WORK_DIR}/edit.json" >"${file}"
} }
jq_in_place "${CONF}" --arg version "${VERSION}" --arg url "${UPDATE_JSON_URL}" \ jq_in_place "${CONF}" --arg version "${VERSION}" \
'.version = $version | .plugins.updater.endpoints = [$url]' '.version = $version | .plugins.updater.endpoints = $ARGS.positional' \
--args "${UPDATE_JSON_URLS[@]}"
jq_in_place "${PACKAGE_JSON}" --arg version "${VERSION}" '.version = $version' jq_in_place "${PACKAGE_JSON}" --arg version "${VERSION}" '.version = $version'
# The first `version = …` line is the one of [package]. # The first `version = …` line is the one of [package].
sed -i -E "0,/^version = \"[^\"]*\"/s//version = \"${VERSION}\"/" "${CARGO_TOML}" sed -i -E "0,/^version = \"[^\"]*\"/s//version = \"${VERSION}\"/" "${CARGO_TOML}"
+11 -7
View File
@@ -1,14 +1,18 @@
# Where Gesprächsrekorder releases are published: the one place to change. # Where Gesprächsrekorder releases are published: the one place to change.
# Sourced by build-release.sh, which writes UPDATE_JSON_URL into # Sourced by build-release.sh, which writes UPDATE_JSON_URLS into
# src-tauri/tauri.conf.json (plugins.updater.endpoints), and by # src-tauri/tauri.conf.json (plugins.updater.endpoints), and by
# make-latest-json.sh, which points the download URLs in latest.json at # make-latest-json.sh, which points the download URLs in latest.json at
# ${RELEASE_BASE_URL}/releases/download/v<version>/<file>. See RELEASING.md. # ${RELEASE_BASE_URL}/releases/download/v<version>/<file>. See RELEASING.md.
RELEASE_BASE_URL="https://gitea.euvino.eu/public/call-recorder" RELEASE_BASE_URL="https://gitea.euvino.eu/public/call-recorder"
# Where the app looks for latest.json. # Where the app looks for latest.json, tried in this order until one answers
# A (default): latest.json is an asset of the newest release. # with a release:
UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json" # 1. latest.json as an asset of the newest release,
# B: latest.json is committed to the root of master (if Gitea does not # 2. latest.json committed to the root of master.
# serve releases/latest/download/…): # Once it is clear which one Gitea serves, the other can be dropped here (it
# UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json" # then disappears from the next version built).
UPDATE_JSON_URLS=(
"${RELEASE_BASE_URL}/releases/latest/download/latest.json"
"${RELEASE_BASE_URL}/raw/branch/master/latest.json"
)
+2 -1
View File
@@ -72,7 +72,8 @@
"updater": { "updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwM0EzNUEyMTUwOThERUQKUldUdGpRa1ZvalU2SVBtYVZRaWlWMVBCNzFTd1BRbmtmdU9sZXMrVTltckNiYlRSSmZHcWpNMHUK", "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwM0EzNUEyMTUwOThERUQKUldUdGpRa1ZvalU2SVBtYVZRaWlWMVBCNzFTd1BRbmtmdU9sZXMrVTltckNiYlRSSmZHcWpNMHUK",
"endpoints": [ "endpoints": [
"https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json" "https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json",
"https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json"
], ],
"windows": { "windows": {
"installMode": "passive" "installMode": "passive"