diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index e61c89c..21411ed 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -8,16 +8,18 @@ # 2. The plan job says what each platform would promote and links the # builds; read it before approving. # 3. The promote jobs wait on the `production` environment's required -# reviewers. Approve, and they run tool/publish_appcast.sh (macOS) and -# tool/windows/promote_release.ps1 (Windows), with their signing keys -# from that environment's secrets. +# reviewers. Approve, and they run tool/publish_appcast.sh (macOS), +# tool/windows/promote_release.ps1 (Windows) and +# tool/linux/promote_release.sh (Linux), with their signing keys from +# that environment's secrets. # 4. Once they have succeeded, the release is tagged v on GitHub # (tool/tag_release.sh), on the commit that set the version. # # What is promoted is what the chosen commit names (pubspec.yaml's version and -# build, windows/release.json's build), and it must already be uploaded by the -# Release workflow. A platform whose build is already in its appcast is -# skipped, so promoting both after only one changed is safe. +# build, which Linux shares, and windows/release.json's build), and it must +# already be uploaded by the Release workflow. A platform whose build is +# already in its appcast is skipped, so promoting all after only one changed +# is safe. # # One-time setup — secrets, environments, Google Cloud: see the release # specs/release_ci.md. @@ -34,8 +36,8 @@ on: description: Platforms to promote required: true type: choice - default: both - options: [both, macos, windows] + default: all + options: [all, macos, windows, linux] concurrency: group: release @@ -58,6 +60,7 @@ jobs: outputs: macos: ${{ steps.pick.outputs.macos }} windows: ${{ steps.pick.outputs.windows }} + linux: ${{ steps.pick.outputs.linux }} steps: - name: From main only run: | @@ -93,17 +96,22 @@ jobs: MR: ${{ steps.plan.outputs.macos_reason }} W: ${{ steps.plan.outputs.windows }} WR: ${{ steps.plan.outputs.windows_reason }} + L: ${{ steps.plan.outputs.linux }} + LR: ${{ steps.plan.outputs.linux_reason }} run: | - [[ "$WANT" == both || "$WANT" == macos ]] || M=skip - [[ "$WANT" == both || "$WANT" == windows ]] || W=skip + [[ "$WANT" == all || "$WANT" == macos ]] || M=skip + [[ "$WANT" == all || "$WANT" == windows ]] || W=skip + [[ "$WANT" == all || "$WANT" == linux ]] || L=skip failed=0 [[ "$M" == error ]] && { echo "::error title=macOS cannot be promoted::$MR"; failed=1; } [[ "$W" == error ]] && { echo "::error title=Windows cannot be promoted::$WR"; failed=1; } - if [[ "$M" == skip && "$W" == skip && "$failed" == 0 ]]; then - echo "::notice title=Nothing to promote::macOS: $MR. Windows: $WR." + [[ "$L" == error ]] && { echo "::error title=Linux cannot be promoted::$LR"; failed=1; } + if [[ "$M" == skip && "$W" == skip && "$L" == skip && "$failed" == 0 ]]; then + echo "::notice title=Nothing to promote::macOS: $MR. Windows: $WR. Linux: $LR." fi echo "macos=$M" >>"$GITHUB_OUTPUT" echo "windows=$W" >>"$GITHUB_OUTPUT" + echo "linux=$L" >>"$GITHUB_OUTPUT" exit "$failed" - name: Summary @@ -119,6 +127,10 @@ jobs: WB: ${{ steps.plan.outputs.windows_build }} WU: ${{ steps.plan.outputs.windows_url }} WR: ${{ steps.plan.outputs.windows_reason }} + L: ${{ steps.plan.outputs.linux }} + LB: ${{ steps.plan.outputs.linux_build }} + LU: ${{ steps.plan.outputs.linux_url }} + LR: ${{ steps.plan.outputs.linux_reason }} run: | { echo "### Promote $MV ($WANT) from \`${GITHUB_SHA:0:7}\`" @@ -129,6 +141,7 @@ jobs: echo "|---|---|---|---|---|" echo "| macOS | $MB | $M | $MR | ${MU:+<$MU>} |" echo "| Windows | $WB | $W | $WR | ${WU:+<$WU>} |" + echo "| Linux | $LB | $L | $LR | ${LU:+<$LU>} |" } >>"$GITHUB_STEP_SUMMARY" macos: @@ -225,17 +238,54 @@ jobs: Remove-Item $key -Force -ErrorAction SilentlyContinue } + linux: + name: linux (appcast) + needs: plan + if: needs.plan.outputs.linux == 'promote' + runs-on: ubuntu-24.04 + timeout-minutes: 20 + environment: production + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Google Cloud + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ vars.GCP_RELEASE_PROMOTE_SERVICE_ACCOUNT }} + + - uses: google-github-actions/setup-gcloud@v2 + + # Same handling as the other keys: outside the checkout (the script + # refuses one inside it), readable only by this user, gone at the end + # of the step. The script checks it against eddsaPublicKey in + # linux/release.json before signing, and appcast.sh verifies the + # signature it made against that key. + - name: Promote into the appcast + env: + LINUX_KEY: ${{ secrets.LINUX_ED25519_PRIVATE_KEY }} + run: | + [[ -n "$LINUX_KEY" ]] || { echo "::error::secret LINUX_ED25519_PRIVATE_KEY is not set"; exit 1; } + key="$RUNNER_TEMP/linux_ed25519.pem" + (umask 077; printf '%s\n' "$LINUX_KEY" >"$key") + trap 'rm -f "$key"' EXIT + ./tool/linux/promote_release.sh --key="$key" --bucket="$BUCKET" + # The release is live: tag it. On the commit that set the version, which is # the one Release built, not on the head of main (tool/tag_release.sh). Runs - # when neither appcast job failed, including when the plan found both + # when no appcast job failed, including when the plan found them all # already promoted, so a re-run can still add a tag that is missing. tag: name: tag - needs: [plan, macos, windows] + needs: [plan, macos, windows, linux] if: >- !cancelled() && needs.plan.result == 'success' && !contains(fromJSON('["failure", "cancelled"]'), needs.macos.result) && - !contains(fromJSON('["failure", "cancelled"]'), needs.windows.result) + !contains(fromJSON('["failure", "cancelled"]'), needs.windows.result) && + !contains(fromJSON('["failure", "cancelled"]'), needs.linux.result) runs-on: ubuntu-latest timeout-minutes: 5 permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79670cf..bcc68c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,9 @@ # Runs after CI passes on a push to main. When the commit names a build that # is not in the bucket yet (`make set_version` was run and committed, or # windows/release.json's build was bumped), it uploads that build exactly as -# `make publish` and tool/windows/publish_release.ps1 do: an immutable object -# under releases/, and the "preview" entry of downloads/.json. The appcast +# `make publish`, tool/windows/publish_release.ps1 and +# tool/linux/publish_release.sh do: an immutable object under releases/, and +# the "preview" entry of downloads/.json. The appcast # is never touched, so no installed copy is offered the build. Test it from # the URL in the run summary on a clean machine, then run the Promote # workflow (promote.yml), which is the half that reaches users. @@ -15,7 +16,8 @@ # # macOS is built, signed and notarized here, as `make build` does locally. The # Windows installer is the one the CI run for the same commit already built -# (ci.yml, `windows installer`), unsigned for now. +# (ci.yml, `windows installer`), unsigned for now. The Linux AppImage is +# built here with `make appimage`, on the oldest Ubuntu it supports. # # One-time setup — secrets, environments, Google Cloud: see the release # specs/release_ci.md. @@ -83,6 +85,11 @@ jobs: windows_build: ${{ steps.plan.outputs.windows_build }} windows_url: ${{ steps.plan.outputs.windows_url }} windows_reason: ${{ steps.plan.outputs.windows_reason }} + linux: ${{ steps.plan.outputs.linux }} + linux_version: ${{ steps.plan.outputs.linux_version }} + linux_build: ${{ steps.plan.outputs.linux_build }} + linux_url: ${{ steps.plan.outputs.linux_url }} + linux_reason: ${{ steps.plan.outputs.linux_reason }} steps: - name: The commit and its CI run id: ci @@ -96,6 +103,9 @@ jobs: # "cancelled" by running out its time — what the removed socket # canary did on every run. REQUIRED: macos-latest|windows-latest|windows installer + # Linux also needs its own test job; macOS and Windows do not wait + # on it. + REQUIRED_LINUX: ubuntu-24.04 run: | if [[ "$EVENT" == workflow_run ]]; then sha="$RUN_SHA" run="$RUN_ID" @@ -123,6 +133,12 @@ jobs: for job in "${required[@]}"; do grep -qxF "$job"$'\t'success <<<"$jobs" || missing+="${missing:+, }$job" done + linux_missing="" + IFS='|' read -ra required_linux <<<"$REQUIRED_LINUX" + for job in "${required_linux[@]}"; do + grep -qxF "$job"$'\t'success <<<"$jobs" || linux_missing+="${linux_missing:+, }$job" + done + echo "linux_missing=$linux_missing" >>"$GITHUB_OUTPUT" if [[ -z "$missing" ]]; then echo "ok=true" >>"$GITHUB_OUTPUT" elif [[ "$EVENT" == workflow_run ]]; then @@ -142,6 +158,7 @@ jobs: id: plan env: CI_OK: ${{ steps.ci.outputs.ok }} + LINUX_MISSING: ${{ steps.ci.outputs.linux_missing }} TEST_MACOS: ${{ inputs.test_macos_build || false }} run: | if [[ "$CI_OK" != true ]]; then @@ -150,16 +167,27 @@ jobs: echo "macos_reason=CI did not pass on this commit" echo "windows=skip" echo "windows_reason=CI did not pass on this commit" + echo "linux=skip" + echo "linux_reason=CI did not pass on this commit" } | tee -a "$GITHUB_OUTPUT" exit 0 fi ./tool/release_plan.sh upload | tee -a "$GITHUB_OUTPUT" + # A later key=value line wins in $GITHUB_OUTPUT. + if [[ -n "$LINUX_MISSING" ]]; then + { + echo "linux=skip" + echo "linux_reason=CI did not pass on this commit: $LINUX_MISSING" + } | tee -a "$GITHUB_OUTPUT" + fi if [[ "$TEST_MACOS" == true ]]; then { echo "macos=test" echo "macos_reason=test build: signed and notarized, not uploaded" echo "windows=skip" echo "windows_reason=test build of macOS only" + echo "linux=skip" + echo "linux_reason=test build of macOS only" } | tee -a "$GITHUB_OUTPUT" fi @@ -169,6 +197,8 @@ jobs: MR: ${{ steps.plan.outputs.macos_reason }} W: ${{ steps.plan.outputs.windows }} WR: ${{ steps.plan.outputs.windows_reason }} + L: ${{ steps.plan.outputs.linux }} + LR: ${{ steps.plan.outputs.linux_reason }} SHA: ${{ steps.ci.outputs.sha }} run: | { @@ -178,6 +208,7 @@ jobs: echo "|---|---|---|" echo "| macOS | $M | $MR |" echo "| Windows | $W | $WR |" + echo "| Linux | $L | $LR |" } >>"$GITHUB_STEP_SUMMARY" macos: @@ -383,3 +414,82 @@ jobs: echo echo "Then run the **Promote** workflow to make it the live update." } >>"$GITHUB_STEP_SUMMARY" + + linux: + name: linux (build the AppImage, upload) + needs: plan + if: needs.plan.outputs.linux != 'skip' + # The oldest Ubuntu the AppImage supports (glibc 2.38, specs/linux_appimage.md + # C1). A newer image can raise the glibc the bundle needs, and then + # build_appimage.sh stops at its glibc check rather than ship a build + # that no longer starts where the download page says it does. + runs-on: ubuntu-24.04 + timeout-minutes: 60 + environment: release-upload + permissions: + contents: read + id-token: write # Workload Identity Federation into Google Cloud + steps: + - name: Stop on a build number that is taken + if: needs.plan.outputs.linux == 'error' + env: + REASON: ${{ needs.plan.outputs.linux_reason }} + run: | + echo "::error title=Linux not uploaded::$REASON. Run 'make set_version V=…' and commit pubspec.yaml and windows/release.json." + exit 1 + + - uses: actions/checkout@v4 + with: + ref: ${{ needs.plan.outputs.sha }} + + # Flutter's Linux desktop toolchain, and what build_appimage.sh needs + # besides (curl, python3, readelf and strip). + - name: Linux build dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev \ + libstdc++-12-dev curl python3 binutils + + - uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.47.7 + cache: true + + # CEF is downloaded by the first CMake configure, and appimagetool and + # its runtime are fetched pinned and sha256-checked by the script. None + # of it is cached: these are the bytes we ship, as on macOS. + - name: Build the AppImage + run: | + flutter pub get + make appimage + + - name: Google Cloud + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ vars.GCP_RELEASE_UPLOAD_SERVICE_ACCOUNT }} + + - uses: google-github-actions/setup-gcloud@v2 + + # Every gate runs again here: the build number against the live Linux + # appcast, the AppImage's own version against pubspec, a feed and a key + # in linux/release.json. + - name: Upload (preview only, the appcast is untouched) + run: ./tool/linux/publish_release.sh --bucket="$BUCKET" + + - name: Summary + env: + V: ${{ needs.plan.outputs.linux_version }} + B: ${{ needs.plan.outputs.linux_build }} + URL: ${{ needs.plan.outputs.linux_url }} + run: | + { + echo "### Linux $V (build $B) uploaded" + echo + echo "Not in the appcast: no installed copy is offered it yet." + echo "Test it on a clean Ubuntu 24.04 or newer: <$URL>" + echo + echo "Then run the **Promote** workflow to make it the live update." + } >>"$GITHUB_STEP_SUMMARY" diff --git a/.gitignore b/.gitignore index 4f95455..ae1af5e 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,12 @@ app.*.map.json # Release / distribution artifacts /dist/ +# Update signing keys and local test feeds never belong in git: a private key +# here is one `git add -A` from public, and a test feed or test public key +# committed would ship in a release (specs/release_ci.md). +*.pem +/appcast*.xml + # --- macOS / Xcode / CocoaPods --- /macos/Flutter/ephemeral/ /macos/Pods/ diff --git a/AGENTS.md b/AGENTS.md index 7f8162c..fcb8b8b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1069,15 +1069,25 @@ full rationale are in `specs/release_ci.md`. Mac). **Windows is the installer artifact from the CI run of the same commit**, unsigned. - **Windows is skipped while `windows/release.json` lacks `appcastUrl` or - `eddsaPublicKey`.** A build without them never checks for updates. + `eddsaPublicKey`, and Linux while `linux/release.json` does.** A build + without them never checks for updates. +- **Linux is built in Release itself**, `make appimage` on `ubuntu-24.04` + (the oldest Ubuntu it supports, so the glibc check in + `build_appimage.sh` holds), and uploaded by `tool/linux/publish_release.sh` + with the macOS gates. Its build number is pubspec's, so `set_version.sh` + also clears the Linux appcast and `downloads/linux.json`. + `tool/publish_downloads.sh --platform=linux` writes that pointer. - **`promote.yml` is `workflow_dispatch` only.** You type the version as confirmation, it runs from `main`, and the promote jobs wait for the `production` environment's required reviewers. The keys come from that environment's secrets as files in the runner's temp directory: `SPARKLE_ED_KEY_FILE` for `publish_appcast.sh`, which checks the derived - public key (`tool/lib/eddsa_public_key.py`) against the shipped one, and + public key (`tool/lib/eddsa_public_key.py`) against the shipped one, `-PrivateKeyFile` for `promote_release.ps1`, which checks against - `release.json` and verifies its own signature. + `release.json` and verifies its own signature, and `--key` for + `tool/linux/promote_release.sh`, which signs the bucket's object with + `appcast.sh` (verified against `linux/release.json`) and refuses to write + the production feed anywhere but that file's `appcastUrl`. - **Google Cloud is Workload Identity Federation**, with no JSON keys. There are two service accounts, each bound to one environment. The uploader can only *create* under `releases/`, so IAM now enforces the immutability too. @@ -2395,7 +2405,10 @@ change is behaviour-neutral on all three (a null check, say). start page, unless another tool's entry already names App Studio. - **Updates** (`lib/update/linux/`) are App Studio's own, from a Sparkle appcast with an Ed25519 signature over the file, written by - `tool/linux/appcast.sh`. The feed URL and public key are in + `tool/linux/appcast.sh`. Release and Promote run it in CI like the other + two platforms (`specs/release_ci.md`): `appcast/linux/appcast.xml`, + `downloads/linux.json`, `releases/linux//b/`, and the key in the + `LINUX_ED25519_PRIVATE_KEY` secret. The feed URL and public key are in `linux/release.json`; both empty means no updates, and the build refuses only one. The feed itself is not signed: nothing from it but the file may be trusted, which is why the version is validated before it reaches the diff --git a/Makefile b/Makefile index 827b0a7..86cfe15 100644 --- a/Makefile +++ b/Makefile @@ -209,9 +209,11 @@ promote: # --------------------------------------------------------------------------- # Linux # -# Builds on the machine it runs on and uploads nothing: hosting, the update -# feed and the release pipeline are Serverpod's. CEF downloads during the first CMake -# configure, so there is no deps step. FLUTTER, SKIP_BUILD, APPIMAGETOOL, +# Builds on the machine it runs on and uploads nothing. Releases are built and +# uploaded by .github/workflows/release.yml (tool/linux/publish_release.sh) +# and promoted by promote.yml (tool/linux/promote_release.sh); see +# specs/release_ci.md. CEF downloads during the first CMake configure, so +# there is no deps step. FLUTTER, SKIP_BUILD, APPIMAGETOOL, # APPIMAGE_UPDATE_INFO and APPIMAGE_FILE_URL are read from the environment; # see the script. # --------------------------------------------------------------------------- diff --git a/specs/linux_appimage.md b/specs/linux_appimage.md index b2a11a0..ab23b8c 100644 --- a/specs/linux_appimage.md +++ b/specs/linux_appimage.md @@ -28,7 +28,9 @@ Studio. **B is built and tested against a local feed.** Where builds are hosted, the feed's URL and the signing key are Serverpod's to decide: until `linux/release.json` names a feed and a key, a release build reports updates -as unavailable, as a build without them does on Windows. The AppImage still +as unavailable, as a build without them does on Windows. The release +workflows build, upload and promote the AppImage once it does +(`specs/release_ci.md`, step 5 of the one-time setup). The AppImage still carries no `.zsync` update information for Gear Lever; that is a separate choice for the same people (`specs/linux_port.md` 4.5). @@ -428,6 +430,9 @@ the AppImage carries update information. - `tool/linux/appcast.sh`: signs an AppImage and adds it to a feed, newest first, refusing a build number the feed already has or has passed, and checking the signature against the key in `linux/release.json`. +- `tool/linux/publish_release.sh` and `tool/linux/promote_release.sh`: the + two halves of a release, run by `.github/workflows/release.yml` and + `promote.yml` (`specs/release_ci.md`). --- diff --git a/specs/linux_port.md b/specs/linux_port.md index 64c0dc4..e3c1edf 100644 --- a/specs/linux_port.md +++ b/specs/linux_port.md @@ -385,7 +385,10 @@ macOS and Windows CI green. ### Serverpod's side - CI (a Linux job, if wanted), the release pipeline, and the update feed's - hosting and signing key, using the build scripts from PR 4. + hosting and signing key, using the build scripts from PR 4. CI runs the + suite on `ubuntu-24.04`, and the release workflows build, upload and + promote the AppImage (`specs/release_ci.md`); the key and + `linux/release.json` are still to be set. --- @@ -469,4 +472,4 @@ After Tuesday: - [x] AppImage: Add to Applications and in-app updates - [ ] `.deb` and `.rpm`, only if asked - [ ] PR 5: Polish ("Open in…" editors, notifications, uninstall) -- [ ] Build scripts handed over for Serverpod's CI and release pipeline +- [x] Build scripts handed over for Serverpod's CI and release pipeline diff --git a/specs/release_ci.md b/specs/release_ci.md index ecb5a92..45ee92d 100644 --- a/specs/release_ci.md +++ b/specs/release_ci.md @@ -5,7 +5,7 @@ Mac, with the same scripts and the same gates. | Workflow | Runs | Does | Reaches users | |---|---|---|---| -| `release.yml` | after CI passes on a push to `main`, or by hand | builds, signs and notarizes macOS; takes the Windows installer CI built; uploads both, preview only | no | +| `release.yml` | after CI passes on a push to `main`, or by hand | builds, signs and notarizes macOS; takes the Windows installer CI built; builds the Linux AppImage; uploads all three, preview only | no | | `promote.yml` | by hand only, after a reviewer approves | adds the uploaded builds to the appcasts | yes | ## When something is uploaded @@ -17,6 +17,10 @@ Mac, with the same scripts and the same gates. `releases/macos/X.Y.Z/bN/AppStudio-X.Y.Z-arm64.zip`. - Windows: the same `X.Y.Z` plus `windows/release.json`'s `build`, object `releases/windows/X.Y.Z/bN/AppStudio-X.Y.Z-x64-setup.exe`. +- Linux: the same `X.Y.Z+N` as macOS (Linux has no counter of its own, + `specs/linux_appimage.md` B4), object + `releases/linux/X.Y.Z/bN/AppStudio-X.Y.Z-x86_64.AppImage`, checked against + the Linux appcast and `downloads/linux.json`. If the object's `.sha256` sidecar is already in the bucket, that platform is skipped. This is the case for most pushes, and the run takes seconds. If it is @@ -36,30 +40,34 @@ This is the recommended answer to "upload when the version changes, or what?": - **Only commits that passed CI are released.** The workflow is chained to CI (`workflow_run`), and the Windows installer is the very artifact CI built and tested alongside. "Passed" means the `macos-latest`, `windows-latest` - and `windows installer` jobs succeeded. Release checks those jobs by name, - so a job added to CI later that is allowed to fail cannot block a - release. + and `windows installer` jobs succeeded; Linux also needs `ubuntu-24.04`, + and only Linux waits on it. Release checks those jobs by name, so a job + added to CI later that is allowed to fail cannot block a release. So a release is: ```bash -make set_version V=1.2.3 # both build counters, from the live bucket +make set_version V=1.2.3 # both build counters (Linux shares pubspec's), from the live bucket git commit -am "chore: Release 1.2.3." && git push ``` `make set_version` writes `pubspec.yaml` (macOS counter) and `windows/release.json` (Windows counter). Each new number clears that -platform's appcast and download manifest, so neither can repeat. +platform's appcast and download manifest, so neither can repeat. Linux +carries pubspec's number, so the pubspec number clears the Linux appcast and +`downloads/linux.json` as well: a Linux upload can get ahead of macOS when +the macOS job fails after it, and a number handed out again would make +Release skip Linux for the new commit. Watch **Actions → Release**. Its summary shows the direct download URL of each -upload. Install those builds on a clean Mac and a clean PC. When they check -out, run **Actions → Promote → Run workflow** on `main`, type `1.2.3`, and -approve the `production` deployment. +upload. Install those builds on a clean Mac, a clean PC and a clean Ubuntu +24.04 or newer. When they check out, run **Actions → Promote → Run +workflow** on `main`, type `1.2.3`, and approve the `production` deployment. **Windows is skipped until `windows/release.json` has `appcastUrl` and -`eddsaPublicKey`.** That is today's state. A build without them never checks -for updates, so anyone who installed it would stay on it. Step 4 below sets -them. +`eddsaPublicKey`, and Linux until `linux/release.json` has them.** That is +today's state. A build without them never checks for updates, so anyone who +installed it would stay on it. Steps 4 and 5 below set them. **Testing the signing setup without a release:** run **Actions → Release → Run workflow** with *test_macos_build* ticked. It builds, signs and notarizes @@ -74,8 +82,9 @@ uploaded and newer than its appcast; a platform already promoted is skipped. The plan job ends before anyone is asked to approve if a platform you asked for cannot be promoted. -The `macos` and `windows` jobs then wait for a `production` reviewer. Once -approved, they run: +Platforms is `all` by default, or one of `macos`, `windows`, `linux`. The +`macos`, `windows` and `linux` jobs then wait for a `production` reviewer. +Once approved, they run: - `tool/publish_appcast.sh` with `SPARKLE_ED_KEY_FILE` set. It checks the key's public half against `SPARKLE_PUBLIC_ED_KEY` in `Sparkle.xcconfig` (derived @@ -85,17 +94,26 @@ approved, they run: `eddsaPublicKey` in `windows/release.json` (`winsparkle-tool public-key`), and checks the new signature against that same public key (`winsparkle-tool verify`). +- `tool/linux/promote_release.sh --key=…`. It downloads the AppImage from the + bucket origin and checks it against its `.sha256` sidecar, checks the key + against `eddsaPublicKey` in `linux/release.json`, and refuses to publish a + feed at any other URL than the `appcastUrl` there (on the production + bucket). `tool/linux/appcast.sh` then signs it, verifies the signature + against the shipped key, and inserts the item, newest first; the script + checks the result names this build, the CDN URL and the object's length, + and carries every earlier item over unchanged. Each key is written to the runner's temp directory, outside the checkout, and deleted when its step ends. Then a `tag` job tags the release **`v`** (`tool/tag_release.sh`), -with the macOS and Windows build numbers in the tag's message. It tags the +with the macOS and Windows build numbers in the tag's message, and the Linux +one once `linux/release.json` has a feed. It tags the commit that set the version, the oldest one whose `pubspec.yaml` adds `version: X.Y.Z+N`. That's the commit Release built. The head of `main` may have moved on while the preview was being tested. A tag is never moved: if `v` already marks another commit (a `V=build` rebuild of a tagged -version), the job leaves it and says so. It runs whenever neither appcast job +version), the job leaves it and says so. It runs whenever no appcast job failed, so re-running Promote adds a tag that is missing. **One case needs a hand:** when `.github/workflows/` changed between the @@ -253,7 +271,54 @@ Commit it. The next Release run uploads Windows build 1 as a preview. Builds from before this commit have no feed and will never update themselves; reinstall them by hand. -### 5. Google Cloud: Workload Identity Federation, no JSON keys +### 5. The Linux update key and `linux/release.json` + +A key of its own: never the Sparkle or WinSparkle key. **If it is lost, +every installed Linux copy can never update again**: they all carry its +public half, and recovering means a new key, a build everyone downloads by +hand, and telling them. + +The feed follows the layout of the other two, +`https://asdl.serverpod.dev/appcast/linux/appcast.xml`, with the releases at +`releases/linux/X.Y.Z/bN/AppStudio-X.Y.Z-x86_64.AppImage`. Builds compile +that URL in, and promote refuses to write the production feed anywhere else, +so settle it before the first build ships. + +The key is Ed25519 in PEM, as `tool/linux/appcast.sh` reads it. It needs +OpenSSL 3: on a Mac that is Homebrew's (`brew install openssl@3`), since +macOS's own `openssl` is LibreSSL and does not know Ed25519. + +```bash +OPENSSL=$(brew --prefix openssl@3)/bin/openssl # on Linux: OPENSSL=openssl +d=$(mktemp -d); chmod 700 "$d" +$OPENSSL genpkey -algorithm ed25519 -out "$d/linux_update.pem" +$OPENSSL pkey -in "$d/linux_update.pem" -pubout -outform DER | tail -c 32 | base64 # the public key +gh secret set LINUX_ED25519_PRIVATE_KEY --env production --repo $REPO < "$d/linux_update.pem" +# back it up next to the Sparkle and WinSparkle keys, but separately from them, then: +rm -P "$d/linux_update.pem"; rmdir "$d" # on Linux: shred -u, then rmdir +``` + +Set `linux/release.json`: + +```json +{ + "appcastUrl": "https://asdl.serverpod.dev/appcast/linux/appcast.xml", + "eddsaPublicKey": "" +} +``` + +**Commit it together with a version bump** (`make set_version V=…`). Linux +takes pubspec's version and build, and nothing of Linux is in the bucket +yet. So the first Release run after this commit uploads a Linux build of +whatever pubspec names. Without a bump, that build would carry the version +macOS already shipped, built from later code. Builds from before this commit +have no feed and never check for updates. + +No Google Cloud change is needed: the bucket roles in step 6 are scoped by +prefix (`releases/`, `appcast/`, `downloads/`), which the Linux paths sit +under, and the CDN invalidator covers any path. + +### 6. Google Cloud: Workload Identity Federation, no JSON keys GitHub's OIDC token is exchanged for a short-lived token of one of two service accounts. Each account is bound to exactly one GitHub environment of @@ -350,7 +415,7 @@ done The scripts treat invalidation as best-effort. If it is missing, the log shows a warning and the cache expires within its max-age. -### 6. GitHub variables +### 7. GitHub variables These are not secrets. They identify; they grant nothing on their own. @@ -372,6 +437,7 @@ gh variable set GCP_RELEASE_PROMOTE_SERVICE_ACCOUNT --repo $REPO --body $PROMOTE | `APPLE_NOTARY_API_ISSUER_ID` | `release-upload` | the team's Issuer ID | | `SPARKLE_ED25519_PRIVATE_KEY` | `production` | `generate_keys -x` output | | `WINSPARKLE_ED25519_PRIVATE_KEY` | `production` | the WinSparkle key file | +| `LINUX_ED25519_PRIVATE_KEY` | `production` | the Linux update key, Ed25519 PEM (`openssl genpkey`) | ## If something fails @@ -379,7 +445,7 @@ gh variable set GCP_RELEASE_PROMOTE_SERVICE_ACCOUNT --repo $REPO --body $PROMOTE succeeded.** GitHub's token was accepted, but its subject matches no `workloadIdentityUser` binding on the service account. Compare the bindings with `gh api repos/serverpod/appstudio/actions/oidc/customization/sub` (step - 5). + 6). - **`storage.buckets.get` denied on upload.** This version of gcloud reads bucket metadata before a copy. Grant both accounts a role with only that permission on the bucket. @@ -394,3 +460,52 @@ gh variable set GCP_RELEASE_PROMOTE_SERVICE_ACCOUNT --repo $REPO --body $PROMOTE - **Promote: "the signing key does not match".** The secret is not the key the app ships. Do not change the shipped key to make it match: every installed copy has the old one. +- **Linux: "The bundle needs glibc X, not 2.38".** `build_appimage.sh` reads + the highest `GLIBC_x.y` the bundle references and stops when it changes, + because the "needs a newer Linux" message and the download page name + distributions for that version. Check which version the bundle now needs + and why (a new runner image, a new CEF). Then update `glibc_expected` and + `glibc_examples` in `tool/linux/build_appimage.sh` and the download page + text in `specs/linux_appimage.md` (part D). Do not lower the check. The + job builds on `ubuntu-24.04`, the oldest Ubuntu the AppImage supports; + keep it there. +- **Linux promote: "builds read their updates from …".** The `appcastUrl` + in `linux/release.json` is not the feed this bucket's CDN serves. Fix the + file, never the check: builds already out there read the URL they were + built with. + +## Testing the Linux half before it reaches users + +1. **Locally, against a test feed.** On Linux, build twice with a test key's + public half and a local feed, bumping the version in between (wait a few + seconds after the bump if VS Code is open: its Dart extension runs `pub + get` on pubspec changes and races the build): + + ```bash + openssl genpkey -algorithm ed25519 -out /tmp/test.pem # outside the repo + export APPSTUDIO_EDDSA_PUBLIC_KEY=$(openssl pkey -in /tmp/test.pem -pubout -outform DER | tail -c 32 | base64 -w0) + export APPSTUDIO_APPCAST_URL=http://127.0.0.1:8000/appcast.xml + make appimage && cp dist/linux/*.AppImage /tmp/feed/old.AppImage + # bump the version, then: + make appimage && cp dist/linux/*.AppImage /tmp/feed/new.AppImage + tool/linux/appcast.sh --key /tmp/test.pem --url http://127.0.0.1:8000/new.AppImage \ + --feed /tmp/feed/appcast.xml /tmp/feed/new.AppImage + (cd /tmp/feed && python3 -m http.server 8000) + ``` + + Start `old.AppImage`: Help → Check for Updates must offer the new one, + install it and restart into it. Keep the key, the feed and the test + public key out of the repo (`.gitignore` covers `*.pem` and + `/appcast*.xml` at the root), and put `pubspec.yaml` back. +2. **The scripts, dry.** `tool/linux/publish_release.sh --dry-run` runs + every upload gate on the built AppImage. `tool/linux/promote_release.sh + --key=… --dry-run` signs the uploaded build into a copy of the live feed + and leaves it in a temporary folder it names, without uploading. +3. **A staging bucket.** Both scripts take `--bucket=NAME` (and + `--impersonate-service-account=SA`), like the macOS ones; on a bucket + other than production every URL is that bucket's origin and nothing is + invalidated. The promoted feed must hold the item with the right URL, + length, build and signature. +4. **The real thing.** Install the previous public build on a clean Ubuntu + 24.04 or newer, promote the new one, and check that the app offers and + installs it. diff --git a/test/tool/release_plan_test.dart b/test/tool/release_plan_test.dart new file mode 100644 index 0000000..7917ff3 --- /dev/null +++ b/test/tool/release_plan_test.dart @@ -0,0 +1,150 @@ +@TestOn('mac-os || linux') +@Tags(['tool']) +library; + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:path/path.dart' as p; + +/// What `tool/release_plan.sh` tells the release workflows to do for Linux. +/// +/// The bucket is a folder read through curl's `file://` support +/// (`ORIGIN_BASE_URL`), so nothing here reaches the network. +void main() { + final root = Directory.current.path; + final plan = p.join(root, 'tool', 'release_plan.sh'); + const object = + 'releases/linux/1.2.3/b20/AppStudio-1.2.3-x86_64.AppImage'; + + late Directory tmp; + late Directory origin; + late String pubspec; + late String linuxJson; + + setUp(() async { + tmp = await Directory.systemTemp.createTemp('release_plan'); + origin = await Directory(p.join(tmp.path, 'bucket')).create(); + pubspec = p.join(tmp.path, 'pubspec.yaml'); + await File(pubspec).writeAsString('name: appstudio\nversion: 1.2.3+20\n'); + linuxJson = p.join(tmp.path, 'linux_release.json'); + await configureLinux(linuxJson, configured: true); + }); + + tearDown(() async { + if (await tmp.exists()) await tmp.delete(recursive: true); + }); + + /// Writes [path] (relative to the fake bucket). + Future put(String path, String contents) async { + final file = File(p.join(origin.path, path)); + await file.parent.create(recursive: true); + await file.writeAsString(contents); + } + + /// A Linux appcast as tool/linux/appcast.sh writes it. + String linuxFeed(List builds) { + final items = builds + .map( + (b) => '', + ) + .join('\n'); + return '' + '$items'; + } + + /// Runs the plan and returns its `linux*` outputs. + Future> run(String mode) async { + final result = await Process.run( + '/bin/bash', + [plan, mode], + environment: { + 'PUBSPEC': pubspec, + 'LINUX_RELEASE_JSON': linuxJson, + 'ORIGIN_BASE_URL': 'file://${origin.path}/', + }, + ); + expect(result.exitCode, 0, reason: result.stderr as String); + return { + for (final line in (result.stdout as String).split('\n')) + if (line.startsWith('linux')) + line.substring(0, line.indexOf('=')): + line.substring(line.indexOf('=') + 1), + }; + } + + group('upload', () { + test('skips Linux while linux/release.json has no feed or key', () async { + await configureLinux(linuxJson, configured: false); + final out = await run('upload'); + expect(out['linux'], 'skip'); + expect(out['linux_reason'], contains('linux/release.json')); + expect(out['linux_build'], '20', reason: "pubspec's counter"); + }); + + test('uploads a new build, to the public URL of its object', () async { + final out = await run('upload'); + expect(out['linux'], 'upload'); + expect(out['linux_version'], '1.2.3'); + expect(out['linux_build'], '20'); + expect(out['linux_url'], 'https://asdl.serverpod.dev/$object'); + }); + + test('skips a build whose sidecar is already uploaded', () async { + await put('$object.sha256', 'abc AppStudio-1.2.3-x86_64.AppImage\n'); + expect((await run('upload'))['linux'], 'skip'); + }); + + test('stops on a number the Linux appcast has passed', () async { + await put('appcast/linux/appcast.xml', linuxFeed([20])); + final out = await run('upload'); + expect(out['linux'], 'error'); + expect(out['linux_reason'], contains('bump the build number')); + }); + + test('stops on a number downloads/linux.json already names', () async { + // Uploaded but not yet promoted: only the pointer knows it. + await put('downloads/linux.json', + '{"latest": {"build": 18}, "preview": {"build": 20}}'); + expect((await run('upload'))['linux'], 'error'); + }); + + test("reads the Linux feeds, not the macOS ones", () async { + await put('appcast/macos/appcast.xml', + '30' + ''); + expect((await run('upload'))['linux'], 'upload'); + }); + }); + + group('promote', () { + test('promotes an uploaded build newer than the appcast', () async { + await put('$object.sha256', 'abc AppStudio-1.2.3-x86_64.AppImage\n'); + await put('appcast/linux/appcast.xml', linuxFeed([19])); + final out = await run('promote'); + expect(out['linux'], 'promote'); + expect(out['linux_reason'], contains('replaces build 19')); + }); + + test('skips a build already in the appcast', () async { + await put('$object.sha256', 'abc AppStudio-1.2.3-x86_64.AppImage\n'); + await put('appcast/linux/appcast.xml', linuxFeed([20, 19])); + expect((await run('promote'))['linux'], 'skip'); + }); + + test('stops on a build that was never uploaded', () async { + final out = await run('promote'); + expect(out['linux'], 'error'); + expect(out['linux_reason'], contains('has not been uploaded')); + }); + }); +} + +Future configureLinux(String path, {required bool configured}) => + File(path).writeAsString(configured + ? '{"appcastUrl": "https://asdl.serverpod.dev/appcast/linux/appcast.xml", ' + '"eddsaPublicKey": "${'A' * 43}="}' + : '{"appcastUrl": "", "eddsaPublicKey": ""}'); diff --git a/test/tool/version_gate_test.dart b/test/tool/version_gate_test.dart index 183ab73..77aba8e 100644 --- a/test/tool/version_gate_test.dart +++ b/test/tool/version_gate_test.dart @@ -199,6 +199,8 @@ void main() { required String pubspec, required String appcastUrl, String downloadsUrl = 'file:///nonexistent/macos.json', + String linuxAppcastUrl = 'file:///nonexistent/linux.xml', + String linuxDownloadsUrl = 'file:///nonexistent/linux.json', }) async { final result = await Process.run( '/bin/bash', @@ -207,6 +209,8 @@ void main() { 'PUBSPEC': pubspec, 'APPCAST_URL': appcastUrl, 'DOWNLOADS_URL': downloadsUrl, + 'LINUX_APPCAST_URL': linuxAppcastUrl, + 'LINUX_DOWNLOADS_URL': linuxDownloadsUrl, }, ); return ( @@ -267,6 +271,46 @@ void main() { expect(text, contains('version: 1.0.1+10')); }); + test('clears a build only the Linux feeds have seen', () async { + // Linux shares pubspec's counter. When the macOS job fails after the + // Linux one uploaded b9, only the Linux pointer knows b9; handing it + // out again would make Release skip Linux for the new commit. + final pubspec = await pubspecWith('1.0.0+8'); + final feed = await appcastWith([7]); + final linux = File(p.join(tmp.path, 'linux.json')); + await linux.writeAsString( + '{"latest": {"build": 7}, "preview": {"build": 9}}', + ); + final (code, text, _) = await run( + 'build', + pubspec: pubspec, + appcastUrl: feed, + linuxDownloadsUrl: 'file://${linux.path}', + ); + expect(code, 0); + expect(text, contains('version: 1.0.0+10')); + }); + + test('clears a build in the Linux appcast', () async { + final pubspec = await pubspecWith('1.0.0+7'); + final feed = await appcastWith([7]); + final linux = File(p.join(tmp.path, 'linux.xml')); + // appcast.sh writes the build as an enclosure attribute. + await linux.writeAsString( + '' + '', + ); + final (code, text, _) = await run( + 'patch', + pubspec: pubspec, + appcastUrl: feed, + linuxAppcastUrl: 'file://${linux.path}', + ); + expect(code, 0); + expect(text, contains('version: 1.0.1+13')); + }); + test('"build" republishes the same version under a new counter', () async { final pubspec = await pubspecWith('1.0.0+7'); final url = await appcastWith([7]); diff --git a/tool/linux/promote_release.sh b/tool/linux/promote_release.sh new file mode 100755 index 0000000..e2f500f --- /dev/null +++ b/tool/linux/promote_release.sh @@ -0,0 +1,309 @@ +#!/usr/bin/env bash +# +# Promotes the uploaded AppImage pubspec.yaml names into the Linux appcast — +# the moment installed copies start offering it. The Linux counterpart of +# tool/publish_appcast.sh; .github/workflows/promote.yml runs it after a +# `production` reviewer approves. +# +# 1. Downloads the AppImage from the bucket ORIGIN, checks it against its +# .sha256 sidecar and makes it executable: what is signed is exactly the +# object users download, never a file from dist/. +# 2. Reads the live appcast uncached from the origin, or starts a new one. +# 3. Signs and inserts the item with tool/linux/appcast.sh, which verifies +# the signature against eddsaPublicKey in linux/release.json — the key +# installed copies carry — and refuses a build the feed has passed. +# 4. Uploads the appcast (max-age=300) and invalidates it at the edge. +# 5. Catches the latest entry of downloads/linux.json up. +# +# The key is the Linux one, PEM, as `openssl genpkey -algorithm ed25519` +# writes it — never the Sparkle or WinSparkle key. It must be outside the +# checkout; CI writes it to the runner's temp directory and deletes it after. +# +# Runs on Linux only (appcast.sh runs the AppImage to read its version), with +# OpenSSL 3, python3 and GNU coreutils. +# +# Usage: +# tool/linux/promote_release.sh --key= [--dry-run] +# [--bucket=NAME] +# [--impersonate-service-account=SA] +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +# shellcheck source=tool/lib/pubspec_version.sh +source "$ROOT_DIR/tool/lib/pubspec_version.sh" +BUCKET="${BUCKET:-serverpod-appstudio-toolchain}" +APPCAST_PATH="appcast/linux/appcast.xml" +KEY_FILE="" +DRY_RUN=0 +IMPERSONATE="" + +for arg in "$@"; do + case "$arg" in + --key=*) KEY_FILE="${arg#*=}" ;; + --dry-run) DRY_RUN=1 ;; + --bucket=*) BUCKET="${arg#*=}" ;; + --impersonate-service-account=*) IMPERSONATE="${arg#*=}" ;; + *) echo "Unknown argument: $arg" >&2; exit 1 ;; + esac +done + +if [[ "$(uname -s)" != Linux ]]; then + echo "promote_release.sh runs on Linux only: appcast.sh runs the AppImage" \ + "to read its version." >&2 + exit 1 +fi +for cmd in curl openssl python3 sha256sum base64; do + command -v "$cmd" >/dev/null || { echo "Missing on this machine: $cmd" >&2; exit 1; } +done + +# shellcheck source=tool/lib/bucket_urls.sh +source "$ROOT_DIR/tool/lib/bucket_urls.sh" +# The feed and its enclosures are user-facing, so they carry the CDN host. +# Every read that decides something reads the origin. ORIGIN_BASE_URL in the +# environment stands in for the bucket in a dry-run test; a release never +# sets it. See tool/lib/bucket_urls.sh. +ORIGIN_BASE_URL="${ORIGIN_BASE_URL:-$(origin_base_url "$BUCKET")}" +PUBLIC_BASE_URL="$(public_base_url "$BUCKET")" + +gcloud_storage() { + if [[ -n "$IMPERSONATE" ]]; then + gcloud storage "$@" --impersonate-service-account="$IMPERSONATE" + else + gcloud storage "$@" + fi +} + +# --------------------------------------------------------------------------- +# The private key: present, and never inside the checkout, where it is one +# `git add -A` from public. Whoever holds it can ship an update every +# installed copy accepts and runs. +# --------------------------------------------------------------------------- +if [[ -z "$KEY_FILE" || ! -s "$KEY_FILE" ]]; then + echo "error: --key= names no key: ${KEY_FILE:-(none)}" >&2 + exit 1 +fi +KEY_FILE="$(cd "$(dirname "$KEY_FILE")" && pwd)/$(basename "$KEY_FILE")" +if [[ "$KEY_FILE" == "$ROOT_DIR"/* ]]; then + echo "error: the key is inside the repo: $KEY_FILE" >&2 + echo "Keep the private key outside the checkout." >&2 + exit 1 +fi + +# --------------------------------------------------------------------------- +# The key that signs must be the key that ships, and the feed this writes +# must be the feed the builds read. appcast.sh falls back to the key's own +# public half when linux/release.json has none (for a local feed); here that +# would "verify" a signature no installed copy can check, so both are +# required. +# --------------------------------------------------------------------------- +read -r SHIPPED_KEY SHIPPED_FEED < <(python3 -c ' +import json, sys +c = json.load(open(sys.argv[1])) +print(c.get("eddsaPublicKey") or "-", c.get("appcastUrl") or "-") +' "$ROOT_DIR/linux/release.json") +if [[ "$SHIPPED_KEY" == - || "$SHIPPED_FEED" == - ]]; then + echo "error: linux/release.json has no eddsaPublicKey or appcastUrl." >&2 + echo "No build could check or even find this update; see specs/release_ci.md." >&2 + exit 1 +fi +SIGNING_KEY="$(openssl pkey -in "$KEY_FILE" -pubout -outform DER | tail -c 32 | base64 -w0)" +if [[ "$SIGNING_KEY" != "$SHIPPED_KEY" ]]; then + echo "error: the signing key does not match eddsaPublicKey in linux/release.json." >&2 + echo " Signing: $SIGNING_KEY" >&2 + echo " Shipped: $SHIPPED_KEY" >&2 + echo "Publishing would produce updates every installed copy rejects." >&2 + exit 1 +fi +echo "==> Signing key matches the one shipped in the app" + +FEED_URL="$PUBLIC_BASE_URL$APPCAST_PATH" +if [[ "$SHIPPED_FEED" != "$FEED_URL" ]]; then + if [[ "$BUCKET" == "$PRODUCTION_BUCKET" ]]; then + echo "error: builds read their updates from $SHIPPED_FEED" >&2 + echo "(linux/release.json), but this would publish $FEED_URL." >&2 + exit 1 + fi + # A staging bucket is served from its origin, never the CDN. + echo " note: test bucket — builds read $SHIPPED_FEED, not this feed" +fi + +# --------------------------------------------------------------------------- +# What is promoted: exactly what pubspec.yaml names, already uploaded. +# --------------------------------------------------------------------------- +read -r APP_VERSION BUILD_NUMBER <<<"$(read_pubspec_version "$ROOT_DIR/pubspec.yaml")" +OBJECT_NAME="AppStudio-$APP_VERSION-x86_64.AppImage" +OBJECT_PATH="releases/linux/$APP_VERSION/b$BUILD_NUMBER/$OBJECT_NAME" +NEW_URL="$PUBLIC_BASE_URL$OBJECT_PATH" + +echo +echo "==> Promoting App Studio $APP_VERSION (build $BUILD_NUMBER) into the Linux appcast" + +WORK="$(mktemp -d)" +KEEP_WORK=0 +trap '[[ "$KEEP_WORK" == 1 ]] || rm -rf "$WORK"' EXIT + +# The live feed, from the origin and past every cache: it is the document +# being edited, and a stale copy would silently drop a release. +FEED="$WORK/appcast.xml" +EXISTING="$WORK/existing.xml" +if fetch_uncached "$ORIGIN_BASE_URL$APPCAST_PATH" >"$EXISTING" && [[ -s "$EXISTING" ]]; then + cp "$EXISTING" "$FEED" + FEED_MAX="$(sparkle_max_build <"$EXISTING")" + echo " the appcast serves up to build $FEED_MAX" +else + rm -f "$EXISTING" + FEED_MAX=0 + echo " no appcast published yet: starting one" +fi + +if [[ -f "$EXISTING" ]] \ + && grep -Eq "sparkle:version=\"$BUILD_NUMBER\"" "$EXISTING"; then + echo " build $BUILD_NUMBER is already in the appcast — nothing to promote." + if [[ "$DRY_RUN" != 1 ]]; then + # Re-running after a half-finished promote: catch the pointer up too. + "$ROOT_DIR/tool/publish_downloads.sh" --platform=linux --bucket="$BUCKET" \ + ${IMPERSONATE:+--impersonate-service-account="$IMPERSONATE"} + fi + exit 0 +fi +assert_build_is_newer "$BUILD_NUMBER" "$FEED_MAX" + +# --------------------------------------------------------------------------- +# The bytes to sign come from the bucket and must be the upload they claim to be. +# --------------------------------------------------------------------------- +echo +echo "==> Fetching the uploaded AppImage" +APPIMAGE="$WORK/$OBJECT_NAME" +if ! curl -fsSL "$ORIGIN_BASE_URL$OBJECT_PATH" -o "$APPIMAGE"; then + echo "error: nothing is uploaded at $ORIGIN_BASE_URL$OBJECT_PATH" >&2 + echo "Run the Release workflow (or tool/linux/publish_release.sh) first." >&2 + exit 1 +fi +EXPECTED_SHA="$( + curl -fsSL "$ORIGIN_BASE_URL$OBJECT_PATH.sha256" | awk '{print $1; exit}' +)" || true +if [[ -z "$EXPECTED_SHA" ]]; then + echo "error: no .sha256 sidecar next to the uploaded AppImage" >&2 + exit 1 +fi +ACTUAL_SHA="$(sha256sum "$APPIMAGE" | awk '{print $1}')" +if [[ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]]; then + echo "error: the uploaded AppImage hashes $ACTUAL_SHA but its sidecar says $EXPECTED_SHA" >&2 + exit 1 +fi +chmod +x "$APPIMAGE" +echo " sha256 verified against the published sidecar" + +# --------------------------------------------------------------------------- +# Sign and insert. appcast.sh reads the version and build out of the +# AppImage, so the item cannot describe it as another build. +# --------------------------------------------------------------------------- +echo +"$ROOT_DIR/tool/linux/appcast.sh" --key "$KEY_FILE" --url "$NEW_URL" \ + --feed "$FEED" "$APPIMAGE" + +# Check the feed says exactly what we mean to publish: the new item first, +# for this build, this URL, this length, signed; every earlier item carried +# over unchanged. +echo +echo "==> Checking the feed" +python3 - "$FEED" "${EXISTING:-}" "$NEW_URL" "$BUILD_NUMBER" \ + "$(stat -c %s "$APPIMAGE")" <<'PY' +import os, sys +import xml.etree.ElementTree as ET + +feed, old, url, build, length = sys.argv[1:6] +S = "{http://www.andymatuschak.org/xml-namespaces/sparkle}" + + +def items(path): + out = [] + for item in ET.parse(path).getroot().find("channel").findall("item"): + e = item.find("enclosure") + if e is None: + sys.exit("error: an item has no enclosure") + out.append({ + "url": e.get("url"), + "build": e.get(S + "version"), + "version": e.get(S + "shortVersionString"), + "os": e.get(S + "os"), + "signature": e.get(S + "edSignature"), + "length": e.get("length"), + }) + return out + + +new = items(feed) +before = items(old) if old and os.path.exists(old) else [] +if not new: + sys.exit("error: the feed has no items") +top = new[0] +expected = {"url": url, "build": build, "os": "linux-x86_64", "length": length} +for key, value in expected.items(): + if top[key] != value: + sys.exit(f"error: the new item's {key} is {top[key]!r}, expected {value!r}") +if not top["signature"]: + sys.exit("error: the new item is not signed") +if new[1:] != before: + sys.exit("error: the earlier items did not come through unchanged") +for item in new: + print(f" {item['version']} (build {item['build']}) {item['url']}") +print(f" {len(new)} signed item(s)") +PY + +if [[ "$DRY_RUN" == "1" ]]; then + KEEP_WORK=1 + echo + echo "==> Dry run: not uploaded. The feed is at $FEED" + exit 0 +fi + +# --------------------------------------------------------------------------- +# Upload. Deliberately without --if-generation-match=0: this object is meant +# to be replaced. Short max-age, as for the other appcasts. +# --------------------------------------------------------------------------- +echo +echo "==> Uploading the appcast" +gcloud_storage cp "$FEED" "gs://$BUCKET/$APPCAST_PATH" \ + --cache-control="public, max-age=300, must-revalidate" \ + --content-type="application/xml" + +invalidate_cdn_path "$BUCKET" "/$APPCAST_PATH" \ + ${IMPERSONATE:+--impersonate-service-account="$IMPERSONATE"} + +echo +echo "==> Verifying the published feed" +# From the origin, uncached: the edge may serve the old feed until the +# asynchronous invalidation lands, and what must be true now is that the +# bucket holds this one. +CHECK="$WORK/published.xml" +for attempt in 1 2 3 4 5; do + fetch_uncached "$ORIGIN_BASE_URL$APPCAST_PATH" >"$CHECK" || true + if diff -q "$FEED" "$CHECK" >/dev/null 2>&1; then + break + fi + if [[ "$attempt" == 5 ]]; then + echo "error: the published feed differs from what was generated" >&2 + diff "$FEED" "$CHECK" | head -20 >&2 + exit 1 + fi + echo " not visible yet (attempt $attempt), retrying" + sleep 3 +done + +# The new enclosure must be fetchable where users fetch it, or the update +# check offers a download that fails. Releases are immutable and negative +# caching is off, so there is no cached 404 to trip over. +if ! curl -fsSL -I "$NEW_URL" >/dev/null 2>&1; then + echo "error: enclosure is not reachable: $NEW_URL" >&2 + exit 1 +fi +echo " ok $NEW_URL" + +echo +"$ROOT_DIR/tool/publish_downloads.sh" --platform=linux --bucket="$BUCKET" \ + ${IMPERSONATE:+--impersonate-service-account="$IMPERSONATE"} + +echo +echo "Published: $FEED_URL" +echo "App Studio $APP_VERSION (build $BUILD_NUMBER) is now live for Linux updates." diff --git a/tool/linux/publish_release.sh b/tool/linux/publish_release.sh new file mode 100755 index 0000000..213210e --- /dev/null +++ b/tool/linux/publish_release.sh @@ -0,0 +1,207 @@ +#!/usr/bin/env bash +# +# Uploads the AppImage in dist/linux to the public bucket, under a path +# derived from the pubspec version, and refreshes the "preview" entry in +# downloads/linux.json. The Linux counterpart of tool/publish_dist.sh, with +# the same gates; .github/workflows/release.yml runs it. +# +# This does NOT touch the appcast. The uploaded build is reachable through its +# direct URL (printed at the end) so it can be tested first; +# tool/linux/promote_release.sh is what makes it the live update for installed +# copies. +# +# Object names are immutable: every upload uses --if-generation-match=0, so a +# name collision fails instead of overwriting. Re-running with the SAME bytes +# is fine — the upload is recognised and skipped. Different bytes under the +# same name need a new build number (make set_version V=build). +# +# The build number is pubspec.yaml's +N, the macOS counter +# (specs/linux_appimage.md, B4). Runs on Linux only: it reads the version out +# of the AppImage by running it (--appimage-extract). +# +# Usage: +# tool/linux/publish_release.sh [--dry-run] [--bucket=NAME] +# [--impersonate-service-account=SA] +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +# shellcheck source=tool/lib/pubspec_version.sh +source "$ROOT_DIR/tool/lib/pubspec_version.sh" +DIST_DIR="${DIST_DIR:-$ROOT_DIR/dist/linux}" +BUCKET="${BUCKET:-serverpod-appstudio-toolchain}" +APPCAST_PATH="appcast/linux/appcast.xml" +DRY_RUN=0 +IMPERSONATE="" + +for arg in "$@"; do + case "$arg" in + --dry-run) DRY_RUN=1 ;; + --bucket=*) BUCKET="${arg#*=}" ;; + --impersonate-service-account=*) IMPERSONATE="${arg#*=}" ;; + *) echo "Unknown argument: $arg" >&2; exit 1 ;; + esac +done + +if [[ "$(uname -s)" != Linux ]]; then + echo "publish_release.sh runs on Linux only: it runs the AppImage to read" \ + "its version." >&2 + exit 1 +fi + +# shellcheck source=tool/lib/bucket_urls.sh +source "$ROOT_DIR/tool/lib/bucket_urls.sh" +# The gate and the verification read the origin; the URL printed at the end +# is the one a person would hand out, so it is the CDN's. ORIGIN_BASE_URL in +# the environment stands in for the bucket in a dry-run test; a release never +# sets it. See tool/lib/bucket_urls.sh. +ORIGIN_BASE_URL="${ORIGIN_BASE_URL:-$(origin_base_url "$BUCKET")}" +PUBLIC_BASE_URL="$(public_base_url "$BUCKET")" + +gcloud_storage() { + if [[ -n "$IMPERSONATE" ]]; then + gcloud storage "$@" --impersonate-service-account="$IMPERSONATE" + else + gcloud storage "$@" + fi +} + +read -r APP_VERSION BUILD_NUMBER <<<"$(read_pubspec_version "$ROOT_DIR/pubspec.yaml")" +OBJECT_NAME="AppStudio-$APP_VERSION-x86_64.AppImage" +OBJECT_PATH="releases/linux/$APP_VERSION/b$BUILD_NUMBER/$OBJECT_NAME" +APPIMAGE="$DIST_DIR/$OBJECT_NAME" + +if [[ ! -f "$APPIMAGE" ]]; then + echo "error: no AppImage at $APPIMAGE" >&2 + echo "Run 'make appimage' first." >&2 + exit 1 +fi + +echo "==> Publishing App Studio $APP_VERSION (build $BUILD_NUMBER, Linux x86_64)" +echo " from $APPIMAGE" +echo " to gs://$BUCKET/$OBJECT_PATH" +echo " size $(du -h "$APPIMAGE" | cut -f1)" + +# --------------------------------------------------------------------------- +# A build with no feed or no key never checks for updates, so whoever installs +# it is stranded on it. release_plan.sh skips Linux in that state; this is the +# same rule for a run by hand. +# --------------------------------------------------------------------------- +if ! python3 -c ' +import json, sys +c = json.load(open(sys.argv[1])) +sys.exit(0 if c.get("appcastUrl") and c.get("eddsaPublicKey") else 1) +' "$ROOT_DIR/linux/release.json"; then + echo "error: linux/release.json has no appcastUrl or eddsaPublicKey." >&2 + echo "A build without them could never update; see specs/release_ci.md." >&2 + exit 1 +fi + +# --------------------------------------------------------------------------- +# Installed copies order releases by build number alone. One that repeats or +# goes backwards is never offered, and an immutable object cannot be fixed. +# --------------------------------------------------------------------------- +echo +echo "==> Checking the build number is newer than everything in the Linux appcast" +PUBLISHED_MAX="$(published_max_build "$ORIGIN_BASE_URL$APPCAST_PATH")" +echo " pubspec build $BUILD_NUMBER, highest promoted $PUBLISHED_MAX" +assert_build_is_newer "$BUILD_NUMBER" "$PUBLISHED_MAX" + +# --------------------------------------------------------------------------- +# The AppImage must contain the version it is about to be published as: a +# stale one from an older build would otherwise be served under a new number. +# --------------------------------------------------------------------------- +echo +echo "==> Checking the AppImage's contents match pubspec" +[[ -x "$APPIMAGE" ]] || chmod +x "$APPIMAGE" +UNPACK="$(mktemp -d)" +cleanup() { rm -rf "$UNPACK"; } +trap cleanup EXIT +(cd "$UNPACK" && "$APPIMAGE" --appimage-extract \ + usr/lib/appstudio/data/flutter_assets/version.json > /dev/null) +VERSION_JSON="$UNPACK/squashfs-root/usr/lib/appstudio/data/flutter_assets/version.json" +if [[ ! -f "$VERSION_JSON" ]]; then + echo "error: no version.json inside the AppImage" >&2 + exit 1 +fi +read -r IMAGE_VERSION IMAGE_BUILD < <(python3 -c ' +import json, sys +v = json.load(open(sys.argv[1])) +print(v["version"], v["build_number"])' "$VERSION_JSON") +echo " AppImage reports $IMAGE_VERSION (build $IMAGE_BUILD)" +if [[ "$IMAGE_VERSION" != "$APP_VERSION" || "$IMAGE_BUILD" != "$BUILD_NUMBER" ]]; then + echo "error: the AppImage is $IMAGE_VERSION+$IMAGE_BUILD but pubspec.yaml says" \ + "$APP_VERSION+$BUILD_NUMBER. Run 'make appimage' again." >&2 + exit 1 +fi +cleanup +trap - EXIT + +SHA256="$(sha256sum "$APPIMAGE" | awk '{print $1}')" +BYTES="$(stat -c %s "$APPIMAGE")" +echo +echo " sha256 $SHA256" + +if [[ "$DRY_RUN" == "1" ]]; then + echo + echo "==> Dry run: nothing uploaded." + exit 0 +fi + +# A re-run for bytes already in the bucket is fine; the same PATH holding +# DIFFERENT bytes means a rebuilt AppImage and needs a new build number. +ALREADY_PUBLISHED="$( + curl -fsSL "$ORIGIN_BASE_URL$OBJECT_PATH.sha256" 2>/dev/null \ + | awk '{print $1; exit}' || true +)" +if [[ -n "$ALREADY_PUBLISHED" && "$ALREADY_PUBLISHED" != "$SHA256" ]]; then + echo "error: gs://$BUCKET/$OBJECT_PATH already exists with different bytes." >&2 + echo "Published objects are immutable — bump the build number:" >&2 + echo " make set_version V=build" >&2 + exit 1 +fi + +echo +if [[ -n "$ALREADY_PUBLISHED" ]]; then + echo "==> Already uploaded (byte-identical) — skipping the upload" +else + echo "==> Uploading" + # --if-generation-match=0: only if the object does not exist yet. + gcloud_storage cp "$APPIMAGE" "gs://$BUCKET/$OBJECT_PATH" \ + --if-generation-match=0 \ + --cache-control="public, max-age=31536000, immutable" \ + --content-type="application/vnd.appimage" + + SUMS="$(mktemp)" + printf '%s %s\n' "$SHA256" "$OBJECT_NAME" >"$SUMS" + gcloud_storage cp "$SUMS" "gs://$BUCKET/$OBJECT_PATH.sha256" \ + --if-generation-match=0 \ + --cache-control="public, max-age=31536000, immutable" \ + --content-type="text/plain" + rm -f "$SUMS" +fi + +echo +echo "==> Verifying the upload" +CHECK="$(mktemp)" +curl -fsSL "$ORIGIN_BASE_URL$OBJECT_PATH" -o "$CHECK" +ACTUAL="$(sha256sum "$CHECK" | awk '{print $1}')" +rm -f "$CHECK" +if [[ "$ACTUAL" != "$SHA256" ]]; then + echo "error: uploaded object hashes $ACTUAL, expected $SHA256" >&2 + exit 1 +fi +echo " ok ($BYTES bytes)" + +# The website's "preview" pointer follows the newest upload. +echo +"$ROOT_DIR/tool/publish_downloads.sh" --platform=linux --bucket="$BUCKET" \ + ${IMPERSONATE:+--impersonate-service-account="$IMPERSONATE"} + +echo +echo "Uploaded, NOT yet in the appcast — installed copies are untouched." +echo +echo "Test this build on a clean Linux:" +echo " $PUBLIC_BASE_URL$OBJECT_PATH" +echo +echo "When it checks out, make it the live update with the Promote workflow" +echo "(or tool/linux/promote_release.sh)." diff --git a/tool/publish_downloads.sh b/tool/publish_downloads.sh index 28adabb..9f36f33 100755 --- a/tool/publish_downloads.sh +++ b/tool/publish_downloads.sh @@ -6,6 +6,10 @@ # latest the newest build in the Sparkle appcast — what auto-update serves # preview the newest uploaded build, which may not be in the appcast yet # +# --platform=linux publishes downloads/linux.json the same way, from the Linux +# appcast and the AppImage pubspec.yaml names (Linux shares pubspec's build +# counter). tool/linux/publish_release.sh and promote_release.sh run it. +# # When nothing is waiting for promotion the two entries are identical. The file # is derived entirely from published state — the live appcast plus the object # for the build pubspec.yaml names — so it is safe to re-run at any time. @@ -17,7 +21,7 @@ # visible on the download page within a minute. # # Usage: -# tool/publish_downloads.sh [--dry-run] [--bucket=NAME] +# tool/publish_downloads.sh [--dry-run] [--bucket=NAME] [--platform=macos|linux] # [--impersonate-service-account=SA] set -euo pipefail @@ -25,8 +29,7 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # shellcheck source=tool/lib/pubspec_version.sh source "$ROOT_DIR/tool/lib/pubspec_version.sh" BUCKET="${BUCKET:-serverpod-appstudio-toolchain}" -APPCAST_PATH="appcast/macos/appcast.xml" -DOWNLOADS_PATH="downloads/macos.json" +PLATFORM=macos DRY_RUN=0 IMPERSONATE="" @@ -34,6 +37,7 @@ for arg in "$@"; do case "$arg" in --dry-run) DRY_RUN=1 ;; --bucket=*) BUCKET="${arg#*=}" ;; + --platform=*) PLATFORM="${arg#*=}" ;; --impersonate-service-account=*) IMPERSONATE="${arg#*=}" ;; *) echo "Unknown argument: $arg" >&2; exit 1 ;; esac @@ -43,10 +47,24 @@ done source "$ROOT_DIR/tool/lib/bucket_urls.sh" # The links in the file are user-facing, so they carry the CDN host. Every read # this script does to BUILD the file asks what is in the bucket, and reads the -# origin. See tool/lib/bucket_urls.sh. -ORIGIN_BASE_URL="$(origin_base_url "$BUCKET")" +# origin. See tool/lib/bucket_urls.sh. ORIGIN_BASE_URL in the environment +# stands in for the bucket in the tests; a release never sets it. +ORIGIN_BASE_URL="${ORIGIN_BASE_URL:-$(origin_base_url "$BUCKET")}" PUBLIC_BASE_URL="$(public_base_url "$BUCKET")" -ARCH="$(uname -m)" + +case "$PLATFORM" in + macos) + APPCAST_PATH="appcast/macos/appcast.xml" + DOWNLOADS_PATH="downloads/macos.json" + UPLOAD_HINT="Run 'make publish' first." + ;; + linux) + APPCAST_PATH="appcast/linux/appcast.xml" + DOWNLOADS_PATH="downloads/linux.json" + UPLOAD_HINT="Run tool/linux/publish_release.sh first." + ;; + *) echo "Unknown platform: $PLATFORM (macos or linux)" >&2; exit 1 ;; +esac gcloud_storage() { if [[ -n "$IMPERSONATE" ]]; then @@ -74,7 +92,11 @@ sha_for() { # entries collapse into one below. # --------------------------------------------------------------------------- read -r APP_VERSION BUILD_NUMBER <<<"$(read_pubspec_version "$ROOT_DIR/pubspec.yaml")" -OBJECT_PATH="releases/macos/$APP_VERSION/b$BUILD_NUMBER/AppStudio-$APP_VERSION-$ARCH.zip" +if [[ "$PLATFORM" == linux ]]; then + OBJECT_PATH="releases/linux/$APP_VERSION/b$BUILD_NUMBER/AppStudio-$APP_VERSION-x86_64.AppImage" +else + OBJECT_PATH="releases/macos/$APP_VERSION/b$BUILD_NUMBER/AppStudio-$APP_VERSION-$(uname -m).zip" +fi # --------------------------------------------------------------------------- # latest: the highest-build item in the live appcast. Old items carry origin @@ -123,7 +145,7 @@ if [[ "$BUILD_NUMBER" -gt "$LATEST_BUILD" ]]; then if ! curl -fsI "$ORIGIN_BASE_URL$OBJECT_PATH" >/dev/null 2>&1; then echo "error: pubspec names build $BUILD_NUMBER but nothing is uploaded at" >&2 echo " $ORIGIN_BASE_URL$OBJECT_PATH" >&2 - echo "Run 'make publish' first." >&2 + echo "$UPLOAD_HINT" >&2 exit 1 fi PREVIEW_VERSION="$APP_VERSION" PREVIEW_BUILD="$BUILD_NUMBER" @@ -174,7 +196,7 @@ with open(sys.argv[1], "w") as f: PY echo -echo "==> downloads/macos.json" +echo "==> $DOWNLOADS_PATH" sed 's/^/ /' "$OUT" if [[ "$DRY_RUN" == "1" ]]; then diff --git a/tool/release_plan.sh b/tool/release_plan.sh index ddf2450..6b861ac 100755 --- a/tool/release_plan.sh +++ b/tool/release_plan.sh @@ -23,9 +23,13 @@ # error not uploaded, but the number is taken. Shipping it would repeat # a build number — unfixable — so the workflow stops and says why. # -# Windows is also skipped while windows/release.json has no appcastUrl or -# eddsaPublicKey: a build without them never checks for updates, so whoever -# installs it is stranded on it. +# Windows and Linux are also skipped while windows/release.json or +# linux/release.json has no appcastUrl or eddsaPublicKey: a build without them +# never checks for updates, so whoever installs it is stranded on it. +# +# Linux has no build counter of its own: it is pubspec.yaml's +N, the macOS +# one (specs/linux_appimage.md, B4), checked against the Linux appcast and +# downloads/linux.json. # # promote, per platform: # promote the uploaded build is newer than everything in the appcast @@ -48,6 +52,10 @@ case "$MODE" in esac BUCKET="${BUCKET:-serverpod-appstudio-toolchain}" +# PUBSPEC and LINUX_RELEASE_JSON are overridable for the tests, which pair +# them with an ORIGIN_BASE_URL of their own; a release never sets them. +PUBSPEC="${PUBSPEC:-$ROOT_DIR/pubspec.yaml}" +LINUX_RELEASE_JSON="${LINUX_RELEASE_JSON:-$ROOT_DIR/linux/release.json}" ORIGIN="${ORIGIN_BASE_URL:-$(origin_base_url "$BUCKET")}" PUBLIC="$(public_base_url "$BUCKET")" # Release Macs are Apple silicon, and so is the runner that builds in CI @@ -110,7 +118,7 @@ plan() { echo "$p: $status — $reason" >&2 } -read -r VERSION MACOS_BUILD <<<"$(read_pubspec_version "$ROOT_DIR/pubspec.yaml")" +read -r VERSION MACOS_BUILD <<<"$(read_pubspec_version "$PUBSPEC")" plan macos "$VERSION" "$MACOS_BUILD" \ "releases/macos/$VERSION/b$MACOS_BUILD/AppStudio-$VERSION-$MACOS_ARCH.zip" \ appcast/macos/appcast.xml downloads/macos.json @@ -133,3 +141,22 @@ else "releases/windows/$VERSION/b$WINDOWS_BUILD/AppStudio-$VERSION-x64-setup.exe" \ appcast/windows/appcast.xml downloads/windows.json fi + +# linux/release.json: no counter, only the feed URL and public key a release +# build compiles in. The build number is pubspec's. +LINUX_CONFIGURED="$(python3 -c ' +import json, sys +c = json.load(open(sys.argv[1])) +print(int(bool(c.get("appcastUrl")) and bool(c.get("eddsaPublicKey")))) +' "$LINUX_RELEASE_JSON")" +if [[ "$LINUX_CONFIGURED" != 1 ]]; then + out linux_version "$VERSION" + out linux_build "$MACOS_BUILD" + out linux skip + out linux_reason "linux/release.json has no appcastUrl or eddsaPublicKey, so the build could never update" + echo "linux: skip — linux/release.json has no appcastUrl or eddsaPublicKey" >&2 +else + plan linux "$VERSION" "$MACOS_BUILD" \ + "releases/linux/$VERSION/b$MACOS_BUILD/AppStudio-$VERSION-x86_64.AppImage" \ + appcast/linux/appcast.xml downloads/linux.json +fi diff --git a/tool/set_version.sh b/tool/set_version.sh index 05156e0..014bcf4 100755 --- a/tool/set_version.sh +++ b/tool/set_version.sh @@ -35,6 +35,12 @@ APPCAST_URL="${APPCAST_URL:-$(origin_base_url "$BUCKET")appcast/macos/appcast.xm # promoted into the appcast — the appcast alone under-reports in exactly that # window, and the number handed out here must clear those uploads too. DOWNLOADS_URL="${DOWNLOADS_URL:-$(origin_base_url "$BUCKET")downloads/macos.json}" +# Linux releases carry this same counter (specs/linux_appimage.md, B4), and a +# Linux upload can get ahead of macOS: a macOS job that failed after the Linux +# one uploaded build N leaves N in the Linux feeds alone. Handing N out again +# would make Release skip Linux for the new commit, its sidecar being there. +LINUX_APPCAST_URL="${LINUX_APPCAST_URL:-$(origin_base_url "$BUCKET")appcast/linux/appcast.xml}" +LINUX_DOWNLOADS_URL="${LINUX_DOWNLOADS_URL:-$(origin_base_url "$BUCKET")downloads/linux.json}" if [[ $# -ne 1 ]]; then sed -n '11,17p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//' @@ -73,6 +79,8 @@ fi # upload still waiting for promotion would otherwise hand out a build number # Sparkle has already seen (or is about to see). PUBLISHED_MAX="$(release_max_build "$APPCAST_URL" "$DOWNLOADS_URL")" +LINUX_MAX="$(release_max_build "$LINUX_APPCAST_URL" "$LINUX_DOWNLOADS_URL")" +[[ "$LINUX_MAX" -gt "$PUBLISHED_MAX" ]] && PUBLISHED_MAX="$LINUX_MAX" NEW_BUILD="$CUR_BUILD" [[ "$PUBLISHED_MAX" -gt "$NEW_BUILD" ]] && NEW_BUILD="$PUBLISHED_MAX" NEW_BUILD="$((NEW_BUILD + 1))" diff --git a/tool/tag_release.sh b/tool/tag_release.sh index 284b3d2..f8dd532 100755 --- a/tool/tag_release.sh +++ b/tool/tag_release.sh @@ -9,7 +9,8 @@ # have moved on by the time that build has been tried and promoted. So the # commit is the oldest one whose pubspec.yaml diff adds `version: X.Y.Z+N`. # -# Annotated, naming the build numbers on both platforms. Never moved: an +# Annotated, naming the build number of each platform (Linux's is pubspec's +# +N, the macOS one, and is named once linux/release.json has a feed). Never moved: an # existing v on the same commit is left as it is, and one on another # commit (a `make set_version V=build` rebuild of a version already tagged) is # reported and left alone too — a tag someone may have fetched should not @@ -29,6 +30,7 @@ DRY_RUN=0 read -r VERSION MACOS_BUILD <<<"$(read_pubspec_version pubspec.yaml)" WINDOWS_BUILD="$(python3 -c 'import json; print(int(json.load(open("windows/release.json")).get("build", 0)))')" +LINUX_CONFIGURED="$(python3 -c 'import json; c = json.load(open("linux/release.json")); print(int(bool(c.get("appcastUrl")) and bool(c.get("eddsaPublicKey"))))')" TAG="v$VERSION" # git log -G takes a regex: the dots and the plus of "0.3.0+23" are literal. @@ -53,6 +55,11 @@ MESSAGE="App Studio $VERSION macOS build $MACOS_BUILD Windows build $WINDOWS_BUILD" +LINUX_LINE="" +if [[ "$LINUX_CONFIGURED" == 1 ]]; then + MESSAGE+=$'\n'"Linux build $MACOS_BUILD" + LINUX_LINE=" -m 'Linux build $MACOS_BUILD'" +fi if [[ "$DRY_RUN" == 1 ]]; then echo " dry run: would create and push $TAG" @@ -75,7 +82,7 @@ if ! out="$(git push origin "refs/tags/$TAG" 2>&1)"; then echo "$out" if [[ "$out" == *"without \`workflows\` permission"* ]]; then short="$(git rev-parse --short "$COMMIT")" - cmd="git tag -a $TAG -m 'App Studio $VERSION' -m 'macOS build $MACOS_BUILD' -m 'Windows build $WINDOWS_BUILD' $short && git push origin $TAG" + cmd="git tag -a $TAG -m 'App Studio $VERSION' -m 'macOS build $MACOS_BUILD' -m 'Windows build $WINDOWS_BUILD'$LINUX_LINE $short && git push origin $TAG" echo "::warning title=Push $TAG by hand::GitHub does not let a workflow tag $short, because its workflow files differ from main's. The release is live. From a checkout: $cmd" if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then {