diff --git a/RELEASING.md b/RELEASING.md index b930304..490c168 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -45,47 +45,53 @@ restarts the app. Debian builds do not update themselves. - `RELEASE_BASE_URL`: the Gitea repository, `https://gitea.euvino.eu/public/call-recorder`. The download URLs in `latest.json` point to `${RELEASE_BASE_URL}/releases/download/v/`. -- `UPDATE_JSON_URL`: where the app looks for `latest.json`. `build-release.sh` writes - it into `plugins.updater.endpoints` in `src-tauri/tauri.conf.json`. +- `UPDATE_JSON_URLS`: where the app looks for `latest.json`. `build-release.sh` + 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 -release build writes the endpoint into `tauri.conf.json`. +Do not edit the endpoints in `tauri.conf.json` by hand. Change `release.env`; the +next release build writes them into `tauri.conf.json`. The repository and its releases must be readable without logging in: the app 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 change; installed versions keep asking the old URL. So check the URL right after -the first release, before anyone relies on updates. +The app tries the endpoints in order and uses the first one that returns a release. +A `404` or a network error on one moves on to the next one: -**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/` 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`. -``` -UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json" -→ https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json -``` +Each release serves both: -Gitea has to redirect `releases/latest/download/` to the newest release (not a -draft, not a pre-release). That cannot be checked before the first release exists. -Check it right after publishing the first release: +- uploading the release assets covers URL 1 (step 7 below); +- committing `latest.json` to the root of `master` covers URL 2 (step 8 below). + +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 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. -``` -UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json" -→ https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json -``` - -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). +Caveat: if URL 1 answered `200` with something that is not JSON (e.g. an HTML page), +the updater would stop there instead of trying URL 2. Gitea answers a missing file +with `404`, which falls through as intended. ## 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 not belong to `plugins.updater.pubkey`, - 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`, - builds the Windows installer (`scripts/build-windows.sh`), the `.deb` and the `.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 `.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 cp dist-release/0.1.1/latest.json latest.json @@ -158,10 +164,11 @@ installed one. ```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/raw/branch/master/latest.json | jq . ``` - (Option B: the `raw/branch/master/latest.json` URL.) It must show the new version, - and the `url` entries must download. + The URL(s) that work must show the new version, and the `url` entries must + download. ## Checking an update on Windows 11 diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 3e6e375..211adb7 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -91,16 +91,19 @@ if [ "${key_of_signature}" != "${key_of_config}" ]; then fi # --- Version and update feed ------------------------------------------------ -echo "Setting version ${VERSION} and update feed ${UPDATE_JSON_URL}" -# Rewrites a JSON file in place, keeping its permissions. +[ "${#UPDATE_JSON_URLS[@]}" -gt 0 ] || die "UPDATE_JSON_URLS in release.env is empty" +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() { local file="$1" shift - jq "$@" "${file}" >"${WORK_DIR}/edit.json" + jq "$@" <"${file}" >"${WORK_DIR}/edit.json" cat "${WORK_DIR}/edit.json" >"${file}" } -jq_in_place "${CONF}" --arg version "${VERSION}" --arg url "${UPDATE_JSON_URL}" \ - '.version = $version | .plugins.updater.endpoints = [$url]' +jq_in_place "${CONF}" --arg version "${VERSION}" \ + '.version = $version | .plugins.updater.endpoints = $ARGS.positional' \ + --args "${UPDATE_JSON_URLS[@]}" jq_in_place "${PACKAGE_JSON}" --arg version "${VERSION}" '.version = $version' # The first `version = …` line is the one of [package]. sed -i -E "0,/^version = \"[^\"]*\"/s//version = \"${VERSION}\"/" "${CARGO_TOML}" diff --git a/scripts/release.env b/scripts/release.env index d563923..d302c19 100644 --- a/scripts/release.env +++ b/scripts/release.env @@ -1,14 +1,18 @@ # 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 # make-latest-json.sh, which points the download URLs in latest.json at # ${RELEASE_BASE_URL}/releases/download/v/. See RELEASING.md. RELEASE_BASE_URL="https://gitea.euvino.eu/public/call-recorder" -# Where the app looks for latest.json. -# A (default): latest.json is an asset of the newest release. -UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json" -# B: latest.json is committed to the root of master (if Gitea does not -# serve releases/latest/download/…): -# UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json" +# Where the app looks for latest.json, tried in this order until one answers +# with a release: +# 1. latest.json as an asset of the newest release, +# 2. latest.json committed to the root of master. +# Once it is clear which one Gitea serves, the other can be dropped here (it +# 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" +) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 4e7e084..61aa7ca 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -72,7 +72,8 @@ "updater": { "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwM0EzNUEyMTUwOThERUQKUldUdGpRa1ZvalU2SVBtYVZRaWlWMVBCNzFTd1BRbmtmdU9sZXMrVTltckNiYlRSSmZHcWpNMHUK", "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": { "installMode": "passive"