Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(versioning): stamp beta builds at build time, keep the committed version X.Y.Z

Raystormsfbfb451ddb6f
diff --git a/AGENTS.md b/AGENTS.md
index a2f84b3..0fdfb9d 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -60,7 +60,7 @@ The checks the workflows run (`make -s <target>`):
- **C and shell suites:** `sigcheck`, `callscheck`, `webpatch-fixtures`, `peicon-fixtures`,
`panel-behavior`, `spawn-env`, `activatecheck`, `compatcheck`, `compatsvc-check`,
`shortcutcheck`, `launch-shell`, `envcheck`, `buildcheck`, `settingscheck`, `routecheck`,
- `bridgecheck`, `gamedrivecheck`, `launchercheck`, `seedcheck`, `gamefixescheck`
+ `bridgecheck`, `gamedrivecheck`, `launchercheck`, `seedcheck`, `gamefixescheck`, `versioncheck`
- **Hardware-free device checks:** `game-host-check`, `dualsense-check`, `steam-rumble-check`
`make tests-list` prints the test paths. A check whose tool or input is missing prints
diff --git a/Makefile b/Makefile
index d3fb076..1bb7204 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ DEPS := $(OBJS:.o=.d)
overlay-shim-bench iconmaker icon \
appinfo helpers-install ntdll-resolve bridge runcheck compatcheck \
compatsvc-check shortcutcheck scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck gamedrivecheck \
- gamefixescheck launchercheck padcheck launch-shell activatecheck FORCE
+ gamefixescheck launchercheck padcheck launch-shell activatecheck stamp-check versioncheck FORCE
APP_PAYLOAD := app/Sources/BridgeplayApp/Resources/payload
@@ -134,6 +134,11 @@ gamefixescheck:
@if [ ! -f dylib/tests/gamefixescheck.sh ]; then $(call SKIP,gamefixescheck,dylib/tests/gamefixescheck.sh); exit 0; fi; \
sh dylib/tests/gamefixescheck.sh dylib/feats/compat_run.sh
+# The beta stamp, the version bump and the upstream sync, on throwaway copies of the repo.
+versioncheck:
+ @if [ ! -f dylib/tests/versioncheck.sh ]; then $(call SKIP,versioncheck,dylib/tests/versioncheck.sh); exit 0; fi; \
+ sh dylib/tests/versioncheck.sh
+
padcheck:
@if [ ! -f dylib/tests/padcheck.sh ]; then $(call SKIP,padcheck,dylib/tests/padcheck.sh); exit 0; fi; \
sh dylib/tests/padcheck.sh dylib/feats/compat_run.sh
@@ -774,7 +779,11 @@ $(ICON_CAR): $(ICONGEN) $(ICON_MARK)
@test -s "$(ICON_DIR)/$(ICON_NAME).icns" || { echo "actool wrote no $(ICON_NAME).icns" >&2; exit 1; }
@echo "==> Built $@"
-app: app-payload $(ICON_CAR)
+# A malformed beta stamp fails before the slow build starts.
+stamp-check:
+ @sh scripts/stamp-beta.sh check
+
+app: stamp-check app-payload $(ICON_CAR)
swift build --package-path app -c release
rm -rf "$(APP_BUNDLE)"
@mkdir -p "$(APP_BUNDLE)/Contents/MacOS" "$(APP_BUNDLE)/Contents/Resources"
@@ -786,6 +795,7 @@ app: app-payload $(ICON_CAR)
"Set :CFBundleVersion $(APP_BUILD)" -c \
"Set :NotProtonVersion $(APP_UPSTREAM)" \
"$(APP_BUNDLE)/Contents/Info.plist"
+ @sh scripts/stamp-beta.sh apply "$(APP_BUNDLE)/Contents/Info.plist"
cp "$$(swift build --package-path app -c release --show-bin-path)/BridgeplayApp" \
"$(APP_BUNDLE)/Contents/MacOS/BridgeplayApp"
@mkdir -p "$(APP_BUNDLE)/Contents/Frameworks"
@@ -838,7 +848,8 @@ app: app-payload $(ICON_CAR)
codesign -f -s "$(APP_SIGN_ID)" "$(APP_BUNDLE)"
codesign --verify --strict --deep "$(APP_BUNDLE)"
@codesign -d -r- "$(APP_BUNDLE)" 2>&1 | sed -n 's/^#* *designated => /==> Designated requirement: /p'
- @echo "==> Built $(APP_BUNDLE) ($(APP_VERSION) build $(APP_BUILD), based on NotProton $(APP_UPSTREAM))"
+ @plist="$(APP_BUNDLE)/Contents/Info.plist"; \
+ echo "==> Built $(APP_BUNDLE) ($$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$$plist") build $$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$$plist"), based on NotProton $(APP_UPSTREAM))"
app-zip: app
rm -f "$(APP_ZIP)"
@@ -888,7 +899,7 @@ CI_CHECKS := mincheck l10ncheck \
sigcheck callscheck webpatch-fixtures peicon-fixtures panel-behavior spawn-env \
activatecheck compatcheck compatsvc-check shortcutcheck launch-shell envcheck \
buildcheck settingscheck routecheck bridgecheck gamedrivecheck launchercheck \
- seedcheck gamefixescheck padcheck np-native-tests native-shim-tests \
+ seedcheck gamefixescheck versioncheck padcheck np-native-tests native-shim-tests \
app-tests game-host-check dualsense-check steam-rumble-check
# app.yml runs the checks that need the built app in its build job and the rest in a
diff --git a/app/Info.plist b/app/Info.plist
index 61e41e9..fb8d3a1 100644
--- a/app/Info.plist
+++ b/app/Info.plist
@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>BridgeplayChannel</key>
+ <string>stable</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleLocalizations</key>
diff --git a/app/Sources/BridgeplayApp/Support/ProductVersion.swift b/app/Sources/BridgeplayApp/Support/ProductVersion.swift
index 23541cb..7964eb9 100644
--- a/app/Sources/BridgeplayApp/Support/ProductVersion.swift
+++ b/app/Sources/BridgeplayApp/Support/ProductVersion.swift
@@ -5,8 +5,9 @@ import Foundation
enum ProductVersion {
- // CFBundleShortVersionString: Bridgeplay semver, the same string recorded as the
- // installed build in Steam.
+ // CFBundleShortVersionString: the label people see, X.Y.Z or, in a beta build,
+ // X.Y.Z-beta.N (stamped at build time, see scripts/stamp-beta.sh). About, Status and
+ // game reports show it; installs and updates are ordered by `build`, never by this.
static var short: String { AppVersion.display }
// CFBundleVersion: the release counter Sparkle orders updates by.
@@ -15,6 +16,19 @@ enum ProductVersion {
// The NotProton release this build is based on.
static var upstream: String? { stamped(Bundle.main.object(forInfoDictionaryKey: "NotProtonVersion")) }
+ enum Channel: String {
+ case stable, beta
+ }
+
+ // BridgeplayChannel: "beta" in a build stamped by scripts/stamp-beta.sh. A missing,
+ // empty or unreadable value means stable.
+ static var channel: Channel { channel(from: Bundle.main.object(forInfoDictionaryKey: "BridgeplayChannel")) }
+
+ static func channel(from value: Any?) -> Channel {
+ guard let text = value as? String else { return .stable }
+ return Channel(rawValue: text.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()) ?? .stable
+ }
+
static var display: String { display(short: short, build: build, upstream: upstream) }
// "Bridgeplay 2.0.0 (32) · based on NotProton 1.2.0"
diff --git a/app/Sources/BridgeplayApp/SystemStatus.swift b/app/Sources/BridgeplayApp/SystemStatus.swift
index 748fd70..28fea5a 100644
--- a/app/Sources/BridgeplayApp/SystemStatus.swift
+++ b/app/Sources/BridgeplayApp/SystemStatus.swift
@@ -8,7 +8,8 @@ import UniformTypeIdentifiers
enum AppVersion {
static let fallback = "0.1.0-dev"
- // The semver people see. It went from 3.5.0 back to 0.7.0, so it doesn't order installs.
+ // The label people see: X.Y.Z, or X.Y.Z-beta.N in a beta build. It went from 3.5.0 back to 0.7.0,
+ // so it never orders installs.
static var display: String {
Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? fallback
}
diff --git a/app/Tests/BridgeplayAppTests/VersioningTests.swift b/app/Tests/BridgeplayAppTests/VersioningTests.swift
index 23aaf21..0af02d3 100644
--- a/app/Tests/BridgeplayAppTests/VersioningTests.swift
+++ b/app/Tests/BridgeplayAppTests/VersioningTests.swift
@@ -59,6 +59,63 @@ struct ProductVersionTests {
== "Bridgeplay 2.0.0 (32) · based on NotProton 1.2.0")
#expect(ProductVersion.display(short: "0.1.0-dev", build: nil, upstream: nil) == "Bridgeplay 0.1.0-dev")
}
+
+ // The committed version is a plain X.Y.Z. A beta label like 0.7.3-beta.1 is stamped into the
+ // built app by scripts/stamp-beta.sh and never committed.
+ @Test("The committed version is a plain X.Y.Z")
+ func committedVersionHasNoBetaLabel() throws {
+ let version = try Self.define("BRIDGEPLAY_VERSION")
+ let parts = version.split(separator: ".", omittingEmptySubsequences: false)
+ #expect(parts.count == 3 && parts.allSatisfy { !$0.isEmpty && $0.allSatisfy { $0.isASCII && $0.isWholeNumber } },
+ "\(version)")
+ }
+
+ @Test("A stamped beta label shows in the display, with the build it carries")
+ func betaLabelDisplays() {
+ #expect(ProductVersion.display(short: "0.7.3-beta.1", build: "50", upstream: "1.2.0")
+ == "Bridgeplay 0.7.3-beta.1 (50) · based on NotProton 1.2.0")
+ }
+
+ @Test("A missing, empty or unreadable channel means stable")
+ func channelDefaultsToStable() {
+ #expect(ProductVersion.channel(from: "beta") == .beta)
+ #expect(ProductVersion.channel(from: " Beta\n") == .beta)
+ #expect(ProductVersion.channel(from: "stable") == .stable)
+ #expect(ProductVersion.channel(from: nil) == .stable)
+ #expect(ProductVersion.channel(from: "") == .stable)
+ #expect(ProductVersion.channel(from: "nightly") == .stable)
+ #expect(ProductVersion.channel(from: 1) == .stable)
+ }
+
+ private static func published(_ build: Int, _ label: String) -> DeploymentContent.Build {
+ DeploymentContent.Build(version: AppVersion.deployKey(build: String(build), display: label), builtAt: 1)
+ }
+
+ // Installs are ordered by the build alone. 0.7.3-beta.1 follows 0.7.2 (build 44) and
+ // the stable 0.7.3 is the number the betas were named after.
+ @Test("A beta orders above the stable it branched from, and the next stable above every beta")
+ func betaOrdering() {
+ let stable = Self.published(44, "0.7.2")
+ let beta1 = Self.published(45, "0.7.3-beta.1")
+ let beta2 = Self.published(46, "0.7.3-beta.2")
+ let next = Self.published(47, "0.7.3")
+ for beta in [beta1, beta2] {
+ #expect(beta.isNewer(than: stable) && !stable.isNewer(than: beta))
+ #expect(next.isNewer(than: beta) && !beta.isNewer(than: next))
+ }
+ #expect(beta2.isNewer(than: beta1) && !beta1.isNewer(than: beta2))
+ // Build 100 stays above 99: the build compares as a number, not as text.
+ #expect(Self.published(100, "0.7.4").isNewer(than: Self.published(99, "0.7.4-beta.9")))
+ }
+
+ @Test("A beta record is never taken for an older or newer build by its label")
+ func labelDoesNotOrder() {
+ // By label 0.10.0-beta.1 is above 0.9.0, and the build still decides.
+ let beta = Self.published(46, "0.10.0-beta.1")
+ let stable = Self.published(47, "0.9.0")
+ #expect(stable.isNewer(than: beta) && !beta.isNewer(than: stable))
+ #expect(AppVersion.label(deployed: AppVersion.deployKey(build: "46", display: "0.10.0-beta.1")) == "build 46")
+ }
}
@Suite("Post-update refresh")
diff --git a/docs/BUILD-LOCAL.md b/docs/BUILD-LOCAL.md
index c753e7b..e2d8bd1 100644
--- a/docs/BUILD-LOCAL.md
+++ b/docs/BUILD-LOCAL.md
@@ -36,7 +36,8 @@ output to `build/logs/<phase>.log`.
At the end the script prints the version (from `dylib/version.h`: `make app` writes
`BRIDGEPLAY_VERSION` into `CFBundleShortVersionString` and `BRIDGEPLAY_BUILD` into
-`CFBundleVersion`, see [RELEASING.md](RELEASING.md)) and the zip's sha256.
+`CFBundleVersion`, see [RELEASING.md](RELEASING.md)) and the zip's sha256. A beta build prints its
+stamped label instead (see "Betas" in RELEASING.md).
## Timings (M5 Max, 18 cores, Xcode 27.0 beta 27A5218g)
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index ea0b9de..aa21ee7 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -39,6 +39,48 @@ record holds `4.0.<build>` (`AppVersion.deployKey`), not the semver: it sorts pa
older record (`1.2.0-…`, `3.5.0`), and an older app that another macOS user still runs sees
a newer install and leaves it alone. `VersioningTests` guards both.
+## Betas
+
+The committed `BRIDGEPLAY_VERSION` is always a plain `X.Y.Z`, on `main` and on `beta`, so merging
+`main` into `beta` never conflicts over a version. A beta's label, build number and channel are
+stamped into the app at build time by `scripts/stamp-beta.sh` and never committed;
+`bump-version.sh`, `stamp-beta.sh` and `make app` refuse a beta label in `dylib/version.h`.
+
+```sh
+BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=46 scripts/build-local.sh # or make app
+BRIDGEPLAY_BETA=2 BRIDGEPLAY_BETA_BUILD=47 BRIDGEPLAY_BETA_PLANNED=0.8.0 make app
+```
+
+| Variable | Meaning |
+|---|---|
+| `BRIDGEPLAY_BETA` | The beta number N, a positive integer. Setting it at all asks for a beta; anything but a positive integer fails the build, and so does setting the two below without it |
+| `BRIDGEPLAY_BETA_BUILD` | The build number: the highest build ever published, stable or beta, plus one. Required, and above the committed build, so the beta orders above the stable it branched from |
+| `BRIDGEPLAY_BETA_PLANNED` | The release the beta is named after. Defaults to the next patch of the committed version; name a milestone minor (`0.8.0`) to override it. Must be above the committed version |
+
+A beta built from committed `0.7.2` therefore reads `0.7.3-beta.1` by default (`CFBundleShortVersionString`,
+shown in About, Status and game reports), carries the build it was given (`CFBundleVersion`) and
+`BridgeplayChannel` `beta` in `Info.plist`; a normal build keeps the committed version and build and
+the `stable` channel `app/Info.plist` ships with. A missing or unreadable channel means stable.
+Installs and updates are ordered by the build alone, never by the label (`AppVersion.deployKey`),
+which is why every published build, prerelease or not, must take a higher number than all before it.
+
+The stable that ships the beta is bumped as the version policy says, usually a patch, to the number
+the beta was named after, and takes the highest published build into account so it outranks every beta:
+
+```sh
+scripts/bump-version.sh patch --named 0.7.3 --highest-build 47 # minor --named 0.8.0 for a milestone
+```
+
+`--named` fails the bump when it would land anywhere else, and `BRIDGEPLAY_HIGHEST_BUILD` can stand in
+for `--highest-build`. Without it the bump only knows the committed build, so give it the real maximum.
+
+Upstream merges go to `beta`: `scripts/sync-upstream.sh` merges and commits no version bump there
+(`BRIDGEPLAY_BETA_BRANCH` names the branch, default `beta`). On `main`, the exception for a security or
+crash hotfix from upstream, it still bumps the patch.
+
+`release-local.sh` does not publish betas: a stamped build no longer matches `dylib/version.h`, so
+its version check stops it. `make versioncheck` covers the stamp, the bump and the sync.
+
## Steps
0. Push the changes first and wait for the `app` workflow to pass on them
@@ -49,7 +91,8 @@ a newer install and leaves it alone. `VersioningTests` guards both.
scripts/bump-version.sh patch # or minor / major
git commit -m "chore(release): Bridgeplay X.Y.Z" dylib/version.h
```
- `scripts/sync-upstream.sh` already bumps the patch after an upstream merge.
+ `scripts/sync-upstream.sh` already bumps the patch after an upstream merge on `main`; on `beta` it
+ commits no bump, see Betas.
2. Push to `main` of `raymondchins/Bridgeplay` (the script refuses anything else).
3. Optionally rehearse: `scripts/release-local.sh --dry-run` writes the zip and appcast to
`out/release/` from an app already built with `make app`, without publishing or reading
diff --git a/dylib/tests/versioncheck.sh b/dylib/tests/versioncheck.sh
new file mode 100644
index 0000000..04d03ac
--- /dev/null
+++ b/dylib/tests/versioncheck.sh
@@ -0,0 +1,382 @@
+#!/bin/sh
+# Beta stamping: scripts/stamp-beta.sh, the version bump and the upstream sync, run on
+# throwaway copies of the repo's scripts, so nothing in the checkout changes.
+#
+# sh dylib/tests/versioncheck.sh
+#
+# The committed version stays X.Y.Z. A beta build stamps X.Y.Z-beta.N, its build number and
+# the beta channel into the app at build time, and a normal build stamps nothing.
+set -eu
+
+repo=$(cd "$(dirname "$0")/../.." && pwd)
+work=$(mktemp -d "${TMPDIR:-/tmp}/np-versioncheck.XXXXXX")
+trap 'rm -rf "$work"' EXIT
+
+unset BRIDGEPLAY_BETA BRIDGEPLAY_BETA_BUILD BRIDGEPLAY_BETA_PLANNED \
+ BRIDGEPLAY_HIGHEST_BUILD BRIDGEPLAY_BETA_BRANCH PLISTBUDDY
+
+checks=0
+failures=0
+pass() { checks=$((checks + 1)); }
+fail() {
+ checks=$((checks + 1))
+ failures=$((failures + 1))
+ echo "FAIL: $*" >&2
+}
+
+expect_eq() { # name wanted got
+ if [ "$2" = "$3" ]; then pass; else fail "$1: wanted '$2', got '$3'"; fi
+}
+
+# expect_ok NAME CMD...: succeeds, output in $out
+expect_ok() {
+ _name=$1
+ shift
+ if out=$("$@" 2>&1); then pass; else fail "$_name: $* failed: $out"; fi
+}
+
+# expect_refused NAME CMD...: fails
+expect_refused() {
+ _name=$1
+ shift
+ if out=$("$@" 2>&1); then fail "$_name: $* succeeded: $out"; else pass; fi
+}
+
+expect_same() { # name file copy
+ if cmp -s "$2" "$3"; then pass; else fail "$1: $2 changed"; fi
+}
+
+write_header() { # file version build upstream
+ cat >"$1" <<EOF
+// Build version string
+#ifndef NOTPROTON_VERSION_H
+#define NOTPROTON_VERSION_H
+
+#define NOTPROTON_VERSION "$4"
+
+// Bridgeplay's own version.
+// BRIDGEPLAY_VERSION semver people see
+// BRIDGEPLAY_BUILD +1 on every release
+#define BRIDGEPLAY_VERSION "$2"
+#define BRIDGEPLAY_BUILD $3
+
+#endif // NOTPROTON_VERSION_H
+EOF
+}
+
+# fixture DIR VERSION BUILD: the version scripts around a header of our own.
+fixture() {
+ mkdir -p "$1/scripts" "$1/dylib" "$1/app"
+ for s in version-lib stamp-beta bump-version sync-upstream; do
+ tr -d '\r' <"$repo/scripts/$s.sh" >"$1/scripts/$s.sh"
+ chmod +x "$1/scripts/$s.sh"
+ done
+ write_header "$1/dylib/version.h" "$2" "$3" "1.2.0"
+ tr -d '\r' <"$repo/app/Info.plist" >"$1/app/Info.plist"
+}
+
+define() { # file name
+ sed -n 's/^#define '"$2"' "\{0,1\}\([^"]*\)"\{0,1\}$/\1/p' "$1"
+}
+
+# --- the template is a stable build -----------------------------------------------
+
+channel_line=$(grep -A1 '<key>BridgeplayChannel</key>' "$repo/app/Info.plist" | tail -n 1 | tr -d '\r\t ')
+expect_eq "app/Info.plist carries the stable channel" "<string>stable</string>" "$channel_line"
+
+# The real header is committed as a plain X.Y.Z.
+version=$(define "$repo/dylib/version.h" BRIDGEPLAY_VERSION)
+case "$version" in
+ *[!0-9.]*|''|.*|*.|*..*|*.*.*.*) fail "dylib/version.h BRIDGEPLAY_VERSION '$version' is not X.Y.Z" ;;
+ *.*.*) pass ;;
+ *) fail "dylib/version.h BRIDGEPLAY_VERSION '$version' is not X.Y.Z" ;;
+esac
+
+# --- stamp-beta.sh ----------------------------------------------------------------
+
+fx=$work/stamp
+fixture "$fx" 0.7.2 44
+cp "$fx/dylib/version.h" "$work/version.h.orig"
+cp "$fx/app/Info.plist" "$work/Info.plist.orig"
+# stamp VAR=value... MODE [ARG]: the leading assignments go into the script's environment.
+stamp() {
+ (
+ # shellcheck disable=SC2163 # the argument is NAME=value, which export takes
+ while [ $# -gt 0 ]; do
+ case $1 in
+ [A-Za-z]*=*) export "$1"; shift ;;
+ *) break ;;
+ esac
+ done
+ sh "$fx/scripts/stamp-beta.sh" "$@"
+ )
+}
+
+# A normal build keeps the committed version and build, and the stable channel.
+expect_ok "normal check" stamp x=1 check
+expect_ok "normal print" stamp x=1 print
+expect_eq "normal print" "version=0.7.2
+build=44
+channel=stable" "$out"
+# apply must not even start PlistBuddy: the template is already what a normal build ships.
+cp "$fx/app/Info.plist" "$work/Info.plist"
+expect_ok "normal apply" stamp PLISTBUDDY=/nonexistent/PlistBuddy apply "$work/Info.plist"
+expect_same "normal apply leaves the plist alone" "$work/Info.plist.orig" "$work/Info.plist"
+
+# A beta takes N from the build command; the planned release defaults to the next patch.
+expect_ok "beta default" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 print
+expect_eq "beta default" "version=0.7.3-beta.1
+build=50
+channel=beta" "$out"
+expect_ok "beta 12" stamp BRIDGEPLAY_BETA=12 BRIDGEPLAY_BETA_BUILD=50 print
+expect_eq "beta 12" "version=0.7.3-beta.12
+build=50
+channel=beta" "$out"
+
+# A milestone minor works the same way.
+expect_ok "milestone" stamp BRIDGEPLAY_BETA=2 BRIDGEPLAY_BETA_BUILD=51 BRIDGEPLAY_BETA_PLANNED=0.8.0 print
+expect_eq "milestone" "version=0.8.0-beta.2
+build=51
+channel=beta" "$out"
+expect_ok "planned patch" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 BRIDGEPLAY_BETA_PLANNED=0.7.3 print
+expect_eq "planned patch" "version=0.7.3-beta.1
+build=50
+channel=beta" "$out"
+expect_ok "planned further patch" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 BRIDGEPLAY_BETA_PLANNED=0.7.10 print
+expect_eq "planned further patch" "version=0.7.10-beta.1
+build=50
+channel=beta" "$out"
+# An empty planned release is the default.
+expect_ok "planned empty" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 BRIDGEPLAY_BETA_PLANNED= print
+expect_eq "planned empty" "version=0.7.3-beta.1
+build=50
+channel=beta" "$out"
+
+# A planned release not above the committed version fails the build.
+for planned in 0.7.2 0.7.1 0.6.9 0.1.0 0.7 0.7.3.1 0.07.3 v0.8.0 0.7.3-beta.1 0.8.0-beta.1 " 0.8.0" 0.8.x; do
+ expect_refused "planned '$planned'" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 BRIDGEPLAY_BETA_PLANNED="$planned" check
+done
+
+# The beta number is a positive integer.
+for n in 0 00 01 -1 +1 1.5 abc "1 2" "" " 1" "1
+2" 1234567890; do
+ expect_refused "beta number '$n'" stamp BRIDGEPLAY_BETA="$n" BRIDGEPLAY_BETA_BUILD=50 check
+ expect_refused "beta number '$n' print" stamp BRIDGEPLAY_BETA="$n" BRIDGEPLAY_BETA_BUILD=50 print
+done
+# A missing number fails, whatever else is set.
+expect_refused "no beta number, build given" stamp BRIDGEPLAY_BETA_BUILD=50 check
+expect_refused "no beta number, planned given" stamp BRIDGEPLAY_BETA_PLANNED=0.8.0 check
+
+# The build number is given, a positive integer and above the committed build.
+expect_refused "no beta build" stamp BRIDGEPLAY_BETA=1 check
+for b in 0 -5 abc 4.5 "" 44 43 1 044; do
+ expect_refused "beta build '$b'" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD="$b" check
+done
+expect_ok "beta build 45" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=45 check
+
+# A failed or successful beta build commits nothing.
+expect_same "beta builds leave version.h alone" "$work/version.h.orig" "$fx/dylib/version.h"
+
+# apply writes the label, the build and the channel through PlistBuddy, and only for a beta.
+cat >"$work/fake-plistbuddy" <<'EOF'
+#!/bin/sh
+printf '%s\n' "$@" >"$FAKE_PLISTBUDDY_LOG"
+EOF
+chmod +x "$work/fake-plistbuddy"
+FAKE_PLISTBUDDY_LOG=$work/plistbuddy.log
+export FAKE_PLISTBUDDY_LOG
+expect_ok "beta apply" stamp BRIDGEPLAY_BETA=3 BRIDGEPLAY_BETA_BUILD=52 BRIDGEPLAY_BETA_PLANNED=0.8.0 \
+ PLISTBUDDY="$work/fake-plistbuddy" apply "$work/Info.plist"
+expect_eq "beta apply arguments" "-c
+Set :CFBundleShortVersionString 0.8.0-beta.3
+-c
+Set :CFBundleVersion 52
+-c
+Set :BridgeplayChannel beta
+$work/Info.plist" "$(cat "$work/plistbuddy.log")"
+expect_refused "apply without a plist" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 \
+ PLISTBUDDY="$work/fake-plistbuddy" apply "$work/missing.plist"
+
+# With the real PlistBuddy, the plist reads back as a beta, and the template is untouched.
+if [ -x /usr/libexec/PlistBuddy ]; then
+ cp "$work/Info.plist.orig" "$work/Info.plist"
+ expect_ok "real apply" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 apply "$work/Info.plist"
+ for key_value in CFBundleShortVersionString:0.7.3-beta.1 CFBundleVersion:50 BridgeplayChannel:beta \
+ NotProtonVersion:0.0.0; do
+ got=$(/usr/libexec/PlistBuddy -c "Print :${key_value%%:*}" "$work/Info.plist")
+ expect_eq "real apply ${key_value%%:*}" "${key_value#*:}" "$got"
+ done
+ expect_same "the beta stamp leaves the template alone" "$work/Info.plist.orig" "$fx/app/Info.plist"
+else
+ echo "==> versioncheck: PlistBuddy not present, the real plist round trip is skipped"
+fi
+
+# A beta label is never accepted as the committed version.
+for bad in 0.7.3-beta.1 0.7.3-beta 0.7 0.7.3.1 v0.7.3 0.07.3 1.2.x ""; do
+ badfx=$work/bad
+ rm -rf "$badfx"
+ fixture "$badfx" "$bad" 44
+ expect_refused "committed '$bad' (check)" env x=1 sh "$badfx/scripts/stamp-beta.sh" check
+ expect_refused "committed '$bad' (beta)" env BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=50 \
+ sh "$badfx/scripts/stamp-beta.sh" check
+ expect_refused "committed '$bad' (bump)" env x=1 sh "$badfx/scripts/bump-version.sh" patch
+done
+
+# --- bump-version.sh --------------------------------------------------------------
+
+bumpfx=$work/bump
+bump() { # bump PART [ARGS]: from 0.7.2 build 44
+ rm -rf "$bumpfx"
+ fixture "$bumpfx" 0.7.2 44
+ env "${bump_env:-x=1}" sh "$bumpfx/scripts/bump-version.sh" "$@"
+}
+bumped() { # bumped VERSION BUILD: what the header says now
+ expect_eq "bumped version" "$1" "$(define "$bumpfx/dylib/version.h" BRIDGEPLAY_VERSION)"
+ expect_eq "bumped build" "$2" "$(define "$bumpfx/dylib/version.h" BRIDGEPLAY_BUILD)"
+}
+
+expect_ok "patch" bump patch
+bumped 0.7.3 45
+expect_ok "minor" bump minor
+bumped 0.8.0 45
+expect_ok "major" bump major
+bumped 1.0.0 45
+expect_eq "upstream stays" 1.2.0 "$(define "$bumpfx/dylib/version.h" NOTPROTON_VERSION)"
+
+# The stable that ships a beta outranks every published build, beta ones included.
+expect_ok "highest build" bump patch --highest-build 50
+bumped 0.7.3 51
+expect_ok "highest build below the committed one" bump patch --highest-build 30
+bumped 0.7.3 45
+expect_ok "highest build equal to the committed one" bump patch --highest-build 44
+bumped 0.7.3 45
+bump_env=BRIDGEPLAY_HIGHEST_BUILD=60
+expect_ok "highest build from the environment" bump patch
+bumped 0.7.3 61
+bump_env=x=1
+for b in 0 abc -3 4.5 ""; do
+ expect_refused "highest build '$b'" bump patch --highest-build "$b"
+done
+
+# --named is the release the beta was named after: the bump must land exactly there.
+expect_ok "named patch" bump patch --named 0.7.3 --highest-build 50
+bumped 0.7.3 51
+expect_ok "named milestone" bump minor --named 0.8.0 --highest-build 50
+bumped 0.8.0 51
+expect_refused "named differs from the patch" bump patch --named 0.8.0
+expect_same "a refused bump leaves version.h alone" "$work/version.h.orig" "$bumpfx/dylib/version.h"
+expect_refused "named differs from the minor" bump minor --named 0.7.3
+expect_refused "named is malformed" bump patch --named 0.7.3-beta.1
+expect_refused "no part" bump
+expect_refused "unknown part" bump beta
+
+# A beta, then the stable it was named after: the beta is above the stable it branched from,
+# and the next stable is above the beta.
+stable_build=44
+expect_ok "beta over the last stable" stamp BRIDGEPLAY_BETA=1 BRIDGEPLAY_BETA_BUILD=45 print
+expect_eq "beta label" "version=0.7.3-beta.1
+build=45
+channel=beta" "$out"
+beta_build=45
+expect_ok "next stable" bump patch --named 0.7.3 --highest-build "$beta_build"
+next_build=$(define "$bumpfx/dylib/version.h" BRIDGEPLAY_BUILD)
+if [ "$beta_build" -gt "$stable_build" ] && [ "$next_build" -gt "$beta_build" ]; then pass; else
+ fail "build order: stable $stable_build, beta $beta_build, next stable $next_build"
+fi
+
+# --- sync-upstream.sh -------------------------------------------------------------
+
+git_in() { # git_in DIR ARGS...
+ _dir=$1
+ shift
+ git -C "$_dir" -c user.name=versioncheck -c [email protected] \
+ -c commit.gpgsign=false -c core.autocrlf=false -c init.defaultBranch=main "$@"
+}
+
+# sync_fixture NAME: an upstream repo and a clone of it that follows it as `upstream`.
+sync_fixture() {
+ up=$work/$1-upstream
+ wk=$work/$1
+ fixture "$up" 0.7.2 44
+ git_in "$work" init -q "$up"
+ git_in "$up" symbolic-ref HEAD refs/heads/main
+ echo base >"$up/file.txt"
+ git_in "$up" add -A
+ git_in "$up" commit -q -m base
+ git_in "$work" clone -q "$up" "$wk"
+ git_in "$wk" config user.name versioncheck
+ git_in "$wk" config user.email [email protected]
+ git_in "$wk" config commit.gpgsign false
+ git_in "$wk" config core.autocrlf false
+ git_in "$wk" remote rename origin upstream
+}
+
+sync_upstream() { # sync_upstream: run it in $wk
+ (cd "$wk" && env "$@" sh scripts/sync-upstream.sh)
+}
+
+version_in() { define "$wk/dylib/version.h" "$1"; }
+
+# On main an upstream merge still bumps the patch, as before.
+sync_fixture onmain
+echo more >"$up/file.txt"
+git_in "$up" commit -q -am "upstream change"
+git_in "$wk" checkout -q -B main
+expect_ok "sync on main" sync_upstream x=1
+expect_eq "main version" 0.7.3 "$(version_in BRIDGEPLAY_VERSION)"
+expect_eq "main build" 45 "$(version_in BRIDGEPLAY_BUILD)"
+expect_eq "main commits the bump" "chore(release): bump Bridgeplay to 0.7.3 after upstream merge" \
+ "$(git_in "$wk" log -1 --format=%s)"
+
+# On beta it merges and commits no version change.
+sync_fixture onbeta
+echo more >"$up/file.txt"
+git_in "$up" commit -q -am "upstream change"
+git_in "$wk" checkout -q -B beta
+expect_ok "sync on beta" sync_upstream x=1
+expect_eq "beta version" 0.7.2 "$(version_in BRIDGEPLAY_VERSION)"
+expect_eq "beta build" 44 "$(version_in BRIDGEPLAY_BUILD)"
+expect_eq "beta merged upstream" more "$(cat "$wk/file.txt")"
+case $(git_in "$wk" log --format=%s) in
+ *chore\(release\)*) fail "a version bump was committed on beta" ;;
+ *) pass ;;
+esac
+expect_eq "beta tree is clean" "" "$(git_in "$wk" status --porcelain --untracked-files=no)"
+
+# The beta branch name can be changed; any other branch bumps as on main.
+sync_fixture named
+echo more >"$up/file.txt"
+git_in "$up" commit -q -am "upstream change"
+git_in "$wk" checkout -q -B next
+expect_ok "sync on a named beta branch" sync_upstream BRIDGEPLAY_BETA_BRANCH=next
+expect_eq "named branch version" 0.7.2 "$(version_in BRIDGEPLAY_VERSION)"
+sync_fixture other
+echo more >"$up/file.txt"
+git_in "$up" commit -q -am "upstream change"
+git_in "$wk" checkout -q -B feature
+expect_ok "sync on another branch" sync_upstream x=1
+expect_eq "other branch version" 0.7.3 "$(version_in BRIDGEPLAY_VERSION)"
+
+# A version.h conflict is still resolved: Bridgeplay's lines stay, NotProton takes upstream's.
+for branch in main beta; do
+ sync_fixture "conflict-$branch"
+ sed 's/^#define NOTPROTON_VERSION ".*"$/#define NOTPROTON_VERSION "1.3.0"/' "$up/dylib/version.h" >"$up/version.h.new"
+ cat "$up/version.h.new" >"$up/dylib/version.h"
+ rm "$up/version.h.new"
+ git_in "$up" commit -q -am "upstream 1.3.0"
+ git_in "$wk" checkout -q -B "$branch"
+ sed 's/^#define NOTPROTON_VERSION ".*"$/#define NOTPROTON_VERSION "1.2.9-local"/' "$wk/dylib/version.h" >"$wk/version.h.new"
+ cat "$wk/version.h.new" >"$wk/dylib/version.h"
+ rm "$wk/version.h.new"
+ git_in "$wk" commit -q -am "local change"
+ expect_ok "conflicting sync on $branch" sync_upstream x=1
+ expect_eq "$branch upstream version" 1.3.0 "$(version_in NOTPROTON_VERSION)"
+done
+expect_eq "conflict on main bumps the patch" 0.7.3 "$(define "$work/conflict-main/dylib/version.h" BRIDGEPLAY_VERSION)"
+expect_eq "conflict on beta keeps the version" 0.7.2 "$(define "$work/conflict-beta/dylib/version.h" BRIDGEPLAY_VERSION)"
+
+if [ "$failures" -ne 0 ]; then
+ echo "==> versioncheck: $failures of $checks checks failed" >&2
+ exit 1
+fi
+echo "==> versioncheck: $checks checks passed"
diff --git a/dylib/version.h b/dylib/version.h
index ba6d4a5..a99ff7d 100644
--- a/dylib/version.h
+++ b/dylib/version.h
@@ -10,6 +10,9 @@
// (CFBundleShortVersionString, sparkle:shortVersionString)
// BRIDGEPLAY_BUILD +1 on every release, continuing the old "-ray.N" counter; Sparkle
// orders updates by it (CFBundleVersion, sparkle:version)
+// Both are committed as they are for a stable release: a plain X.Y.Z and the next build. A beta
+// build stamps its X.Y.Z-beta.N label, build number and channel in at build time
+// (scripts/stamp-beta.sh); those are never committed.
// Change both with scripts/bump-version.sh, see docs/RELEASING.md.
#define BRIDGEPLAY_VERSION "0.7.0"
#define BRIDGEPLAY_BUILD 44
diff --git a/scripts/build-local.sh b/scripts/build-local.sh
index 8f3743e..93e2897 100755
--- a/scripts/build-local.sh
+++ b/scripts/build-local.sh
@@ -15,6 +15,7 @@
# app/.build SwiftPM build and the Sparkle checkout
#
# Overridable: DEVELOPER_DIR (default Xcode-beta), JOBS (default hw.ncpu)
+# A beta build: BRIDGEPLAY_BETA=N BRIDGEPLAY_BETA_BUILD=B [BRIDGEPLAY_BETA_PLANNED=X.Y.Z], see docs/RELEASING.md
set -eu
@@ -51,6 +52,9 @@ if [ -z "${DEVELOPER_DIR:-}" ] || [ ! -d "$DEVELOPER_DIR" ]; then
fi
export DEVELOPER_DIR
+# A malformed beta stamp (BRIDGEPLAY_BETA*, see stamp-beta.sh) fails now, not after the slow phases.
+sh scripts/stamp-beta.sh check
+
JOBS=${JOBS:-$(sysctl -n hw.ncpu)}
LOG_DIR=$repo/build/logs
mkdir -p "$LOG_DIR"
diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh
index 7f40acf..01a6491 100755
--- a/scripts/bump-version.sh
+++ b/scripts/bump-version.sh
@@ -1,18 +1,26 @@
#!/bin/sh
# Bump Bridgeplay's version in dylib/version.h before a release.
#
-# scripts/bump-version.sh patch|minor|major [--upstream "NotProton X.Y.Z"]
+# scripts/bump-version.sh patch|minor|major [--upstream "NotProton X.Y.Z"] [--highest-build N] [--named X.Y.Z]
#
# Almost always patch (fixes, features, upstream merges); minor and major are rare, see
# docs/RELEASING.md. BRIDGEPLAY_BUILD goes up by one every time, since Sparkle orders updates by it.
# --upstream records the NotProton release this build is based on (NOTPROTON_VERSION);
# a clean upstream merge already brings upstream's value, so it is rarely needed.
+# --highest-build N (or BRIDGEPLAY_HIGHEST_BUILD) is the highest build ever published, stable or
+# beta. The new build is one above the larger of N and the committed build, so the stable that
+# ships a beta outranks every beta. --named X.Y.Z is the release that beta was named after: the
+# bump fails unless it lands exactly there.
+# The committed version is always a plain X.Y.Z; a beta label is stamped at build time
+# (scripts/stamp-beta.sh) and never committed.
# Edits the file only; commit it yourself. See docs/RELEASING.md.
set -eu
repo=$(cd "$(dirname "$0")/.." && pwd)
header=$repo/dylib/version.h
+# shellcheck source=/dev/null
+. "$repo/scripts/version-lib.sh"
usage() {
sed -n '4p' "$0" | sed 's/^# \{0,1\}//' >&2
@@ -26,6 +34,8 @@ case "$part" in
esac
upstream=""
+highest=${BRIDGEPLAY_HIGHEST_BUILD:-}
+named=""
while [ $# -gt 0 ]; do
case "$1" in
--upstream)
@@ -33,39 +43,57 @@ while [ $# -gt 0 ]; do
upstream=${2#NotProton }
shift 2
;;
+ --highest-build)
+ [ $# -ge 2 ] || usage
+ is_posint "$2" || { echo "==> --highest-build wants a positive integer, got '$2'" >&2; exit 1; }
+ highest=$2
+ shift 2
+ ;;
+ --named)
+ [ $# -ge 2 ] || usage
+ named=$2
+ shift 2
+ ;;
*) usage ;;
esac
done
die() { echo "==> $*" >&2; exit 1; }
-version=$(sed -n 's/^#define BRIDGEPLAY_VERSION "\(.*\)"$/\1/p' "$header")
-build=$(sed -n 's/^#define BRIDGEPLAY_BUILD \([0-9][0-9]*\)$/\1/p' "$header")
-based=$(sed -n 's/^#define NOTPROTON_VERSION "\(.*\)"$/\1/p' "$header")
-echo "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || die "BRIDGEPLAY_VERSION '$version' in $header is not X.Y.Z"
+version=$(header_string "$header" BRIDGEPLAY_VERSION)
+build=$(header_number "$header" BRIDGEPLAY_BUILD)
+based=$(header_string "$header" NOTPROTON_VERSION)
+is_semver "$version" || die "BRIDGEPLAY_VERSION '$version' in $header is not X.Y.Z; a beta label is stamped at build time, never committed"
[ -n "$build" ] || die "no numeric BRIDGEPLAY_BUILD in $header"
[ -n "$based" ] || die "no NOTPROTON_VERSION in $header"
if [ -n "$upstream" ]; then
echo "$upstream" | grep -Eq '^[0-9]+(\.[0-9]+)*$' || die "--upstream wants 'NotProton X.Y.Z', got '$upstream'"
fi
+if [ -n "$highest" ]; then
+ is_posint "$highest" || die "--highest-build wants a positive integer, got '$highest'"
+fi
+if [ -n "$named" ]; then
+ is_semver "$named" || die "--named wants X.Y.Z, got '$named'"
+fi
-major=${version%%.*}
-rest=${version#*.}
-minor=${rest%%.*}
-patch=${rest#*.}
-case "$part" in
- major) major=$((major + 1)); minor=0; patch=0 ;;
- minor) minor=$((minor + 1)); patch=0 ;;
- patch) patch=$((patch + 1)) ;;
-esac
-next="$major.$minor.$patch"
-next_build=$((build + 1))
+next=$(semver_next "$part" "$version")
+[ -z "$named" ] || [ "$named" = "$next" ] \
+ || die "a $part bump of $version gives $next, not $named, the release the beta was named after; pick the matching part"
+base_build=$build
+if [ -n "$highest" ] && [ "$highest" -gt "$base_build" ]; then
+ base_build=$highest
+fi
+next_build=$((base_build + 1))
next_based=${upstream:-$based}
-sed -i '' \
+# Written through a temporary file so the same edit works with BSD and GNU sed.
+tmp=$header.tmp.$$
+trap 'rm -f "$tmp"' EXIT
+sed \
-e "s/^#define BRIDGEPLAY_VERSION \".*\"$/#define BRIDGEPLAY_VERSION \"$next\"/" \
-e "s/^#define BRIDGEPLAY_BUILD [0-9][0-9]*$/#define BRIDGEPLAY_BUILD $next_build/" \
-e "s/^#define NOTPROTON_VERSION \".*\"$/#define NOTPROTON_VERSION \"$next_based\"/" \
- "$header"
+ "$header" >"$tmp"
+cat "$tmp" >"$header"
echo "==> Bridgeplay $version ($build) -> $next ($next_build), based on NotProton $next_based"
diff --git a/scripts/stamp-beta.sh b/scripts/stamp-beta.sh
new file mode 100755
index 0000000..e7e990f
--- /dev/null
+++ b/scripts/stamp-beta.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+# Stamp a beta build's label, build number and channel at build time, committing nothing.
+#
+# BRIDGEPLAY_BETA=N BRIDGEPLAY_BETA_BUILD=B [BRIDGEPLAY_BETA_PLANNED=X.Y.Z] make app
+# scripts/stamp-beta.sh check | print | apply Info.plist
+#
+# dylib/version.h always holds the plain X.Y.Z, on main and on beta. A beta build is named
+# after the release it leads to: label X.Y.Z-beta.N with X.Y.Z the planned release, which
+# defaults to the next patch of the committed version; name a milestone minor to override it.
+# It must be above the committed version. The build number B is "the highest build ever
+# published, stable or beta, plus one", so it is higher than every build before it; it must be
+# above the committed build. N is a positive integer. Anything else fails the build.
+#
+# check validate dylib/version.h and the BRIDGEPLAY_BETA* variables; changes nothing
+# print the stamped label, build and channel as version=, build= and channel= lines
+# apply write them into an Info.plist; a normal build (no BRIDGEPLAY_BETA) changes nothing
+#
+# A normal build keeps the committed version, the committed build and the stable channel
+# that app/Info.plist already carries. See docs/RELEASING.md.
+
+set -eu
+
+repo=$(cd "$(dirname "$0")/.." && pwd)
+header=$repo/dylib/version.h
+# shellcheck source=/dev/null
+. "$repo/scripts/version-lib.sh"
+
+die() { echo "==> $*" >&2; exit 1; }
+
+mode=${1:-}
+case "$mode" in
+ check|print) [ $# -eq 1 ] || die "usage: stamp-beta.sh check | print | apply Info.plist" ;;
+ apply) [ $# -eq 2 ] || die "usage: stamp-beta.sh apply Info.plist" ;;
+ *) die "usage: stamp-beta.sh check | print | apply Info.plist" ;;
+esac
+
+committed=$(header_string "$header" BRIDGEPLAY_VERSION)
+committed_build=$(header_number "$header" BRIDGEPLAY_BUILD)
+is_semver "$committed" || die "BRIDGEPLAY_VERSION '$committed' in $header is not X.Y.Z; a beta label is stamped at build time, never committed"
+is_posint "$committed_build" || die "no numeric BRIDGEPLAY_BUILD in $header"
+
+version=$committed
+build=$committed_build
+channel=stable
+
+# BRIDGEPLAY_BETA set at all, even empty, asks for a beta, so a malformed number fails
+# rather than quietly building a stable app.
+if [ -n "${BRIDGEPLAY_BETA+set}" ]; then
+ is_posint "$BRIDGEPLAY_BETA" || die "BRIDGEPLAY_BETA '$BRIDGEPLAY_BETA' is not a positive integer (the beta number N)"
+ beta_build=${BRIDGEPLAY_BETA_BUILD:-}
+ is_posint "$beta_build" || die "BRIDGEPLAY_BETA_BUILD '$beta_build' is not a positive integer (the highest published build plus one)"
+ [ "$beta_build" -gt "$committed_build" ] \
+ || die "BRIDGEPLAY_BETA_BUILD $beta_build is not above the committed build $committed_build, so the beta would not order above the stable it branched from"
+ planned=${BRIDGEPLAY_BETA_PLANNED:-}
+ if [ -z "$planned" ]; then
+ planned=$(semver_next patch "$committed")
+ else
+ is_semver "$planned" || die "BRIDGEPLAY_BETA_PLANNED '$planned' is not X.Y.Z"
+ semver_gt "$planned" "$committed" \
+ || die "BRIDGEPLAY_BETA_PLANNED $planned is not above the committed version $committed"
+ fi
+ version=$planned-beta.$BRIDGEPLAY_BETA
+ build=$beta_build
+ channel=beta
+elif [ -n "${BRIDGEPLAY_BETA_BUILD:-}" ] || [ -n "${BRIDGEPLAY_BETA_PLANNED:-}" ]; then
+ die "BRIDGEPLAY_BETA_BUILD or BRIDGEPLAY_BETA_PLANNED is set without BRIDGEPLAY_BETA (the beta number N)"
+fi
+
+case "$mode" in
+ check) ;;
+ print)
+ echo "version=$version"
+ echo "build=$build"
+ echo "channel=$channel"
+ ;;
+ apply)
+ [ "$channel" = beta ] || exit 0
+ plist=$2
+ [ -f "$plist" ] || die "$plist does not exist"
+ "${PLISTBUDDY:-/usr/libexec/PlistBuddy}" \
+ -c "Set :CFBundleShortVersionString $version" \
+ -c "Set :CFBundleVersion $build" \
+ -c "Set :BridgeplayChannel $channel" \
+ "$plist"
+ echo "==> Stamped beta $version (build $build) into $plist"
+ ;;
+esac
diff --git a/scripts/sync-upstream.sh b/scripts/sync-upstream.sh
index 0b213bf..012a3a3 100755
--- a/scripts/sync-upstream.sh
+++ b/scripts/sync-upstream.sh
@@ -9,7 +9,8 @@
# rebased or taken with -X theirs, so local commits stay as they are. The only conflict
# resolved automatically is dylib/version.h: Bridgeplay's lines are kept and
# NOTPROTON_VERSION takes upstream's value. Any other conflict aborts that merge and
-# leaves the tree untouched. After a merge, scripts/bump-version.sh patch is committed.
+# leaves the tree untouched. After a merge on main, scripts/bump-version.sh patch is committed;
+# on beta (BRIDGEPLAY_BETA_BRANCH, default beta) no version change is committed.
set -eu
@@ -79,14 +80,21 @@ for entry in $pending; do
exit 1
fi
git checkout -q --ours dylib/version.h
- sed -i '' "s/^#define NOTPROTON_VERSION \".*\"/#define NOTPROTON_VERSION \"$theirs\"/" dylib/version.h
+ sed "s/^#define NOTPROTON_VERSION \".*\"/#define NOTPROTON_VERSION \"$theirs\"/" dylib/version.h >dylib/version.h.tmp
+ cat dylib/version.h.tmp >dylib/version.h
+ rm dylib/version.h.tmp
git add dylib/version.h
git commit -q --no-edit
echo "==> kept Bridgeplay's version.h, NotProton $theirs"
done
-# An upstream merge is a patch: versions move slowly, see docs/RELEASING.md.
-if [ "$(product_of <dylib/version.h)" = "$ours_before" ]; then
+# On beta nothing is bumped: the committed version stays X.Y.Z there, and the stable that
+# ships the beta takes the bump. On main (a security or crash hotfix from upstream) an upstream
+# merge is a patch: versions move slowly, see docs/RELEASING.md.
+branch=$(git symbolic-ref -q --short HEAD || true)
+if [ "$branch" = "${BRIDGEPLAY_BETA_BRANCH:-beta}" ]; then
+ echo "==> on $branch: no version bump committed; the stable that ships this beta gets it"
+elif [ "$(product_of <dylib/version.h)" = "$ours_before" ]; then
scripts/bump-version.sh patch
git commit -q -m "chore(release): bump Bridgeplay to $(product_of <dylib/version.h) after upstream merge" dylib/version.h
fi
diff --git a/scripts/version-lib.sh b/scripts/version-lib.sh
new file mode 100644
index 0000000..0d40570
--- /dev/null
+++ b/scripts/version-lib.sh
@@ -0,0 +1,72 @@
+# shellcheck shell=sh
+# Version helpers shared by bump-version.sh, stamp-beta.sh and sync-upstream.sh. Source it, don't run it.
+#
+# The committed version in dylib/version.h is always a plain X.Y.Z. Only a beta build carries
+# a label like X.Y.Z-beta.N, stamped in at build time by stamp-beta.sh and never committed.
+
+# A positive integer of up to nine digits, no sign and no leading zero.
+is_posint() {
+ case $1 in
+ ''|*[!0-9]*|0*) return 1 ;;
+ esac
+ [ "${#1}" -le 9 ]
+}
+
+# X.Y.Z with plain numeric parts. A beta label, a v prefix or a fourth part is not one.
+is_semver() {
+ case $1 in
+ ''|*[!0-9.]*|.*|*.|*..*|*.*.*.*) return 1 ;;
+ *.*.*) ;;
+ *) return 1 ;;
+ esac
+ _old_ifs=$IFS
+ IFS=.
+ # shellcheck disable=SC2086 # only digits and dots got this far
+ set -- $1
+ IFS=$_old_ifs
+ for _part in "$@"; do
+ case $_part in
+ 0) ;;
+ 0*) return 1 ;;
+ esac
+ [ "${#_part}" -le 9 ] || return 1
+ done
+}
+
+# semver_gt A B: A is above B. Both must pass is_semver.
+semver_gt() {
+ _old_ifs=$IFS
+ IFS=.
+ # shellcheck disable=SC2086 # only digits and dots, checked by the caller
+ set -- $1 $2
+ IFS=$_old_ifs
+ [ "$1" -gt "$4" ] && return 0
+ [ "$1" -lt "$4" ] && return 1
+ [ "$2" -gt "$5" ] && return 0
+ [ "$2" -lt "$5" ] && return 1
+ [ "$3" -gt "$6" ]
+}
+
+# semver_next PART VERSION: the next patch, minor or major of VERSION.
+semver_next() {
+ _old_ifs=$IFS
+ IFS=.
+ # shellcheck disable=SC2086 # only digits and dots, checked by the caller
+ set -- $2 "$1"
+ IFS=$_old_ifs
+ case $4 in
+ major) echo "$(($1 + 1)).0.0" ;;
+ minor) echo "$1.$(($2 + 1)).0" ;;
+ patch) echo "$1.$2.$(($3 + 1))" ;;
+ *) return 1 ;;
+ esac
+}
+
+# header_string FILE NAME, header_number FILE NAME: a #define from dylib/version.h.
+header_string() {
+ sed -n 's/^#define '"$2"' "\(.*\)"$/\1/p' "$1"
+}
+
+header_number() {
+ sed -n 's/^#define '"$2"' \([0-9][0-9]*\)$/\1/p' "$1"
+}