Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

ci(spaces): nightly macOS build and its own Sparkle feed (CUA-2353) (#6014)

cua-agents[bot]c063af062528
diff --git a/.github/scripts/spaces_inputs_tree.sh b/.github/scripts/spaces_inputs_tree.sh
new file mode 100755
index 0000000000..626a6a00d7
--- /dev/null
+++ b/.github/scripts/spaces_inputs_tree.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+# Prints one hash of everything that can change the shipped bytes of Cua
+# Spaces at REV (default HEAD): the git trees of the release inputs. The same
+# hash means the same build. Used by cd-cua-spaces-build.yml (a live build of
+# the tree is not built again) and nightly-cua-spaces.yml (no nightly when
+# nothing changed since the last one). Keep the list in step with
+# cd-cua-spaces-build.yml's `on.push.paths`.
+#
+# .github/scripts/spaces_inputs_tree.sh [REV]
+set -euo pipefail
+rev="${1:-HEAD}"
+inputs=(
+ apps/cua-spaces-macos apps/cua-spaces apps/cua-spaces-desktop apps/cua-spaces-web
+ libs/cua libs/cua-spacesd/VERSION
+ .github/actions/spaces-native .github/actions/spaces-rust-slice .github/actions/setup-protoc
+ .github/workflows/cd-cua-spaces-build.yml
+)
+args=()
+for p in "${inputs[@]}"; do args+=("$rev:$p"); done
+git rev-parse "${args[@]}" | git hash-object --stdin
diff --git a/.github/workflows/cd-cua-spaces-build.yml b/.github/workflows/cd-cua-spaces-build.yml
index d2079df813..446e93d766 100644
--- a/.github/workflows/cd-cua-spaces-build.yml
+++ b/.github/workflows/cd-cua-spaces-build.yml
@@ -34,6 +34,12 @@ name: "CD: Cua Spaces build (shadow)"
# file. Every file, the manifest included, has a GitHub artifact attestation
# (signer workflow: this file at refs/heads/main). verify-release.sh runs on
# the produced set before it is attested.
+#
+# Nightly (CUA-1991; called by nightly-cua-spaces.yml with `channel:
+# nightly`): the same macOS build with the nightly version and
+# CFBundleVersion the caller chose, and nothing else. No Windows or Linux
+# build, no build set, attestation or marker: the caller publishes the
+# signed, notarized disk image to the nightly appcast and records the cost.
on:
push:
@@ -56,6 +62,20 @@ on:
description: "Build even if a live build of this exact input tree exists"
type: boolean
default: false
+ workflow_call:
+ inputs:
+ channel:
+ description: "nightly: the macOS app only, for nightly-cua-spaces.yml"
+ type: string
+ required: true
+ version:
+ description: "The app's full version (0.17.0-nightly.20261025+1a2b3c4)"
+ type: string
+ required: true
+ bundle_version:
+ description: "Its CFBundleVersion (numbers and dots), which Sparkle compares"
+ type: string
+ required: true
permissions:
contents: read
@@ -65,7 +85,7 @@ permissions:
# newest waits, an older pending one is replaced. The tree-hash key means the
# newest build still covers every input.)
concurrency:
- group: cd-cua-spaces-build
+ group: cd-cua-spaces-build${{ inputs.channel == 'nightly' && '-nightly' || '' }}
cancel-in-progress: false
defaults:
@@ -114,20 +134,12 @@ jobs:
run: |
set -euo pipefail
# Everything that can change the shipped bytes. Same list as `on.push.paths`.
- inputs=(
- apps/cua-spaces-macos apps/cua-spaces apps/cua-spaces-desktop apps/cua-spaces-web
- libs/cua libs/cua-spacesd/VERSION
- .github/actions/spaces-native .github/actions/spaces-rust-slice .github/actions/setup-protoc
- .github/workflows/cd-cua-spaces-build.yml
- )
- args=()
- for p in "${inputs[@]}"; do args+=("HEAD:$p"); done
- tree="$(git rev-parse "${args[@]}" | git hash-object --stdin)"
+ tree="$(.github/scripts/spaces_inputs_tree.sh HEAD)"
echo "tree=$tree" >> "$GITHUB_OUTPUT"
echo "key=spaces-build-done-v1-${GITHUB_REPOSITORY//\//-}-$tree" >> "$GITHUB_OUTPUT"
- name: Look for a live build of this tree
id: marker
- if: github.event_name != 'workflow_dispatch' || !inputs.force
+ if: inputs.channel != 'nightly' && (github.event_name != 'workflow_dispatch' || !inputs.force)
uses: actions/cache/restore@v4
with:
path: marker
@@ -138,10 +150,11 @@ jobs:
GH_TOKEN: ${{ github.token }}
TREE: ${{ steps.tree.outputs.tree }}
HIT: ${{ steps.marker.outputs.cache-hit }}
+ NIGHTLY_VERSION: ${{ inputs.channel == 'nightly' && inputs.version || '' }}
run: |
set -euo pipefail
- version="$(tr -d '[:space:]' < apps/cua-spaces-macos/VERSION)"
- [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::bad version: $version"; exit 1; }
+ version="${NIGHTLY_VERSION:-$(tr -d '[:space:]' < apps/cua-spaces-macos/VERSION)}"
+ [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]] || { echo "::error::bad version: $version"; exit 1; }
skip=false; reuse_run=""
if [ "$HIT" = true ] && [ -f marker/build ]; then
read -r old_sha old_run < marker/build
@@ -276,6 +289,8 @@ jobs:
CARGO_BUILD_JOBS: 4
CARGO_TARGET_DIR: ${{ github.workspace }}/libs/cua/target
VERSION: ${{ needs.plan.outputs.version }}
+ # A nightly's CFBundleVersion (the caller's); else X.Y.Z.<run number>.
+ BUNDLE_VERSION: ${{ inputs.channel == 'nightly' && inputs.bundle_version || '' }}
outputs:
signed: ${{ steps.signing.outputs.apple }}
steps:
@@ -371,9 +386,12 @@ jobs:
set -euo pipefail
identity="-"
[ "$SIGNED" = true ] && identity="Developer ID Application: $DEVELOPER_NAME ($TEAM_ID)"
- # CFBundleVersion is X.Y.Z.<run number>: the build number of this run.
+ # CFBundleVersion is X.Y.Z.<run number>: the build number of this
+ # run; a nightly's is the caller's.
+ bundle=(--build-number "$GITHUB_RUN_NUMBER")
+ [ -n "$BUNDLE_VERSION" ] && bundle=(--bundle-version "$BUNDLE_VERSION")
apps/cua-spaces-macos/scripts/build-release.sh --version "$VERSION" \
- --build-number "$GITHUB_RUN_NUMBER" --arch universal --skip-cargo \
+ "${bundle[@]}" --arch universal --skip-cargo \
--sign "$identity" --out "$RUNNER_TEMP/spaces-app" \
--feed-url "https://github.com/$GITHUB_REPOSITORY/releases/download/cua-spaces-latest/cua-spaces-appcast.xml"
@@ -494,6 +512,7 @@ jobs:
electron-native:
name: Electron native (${{ matrix.label }})
needs: plan
+ if: inputs.channel != 'nightly'
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
permissions:
@@ -899,7 +918,7 @@ jobs:
summary:
name: Cost summary
needs: [plan, assemble, verify, attest]
- if: always() && needs.plan.result == 'success'
+ if: always() && needs.plan.result == 'success' && inputs.channel != 'nightly'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
diff --git a/.github/workflows/nightly-cua-spaces.yml b/.github/workflows/nightly-cua-spaces.yml
new file mode 100644
index 0000000000..fc7faf1e5e
--- /dev/null
+++ b/.github/workflows/nightly-cua-spaces.yml
@@ -0,0 +1,248 @@
+name: "Nightly: Cua Spaces (macOS)"
+
+# The Nightly update channel of the Cua Spaces Mac app (CUA-1991, phase 1 of
+# the build-once plan in docs/design/desktop-release-build-once-promote.md,
+# trycua/cua#5704; channel switch: Settings, Advanced, Updates).
+#
+# Every night, when the release inputs changed since the last nightly (the
+# input tree hash of .github/scripts/spaces_inputs_tree.sh, recorded in
+# nightly.json), builds main's macOS app with cd-cua-spaces-build.yml
+# (`channel: nightly`): signed, notarized and stapled like a release. Then
+# publishes the disk image to the rolling `cua-spaces-nightly` prerelease
+# (never "latest", tag never `cua-spaces-v*`, so no release workflow runs) and
+# adds it to that release's own Sparkle appcast,
+# cua-spaces-nightly-appcast.xml. Only apps set to Nightly read that feed, and
+# its items are on Sparkle's `nightly` channel, so nothing else installs them.
+# The stable and beta appcast on `cua-spaces-latest` is never touched.
+#
+# Versions: VERSION X.Y.Z on main builds X.(Y+1).0-nightly.YYYYMMDD+<sha>
+# (a prerelease X.Y.Z-pre builds X.Y.Z-nightly...). CFBundleVersion, which
+# Sparkle compares, is X.Y.Z.<YYYYMMDDHHMM> (X.Y.Z.0.<...> for a prerelease):
+# above every build of the release it came from, below the next release, so
+# an app back on Stable takes the next stable release.
+#
+# Cost: the last job writes the run's runner minutes per OS to the run
+# summary (the go/no-go of CUA-1991 is decided on them).
+#
+# workflow_dispatch builds even when nothing changed (`force`).
+
+on:
+ schedule:
+ # 07:30 UTC: night in the Americas, morning in Europe.
+ - cron: "30 7 * * *"
+ workflow_dispatch:
+ inputs:
+ force:
+ description: "Build even if nothing changed since the last nightly"
+ type: boolean
+ default: false
+
+permissions:
+ contents: read
+
+concurrency:
+ group: nightly-cua-spaces
+ cancel-in-progress: false
+
+defaults:
+ run:
+ shell: bash
+
+env:
+ TAG: cua-spaces-nightly
+ APPCAST: cua-spaces-nightly-appcast.xml
+
+jobs:
+ plan:
+ name: Plan
+ if: github.ref == 'refs/heads/main'
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ outputs:
+ skip: ${{ steps.plan.outputs.skip }}
+ version: ${{ steps.plan.outputs.version }}
+ bundle_version: ${{ steps.plan.outputs.bundle_version }}
+ tree: ${{ steps.plan.outputs.tree }}
+ previous_sha: ${{ steps.plan.outputs.previous_sha }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: Plan
+ id: plan
+ env:
+ GH_TOKEN: ${{ github.token }}
+ FORCE: ${{ github.event_name == 'workflow_dispatch' && inputs.force }}
+ run: |
+ set -euo pipefail
+ tree="$(.github/scripts/spaces_inputs_tree.sh HEAD)"
+ last="$(gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern nightly.json --output - 2>/dev/null || echo '{}')"
+ last_tree="$(jq -r '.tree // ""' <<<"$last")"
+ previous_sha="$(jq -r '.sha // ""' <<<"$last")"
+ skip=false
+ if [ "$tree" = "$last_tree" ] && [ "$FORCE" != true ]; then skip=true; fi
+
+ base="$(tr -d '[:space:]' < apps/cua-spaces-macos/VERSION)"
+ [[ "$base" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::bad VERSION: $base"; exit 1; }
+ x="${BASH_REMATCH[1]}"; y="${BASH_REMATCH[2]}"; z="${BASH_REMATCH[3]}"; pre="${BASH_REMATCH[4]}"
+ stamp="$(date -u +%Y%m%d%H%M)"
+ day="${stamp:0:8}"
+ sha="${GITHUB_SHA:0:7}"
+ if [ -z "$pre" ]; then
+ version="$x.$((y + 1)).0-nightly.$day+$sha"
+ bundle_version="$x.$y.$z.$stamp"
+ else
+ version="$x.$y.$z-nightly.$day+$sha"
+ bundle_version="$x.$y.$z.0.$stamp"
+ fi
+ {
+ echo "skip=$skip"
+ echo "version=$version"
+ echo "bundle_version=$bundle_version"
+ echo "tree=$tree"
+ echo "previous_sha=$previous_sha"
+ } >> "$GITHUB_OUTPUT"
+ {
+ echo "## Plan"
+ echo "- Inputs tree \`$tree\` (last nightly: \`${last_tree:-none}\`)"
+ if [ "$skip" = true ]; then
+ echo "- **Skipped:** nothing changed since the last nightly."
+ else
+ echo "- Building **$version** (CFBundleVersion $bundle_version) from $GITHUB_SHA."
+ fi
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ # The macOS app, signed and notarized: the release build, nightly version.
+ build:
+ name: Build
+ needs: plan
+ if: needs.plan.outputs.skip != 'true'
+ # Everything a job of the called workflow asks for, also the jobs a
+ # nightly skips (GitHub checks them all; test_reusable_workflow_permissions.py).
+ permissions:
+ contents: read
+ actions: read
+ id-token: write
+ attestations: write
+ uses: ./.github/workflows/cd-cua-spaces-build.yml
+ with:
+ channel: nightly
+ version: ${{ needs.plan.outputs.version }}
+ bundle_version: ${{ needs.plan.outputs.bundle_version }}
+ secrets: inherit
+
+ # The disk image to the rolling `cua-spaces-nightly` release and its item
+ # into the nightly appcast (EdDSA-signed with the release key and checked
+ # by verify-appcast.sh the way the app reads it).
+ publish:
+ name: Publish to the nightly feed
+ needs: [plan, build]
+ runs-on: macos-26
+ timeout-minutes: 30
+ # Holds the Sparkle EdDSA key; restricted to main.
+ environment: cua-driver-release-signing
+ permissions:
+ contents: write
+ env:
+ VERSION: ${{ needs.plan.outputs.version }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ filter: blob:none
+ - name: Download the signed disk image
+ uses: actions/download-artifact@v4
+ with:
+ name: part-darwin-universal
+ path: ${{ runner.temp }}/part
+ - name: Sparkle appcast
+ env:
+ GH_TOKEN: ${{ github.token }}
+ CUA_SPACES_SPARKLE_ED_PRIVATE_KEY: ${{ secrets.CUA_SPACES_SPARKLE_ED_PRIVATE_KEY }}
+ PREVIOUS_SHA: ${{ needs.plan.outputs.previous_sha }}
+ run: |
+ set -euo pipefail
+ [ -n "$CUA_SPACES_SPARKLE_ED_PRIVATE_KEY" ] || { echo "::error::no CUA_SPACES_SPARKLE_ED_PRIVATE_KEY: cannot sign the nightly appcast"; exit 1; }
+ grep -q "Developer ID signed and notarized" "$RUNNER_TEMP/part/signing-darwin-universal.txt" ||
+ { echo "::error::the nightly disk image is not signed and notarized"; exit 1; }
+ # A GitHub asset name has no '+': the build metadata joins with a dot.
+ asset="cua-spaces-${VERSION//+/.}-darwin-universal.dmg"
+ mkdir -p out
+ mv "$RUNNER_TEMP/part/cua-spaces-$VERSION-darwin-universal.dmg" "out/$asset"
+ echo "ASSET=$asset" >> "$GITHUB_ENV"
+
+ # What changed since the last nightly (the release inputs only).
+ notes="$RUNNER_TEMP/notes.md"
+ {
+ echo "Nightly build of main at ${GITHUB_SHA:0:7}. Nightly builds are not tested and may break; switch back to Stable in Settings, Advanced, Updates."
+ echo
+ range="$GITHUB_SHA"
+ [ -n "$PREVIOUS_SHA" ] && git cat-file -e "$PREVIOUS_SHA^{commit}" 2>/dev/null && range="$PREVIOUS_SHA..$GITHUB_SHA"
+ git log --no-merges --format='- %s' -n 40 "$range" -- \
+ apps/cua-spaces-macos apps/cua-spaces apps/cua-spaces-desktop apps/cua-spaces-web libs/cua libs/cua-spacesd/VERSION
+ } > "$notes"
+
+ mkdir -p "$RUNNER_TEMP/previous"
+ gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "$APPCAST" \
+ --dir "$RUNNER_TEMP/previous" 2>/dev/null || true
+ apps/cua-spaces-macos/scripts/make-appcast.sh \
+ --dmg "out/$asset" --version "$VERSION" \
+ --download-base "https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/" \
+ --previous "$RUNNER_TEMP/previous/$APPCAST" --notes "$notes" \
+ --out "out/$APPCAST"
+ - name: Publish
+ env:
+ GH_TOKEN: ${{ github.token }}
+ TREE: ${{ needs.plan.outputs.tree }}
+ BUNDLE_VERSION: ${{ needs.plan.outputs.bundle_version }}
+ run: |
+ set -euo pipefail
+ body="The newest Cua Spaces for Mac, built from main most nights. Nightly builds are not tested and may break. To get them, open Cua Spaces, Settings, Advanced, and set Updates to Nightly. Latest: $VERSION."
+ if ! gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
+ gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \
+ --title "Cua Spaces Nightly" --notes "$body" --prerelease --latest=false
+ fi
+ jq -n --arg version "$VERSION" --arg bundle "$BUNDLE_VERSION" --arg sha "$GITHUB_SHA" \
+ --arg tree "$TREE" --arg asset "$ASSET" --arg run "$GITHUB_RUN_ID" \
+ --arg at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
+ '{version: $version, bundleVersion: $bundle, sha: $sha, tree: $tree, dmg: $asset, run: ($run | tonumber), builtAt: $at}' \
+ > out/nightly.json
+ # The image first, then the feed that points at it, then the record.
+ gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" --clobber "out/$ASSET"
+ gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" --clobber "out/$APPCAST"
+ gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" --clobber out/nightly.json
+ gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --notes "$body" --prerelease --latest=false
+ # Disk images the appcast no longer lists go.
+ keep="$(python3 - "out/$APPCAST" <<'PY'
+ import sys
+ import xml.etree.ElementTree as ET
+ for e in ET.parse(sys.argv[1]).iter("enclosure"):
+ print(e.get("url", "").rsplit("/", 1)[-1])
+ PY
+ )"
+ gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' |
+ grep '\.dmg$' | while read -r name; do
+ grep -qxF "$name" <<<"$keep" || gh release delete-asset "$TAG" "$name" --repo "$GITHUB_REPOSITORY" --yes
+ done
+ {
+ echo "## Published"
+ echo "- **$VERSION** (CFBundleVersion $BUNDLE_VERSION)"
+ echo "- Feed: https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/$APPCAST"
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ # Runner minutes per OS for the CUA-1991 cost go/no-go.
+ cost:
+ name: Cost summary
+ needs: [plan, build, publish]
+ if: always() && needs.plan.outputs.skip != 'true' && needs.plan.result == 'success'
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ actions: read
+ steps:
+ - uses: actions/checkout@v4
+ - name: Cost summary
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: python3 -I .github/scripts/spaces_build_summary.py "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID" >> "$GITHUB_STEP_SUMMARY"
diff --git a/apps/cua-spaces-macos/scripts/build-release.sh b/apps/cua-spaces-macos/scripts/build-release.sh
index 910a30cd8b..cc842567e7 100755
--- a/apps/cua-spaces-macos/scripts/build-release.sh
+++ b/apps/cua-spaces-macos/scripts/build-release.sh
@@ -24,9 +24,9 @@
# it would register as the app)
# Cua Spaces.app com.trycua.spaces.macos, Support/CuaSpacesMac.entitlements
#
-# scripts/build-release.sh --version 0.2.0[-suffix] [--build-number N]
-# [--arch universal|arm64|x86_64] [--sign IDENTITY] [--out DIR]
-# [--feed-url URL] [--skip-cargo]
+# scripts/build-release.sh --version 0.2.0[-suffix][+build] [--build-number N]
+# [--bundle-version A.B.C.D[.E]] [--arch universal|arm64|x86_64]
+# [--sign IDENTITY] [--out DIR] [--feed-url URL] [--skip-cargo]
#
# Every release build, a beta included, is a production build: it talks to
# Cua production unless CUA_ENV=staging is set at launch. The script keeps
@@ -39,6 +39,12 @@
# production session and home. A build that defaults to staging is a local
# build, not a release.
#
+# A nightly (nightly-cua-spaces.yml, --version X.Y.Z-nightly.YYYYMMDD+sha)
+# is the same build again. It names its own CFBundleVersion with
+# --bundle-version (numbers and dots), which Sparkle compares: it sorts
+# above every release of the version it was built from and below the next
+# one, so a nightly app on Stable takes the next stable release.
+#
# --feed-url sets the updater's appcast (SUFeedURL; default Support/Info.plist's,
# trycua/cua's rolling cua-spaces-latest release). The release workflow passes
# its own repository's, so a staging build updates from staging.
@@ -65,6 +71,7 @@ cua="$repo/libs/cua"
version=""
build_number=""
+bundle_override=""
arch=universal
identity="-"
out="$here/.build/release-app"
@@ -74,12 +81,13 @@ while [ $# -gt 0 ]; do
case "$1" in
--version) version="$2"; shift ;;
--build-number) build_number="$2"; shift ;;
+ --bundle-version) bundle_override="$2"; shift ;;
--arch) arch="$2"; shift ;;
--sign) identity="$2"; shift ;;
--out) out="$2"; shift ;;
--skip-cargo) skip_cargo=1 ;;
--feed-url) feed_url="$2"; shift ;;
- -h | --help) sed -n '5,45p' "$0"; exit 0 ;;
+ -h | --help) sed -n '5,52p' "$0"; exit 0 ;;
*) echo "unknown option: $1" >&2; exit 2 ;;
esac
shift
@@ -88,8 +96,8 @@ done
# CFBundleShortVersionString is X.Y.Z (numbers only); a prerelease suffix
# (0.2.0-staging.4) goes in CuaVersion. CFBundleVersion is X.Y.Z plus the
# build number when there is one (the release workflow's run number).
-if [[ ! "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z.-]+)?$ ]]; then
- echo "--version must look like 1.2.3 or 1.2.3-suffix" >&2
+if [[ ! "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
+ echo "--version must look like 1.2.3, 1.2.3-suffix or 1.2.3-suffix+build" >&2
exit 2
fi
short="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
@@ -98,6 +106,11 @@ if [ -n "$build_number" ]; then
[[ "$build_number" =~ ^[0-9]+$ ]] || { echo "--build-number must be a number" >&2; exit 2; }
bundle_version="$short.$build_number"
fi
+if [ -n "$bundle_override" ]; then
+ [[ "$bundle_override" =~ ^[0-9]+(\.[0-9]+){2,4}$ ]] ||
+ { echo "--bundle-version must be 3 to 5 numbers joined by dots" >&2; exit 2; }
+ bundle_version="$bundle_override"
+fi
case "$arch" in
universal) archs="arm64 x86_64" ;;
diff --git a/apps/cua-spaces-macos/scripts/make-appcast.sh b/apps/cua-spaces-macos/scripts/make-appcast.sh
index c4e76d180a..53fdc6001c 100755
--- a/apps/cua-spaces-macos/scripts/make-appcast.sh
+++ b/apps/cua-spaces-macos/scripts/make-appcast.sh
@@ -23,7 +23,10 @@
# (verify-appcast.sh --electron).
#
# A version with a suffix (X.Y.Z-suffix) goes to the `beta` channel, which
-# only apps set to "Update to: Beta" see; X.Y.Z goes to everyone. --notes
+# only apps set to Beta see; X.Y.Z goes to everyone. A nightly
+# (X.Y.Z-nightly.YYYYMMDD+sha, nightly-cua-spaces.yml, written into the
+# separate nightly appcast) goes to the `nightly` channel, so only apps set
+# to Nightly install it even if another app read that feed. --notes
# (Markdown) becomes the item's release notes. The key (the base64 Ed25519
# seed from Sparkle's key format) is read from the environment and handed
# to Sparkle on standard input; it is never written to disk or printed.
@@ -56,7 +59,7 @@ while [ $# -gt 0 ]; do
shift
done
[ -f "$dmg" ] || { echo "--dmg must be a disk image" >&2; exit 2; }
-[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "--version must look like 1.2.3 or 1.2.3-suffix" >&2; exit 2; }
+[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]] || { echo "--version must look like 1.2.3, 1.2.3-suffix or 1.2.3-suffix+build" >&2; exit 2; }
case "$base" in http://* | https://*) ;; *) echo "--download-base must be a URL" >&2; exit 2 ;; esac
case "$base" in */) ;; *) base="$base/" ;; esac
[ -n "$out" ] || { echo "--out is required" >&2; exit 2; }
@@ -74,7 +77,9 @@ cp "$dmg" "$work/$name"
[ -n "$previous" ] && [ -s "$previous" ] && cp "$previous" "$work/cua-spaces-appcast.xml"
[ -n "$notes" ] && [ -s "$notes" ] && cp "$notes" "$work/${name%.dmg}.md"
channel=()
-[[ "$version" == *-* ]] && channel=(--channel beta)
+if [[ "${version%%+*}" == *-nightly* ]]; then channel=(--channel nightly)
+elif [[ "${version%%+*}" == *-* ]]; then channel=(--channel beta)
+fi
printf '%s' "$CUA_SPACES_SPARKLE_ED_PRIVATE_KEY" |
"$bin/generate_appcast" --ed-key-file - ${channel[@]+"${channel[@]}"} --embed-release-notes \
diff --git a/apps/cua-spaces-macos/scripts/verify-appcast.sh b/apps/cua-spaces-macos/scripts/verify-appcast.sh
index c980337053..45d3173fc8 100755
--- a/apps/cua-spaces-macos/scripts/verify-appcast.sh
+++ b/apps/cua-spaces-macos/scripts/verify-appcast.sh
@@ -5,8 +5,9 @@
# Checks one release's item in a Sparkle appcast the way the installed app
# will read it: the feed parses; the item for the disk image names its
# bundle version (sparkle:version is the app's CFBundleVersion, which
-# Sparkle compares), the full version, the beta channel exactly for an
-# X.Y.Z-suffix version, the app's minimum macOS and the image's exact
+# Sparkle compares), the full version, the nightly channel for a nightly
+# (X.Y.Z-nightly...) and the beta channel for any other X.Y.Z-suffix
+# version, the app's minimum macOS and the image's exact
# length; and its EdDSA signature verifies with the public key the app
# ships (SUPublicEDKey, read from the app inside the image, and the one
# committed in Support/Info.plist). With CUA_SPACES_SPARKLE_ED_PRIVATE_KEY
@@ -14,7 +15,10 @@
# The image must hold the Swift app, or with --electron the Electron app
# (the Sparkle cutover): either way "Cua Spaces.app", bundle id
# com.trycua.spaces.macos and CFBundleVersion X.Y.Z.N for the version's
-# X.Y.Z, which is what lets Sparkle replace one with the other.
+# X.Y.Z, which is what lets Sparkle replace one with the other. A nightly
+# names its own CFBundleVersion (build-release.sh --bundle-version: four or
+# five numbers, sorting between the release it was built from and the
+# next one).
#
# scripts/verify-appcast.sh --appcast cua-spaces-appcast.xml --dmg cua-spaces-0.2.0-darwin-universal.dmg \
# --url https://.../cua-spaces-0.2.0-darwin-universal.dmg --version 0.2.0 [--sparkle-bin DIR] [--electron]
@@ -85,7 +89,10 @@ item_min="$(sed -n 4p <<<"$fields")"
item_length="$(sed -n 5p <<<"$fields")"
signature="$(sed -n 6p <<<"$fields")"
want_channel=""
-[[ "$version" == *-* ]] && want_channel="beta"
+nightly=false
+if [[ "${version%%+*}" == *-nightly* ]]; then want_channel="nightly"; nightly=true
+elif [[ "${version%%+*}" == *-* ]]; then want_channel="beta"
+fi
fail=0
expect() { # expect WHAT GOT WANT
if [ "$2" = "$3" ]; then echo "PASS $1 ($2)"; else echo "FAIL $1: got '$2', want '$3'"; fail=1; fi
@@ -96,7 +103,11 @@ expect "channel" "$item_channel" "$want_channel"
expect "minimum macOS" "$item_min" "$min_os"
expect "length" "$item_length" "$(stat -f %z "$dmg")"
expect "bundle id" "$(read_key CFBundleIdentifier "$plist")" "com.trycua.spaces.macos"
-expect "CFBundleVersion is X.Y.Z.N" "$(sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+$/\1/' <<<"$bundle_version")" "${version%%-*}"
+if [ "$nightly" = true ]; then
+ expect "CFBundleVersion is numbers (a nightly's)" "$([[ "$bundle_version" =~ ^[0-9]+(\.[0-9]+){3,4}$ ]] && echo yes || echo "$bundle_version")" yes
+else
+ expect "CFBundleVersion is X.Y.Z.N" "$(sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+$/\1/' <<<"$bundle_version")" "${version%%-*}"
+fi
is_electron=false
[ -d "$app/Contents/Frameworks/Electron Framework.framework" ] && is_electron=true
expect "Electron app (--electron)" "$is_electron" "$electron"