mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 02:29:55 +02:00
feat(release): automate derived store versions
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# Application versioning
|
||||
|
||||
`version.properties` at the repository root is the single source of truth for
|
||||
the VniDrop product version and persistent store counters. Platform projects
|
||||
and release workflows use the version resolver rather than accepting
|
||||
independent version overrides.
|
||||
the VniDrop product version and the permanent Windows version epoch. Platform
|
||||
projects and release workflows derive their versions from it rather than
|
||||
accepting independent release counters.
|
||||
|
||||
Keep it as plain `KEY=VALUE` assignments: the same file is parsed by shell,
|
||||
PowerShell, Gradle, and Rust. Xcode receives resolver-generated xcconfig files.
|
||||
@@ -15,7 +15,7 @@ the patch component (`0.2.1`). Release channels belong in
|
||||
|
||||
| Platform | Product version | Platform build/package version |
|
||||
| --- | --- | --- |
|
||||
| Android | `PRODUCT_VERSION` | `ANDROID_VERSION_CODE` |
|
||||
| Android | `PRODUCT_VERSION` | Derived monotonic integer |
|
||||
| Apple Store | `PRODUCT_VERSION` | Derived UTC `YYYYMMDD.HHMM.SS` |
|
||||
| Direct macOS | `PRODUCT_VERSION` | Independently derived UTC `YYYYMMDD.HHMM.SS` |
|
||||
| Linux | `PRODUCT_VERSION` | Native package revision |
|
||||
@@ -32,12 +32,23 @@ the Store. Its version is:
|
||||
With epoch `1`, product `0.2.0` maps to MSIX `1.2.0.0`, while product `1.0.0`
|
||||
maps to `2.0.0.0`. Do not change the epoch after publishing.
|
||||
|
||||
Every Android upload must increment `ANDROID_VERSION_CODE`. Apple build numbers
|
||||
are derived at build time by `apple-store-build` and `apple-direct-build`; they
|
||||
are kept as separate resolver outputs so App Store and Sparkle releases do not
|
||||
consume each other's cadence. Every changed Windows Store package must
|
||||
increment the product version because the Store-reserved fourth component
|
||||
cannot carry a rebuild number.
|
||||
Android derives its version code as:
|
||||
|
||||
```text
|
||||
product major * 1,000,000 + product minor * 1,000 + product patch
|
||||
```
|
||||
|
||||
For example, `0.2.0` maps to Android code `2000`, `0.2.1` to `2001`, and
|
||||
`1.0.0` to `1000000`. To keep that mapping unique and within store limits,
|
||||
the product major may not exceed `2099`, and minor and patch may not exceed
|
||||
`999`. A rejected store build must use a new patch version rather than
|
||||
rebuilding a previously uploaded product version.
|
||||
|
||||
Apple build numbers are derived at build time by `apple-store-build` and
|
||||
`apple-direct-build`; they are kept as separate resolver outputs so App Store
|
||||
and Sparkle releases do not consume each other's cadence. Every changed Windows
|
||||
Store package must increment the product version because the Store-reserved
|
||||
fourth component cannot carry a rebuild number.
|
||||
|
||||
Apple projects read generated build settings rather than `version.properties`
|
||||
directly:
|
||||
@@ -50,7 +61,14 @@ The generated files under `apple/Generated/` are intentionally ignored.
|
||||
`VNIDROP_BUILD_TIME_UTC=YYYYMMDDHHMMSS` provides a deterministic clock for
|
||||
tests; distribution builds normally use the current UTC time.
|
||||
|
||||
Before releasing:
|
||||
Prepare the next release by changing only the product version:
|
||||
|
||||
```bash
|
||||
make prepare-release RELEASE_VERSION=0.2.1
|
||||
```
|
||||
|
||||
The command refuses non-increasing versions, updates `PRODUCT_VERSION`, and
|
||||
prints the derived Android and Microsoft Store versions. Then verify:
|
||||
|
||||
```bash
|
||||
make check-version
|
||||
|
||||
53
packaging/version/prepare-release.sh
Executable file
53
packaging/version/prepare-release.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
repo_root="$(cd "$script_dir/../.." && pwd)"
|
||||
resolver="$script_dir/resolve-version.sh"
|
||||
version_file="${VNIDROP_VERSION_FILE:-$repo_root/version.properties}"
|
||||
next_version="${1:-}"
|
||||
|
||||
fail() {
|
||||
printf '%s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ -n $next_version ]] ||
|
||||
fail "Usage: $0 MAJOR.MINOR.PATCH"
|
||||
[[ -f $version_file ]] ||
|
||||
fail "Version file not found: $version_file"
|
||||
[[ $(grep -c '^PRODUCT_VERSION=' "$version_file") == 1 ]] ||
|
||||
fail "Expected exactly one PRODUCT_VERSION entry in $version_file"
|
||||
|
||||
current_version="$(
|
||||
VNIDROP_VERSION_FILE="$version_file" "$resolver" product
|
||||
)"
|
||||
current_android_code="$(
|
||||
VNIDROP_VERSION_FILE="$version_file" "$resolver" android-code
|
||||
)"
|
||||
temporary="$(mktemp "$(dirname "$version_file")/.version.properties.XXXXXX")"
|
||||
trap 'rm -f "$temporary"' EXIT
|
||||
|
||||
sed "s/^PRODUCT_VERSION=.*/PRODUCT_VERSION=$next_version/" \
|
||||
"$version_file" > "$temporary"
|
||||
|
||||
next_android_code="$(
|
||||
VNIDROP_VERSION_FILE="$temporary" "$resolver" android-code
|
||||
)"
|
||||
next_windows_package="$(
|
||||
VNIDROP_VERSION_FILE="$temporary" "$resolver" windows-package
|
||||
)"
|
||||
VNIDROP_VERSION_FILE="$temporary" "$resolver" verify >/dev/null
|
||||
|
||||
(( next_android_code > current_android_code )) ||
|
||||
fail "New version must be greater than $current_version"
|
||||
|
||||
chmod 644 "$temporary"
|
||||
mv "$temporary" "$version_file"
|
||||
trap - EXIT
|
||||
|
||||
printf 'Prepared VniDrop %s\n' "$next_version"
|
||||
printf ' Android version code: %s\n' "$next_android_code"
|
||||
printf ' Microsoft Store package: %s\n' "$next_windows_package"
|
||||
printf 'Next: make check-version\n'
|
||||
@@ -47,7 +47,6 @@ function Convert-CanonicalInteger {
|
||||
|
||||
$productVersion = Read-VersionProperty "PRODUCT_VERSION"
|
||||
$releaseChannel = Read-VersionProperty "RELEASE_CHANNEL"
|
||||
$androidVersionCodeText = Read-VersionProperty "ANDROID_VERSION_CODE"
|
||||
$windowsVersionEpochText = Read-VersionProperty "WINDOWS_VERSION_EPOCH"
|
||||
$buildTimeUtc = $env:VNIDROP_BUILD_TIME_UTC
|
||||
if ([string]::IsNullOrWhiteSpace($buildTimeUtc)) {
|
||||
@@ -78,13 +77,16 @@ if ($productVersion -notmatch "^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*
|
||||
throw "PRODUCT_VERSION must use canonical MAJOR.MINOR.PATCH integers"
|
||||
}
|
||||
$productParts = $productVersion.Split(".")
|
||||
$productMajor = Convert-CanonicalInteger "PRODUCT_VERSION major" $productParts[0] 0 65534
|
||||
$null = Convert-CanonicalInteger "PRODUCT_VERSION minor" $productParts[1] 0 65535
|
||||
$null = Convert-CanonicalInteger "PRODUCT_VERSION patch" $productParts[2] 0 65535
|
||||
$productMajor = Convert-CanonicalInteger "PRODUCT_VERSION major" $productParts[0] 0 2099
|
||||
$productMinor = Convert-CanonicalInteger "PRODUCT_VERSION minor" $productParts[1] 0 999
|
||||
$productPatch = Convert-CanonicalInteger "PRODUCT_VERSION patch" $productParts[2] 0 999
|
||||
if ($releaseChannel -notmatch "^[a-z][a-z0-9-]*$") {
|
||||
throw "RELEASE_CHANNEL contains unsupported characters"
|
||||
}
|
||||
$androidVersionCode = Convert-CanonicalInteger "ANDROID_VERSION_CODE" $androidVersionCodeText 1 2100000000
|
||||
$androidVersionCode = $productMajor * 1000000L + $productMinor * 1000L + $productPatch
|
||||
if ($androidVersionCode -lt 1 -or $androidVersionCode -gt 2100000000L) {
|
||||
throw "Derived Android version code must be between 1 and 2100000000"
|
||||
}
|
||||
$windowsVersionEpoch = Convert-CanonicalInteger "WINDOWS_VERSION_EPOCH" $windowsVersionEpochText 1 65535
|
||||
$windowsMajor = $productMajor + $windowsVersionEpoch
|
||||
if ($windowsMajor -gt 65535) {
|
||||
|
||||
@@ -34,23 +34,29 @@ validate_canonical_integer() {
|
||||
|
||||
product_version="$(read_property PRODUCT_VERSION)"
|
||||
release_channel="$(read_property RELEASE_CHANNEL)"
|
||||
android_version_code="$(read_property ANDROID_VERSION_CODE)"
|
||||
windows_version_epoch="$(read_property WINDOWS_VERSION_EPOCH)"
|
||||
build_time_utc="${VNIDROP_BUILD_TIME_UTC:-$(date -u +%Y%m%d%H%M%S)}"
|
||||
|
||||
[[ $product_version =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] ||
|
||||
fail "PRODUCT_VERSION must use canonical MAJOR.MINOR.PATCH integers"
|
||||
IFS=. read -r product_major product_minor product_patch <<< "$product_version"
|
||||
validate_canonical_integer "PRODUCT_VERSION major" "$product_major" 0 65534
|
||||
validate_canonical_integer "PRODUCT_VERSION minor" "$product_minor" 0 65535
|
||||
validate_canonical_integer "PRODUCT_VERSION patch" "$product_patch" 0 65535
|
||||
validate_canonical_integer "PRODUCT_VERSION major" "$product_major" 0 2099
|
||||
validate_canonical_integer "PRODUCT_VERSION minor" "$product_minor" 0 999
|
||||
validate_canonical_integer "PRODUCT_VERSION patch" "$product_patch" 0 999
|
||||
[[ $release_channel =~ ^[a-z][a-z0-9-]*$ ]] ||
|
||||
fail "RELEASE_CHANNEL must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
|
||||
validate_canonical_integer "ANDROID_VERSION_CODE" "$android_version_code" 1 2100000000
|
||||
validate_canonical_integer "WINDOWS_VERSION_EPOCH" "$windows_version_epoch" 1 65535
|
||||
[[ $build_time_utc =~ ^[0-9]{14}$ ]] ||
|
||||
fail "VNIDROP_BUILD_TIME_UTC must use YYYYMMDDHHMMSS"
|
||||
|
||||
android_version_code=$((
|
||||
(10#$product_major * 1000000) +
|
||||
(10#$product_minor * 1000) +
|
||||
10#$product_patch
|
||||
))
|
||||
(( android_version_code >= 1 && android_version_code <= 2100000000 )) ||
|
||||
fail "Derived Android version code must be between 1 and 2100000000"
|
||||
|
||||
build_month="${build_time_utc:4:2}"
|
||||
build_day="${build_time_utc:6:2}"
|
||||
build_hour="${build_time_utc:8:2}"
|
||||
|
||||
@@ -4,6 +4,7 @@ set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
resolver="$script_dir/resolve-version.sh"
|
||||
prepare_release="$script_dir/prepare-release.sh"
|
||||
scratch="$(mktemp -d)"
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
|
||||
@@ -11,8 +12,7 @@ write_version() {
|
||||
printf '%s\n' \
|
||||
"PRODUCT_VERSION=$1" \
|
||||
"RELEASE_CHANNEL=$2" \
|
||||
"ANDROID_VERSION_CODE=$3" \
|
||||
"WINDOWS_VERSION_EPOCH=$4" \
|
||||
"WINDOWS_VERSION_EPOCH=$3" \
|
||||
> "$scratch/version.properties"
|
||||
}
|
||||
|
||||
@@ -29,32 +29,42 @@ expect_failure() {
|
||||
|
||||
export VNIDROP_BUILD_TIME_UTC=20260728143217
|
||||
|
||||
write_version 0.2.0 beta 2 1
|
||||
write_version 0.2.0 beta 1
|
||||
[[ $(resolve product) == 0.2.0 ]]
|
||||
[[ $(resolve android-code) == 2 ]]
|
||||
[[ $(resolve android-code) == 2000 ]]
|
||||
[[ $(resolve apple-store-build) == 20260728.1432.17 ]]
|
||||
[[ $(resolve apple-direct-build) == 20260728.1432.17 ]]
|
||||
[[ $(resolve windows-package) == 1.2.0.0 ]]
|
||||
resolve verify-tag v0.2.0
|
||||
expect_failure resolve verify-tag v1.0.0
|
||||
|
||||
write_version 1.0.0 stable 42 1
|
||||
write_version 1.0.0 stable 1
|
||||
[[ $(resolve android-code) == 1000000 ]]
|
||||
[[ $(resolve windows-package) == 2.0.0.0 ]]
|
||||
|
||||
write_version 01.0.0 beta 2 1
|
||||
write_version 2099.999.999 stable 1
|
||||
[[ $(resolve android-code) == 2099999999 ]]
|
||||
|
||||
write_version 01.0.0 beta 1
|
||||
expect_failure resolve verify
|
||||
|
||||
write_version 0.2.0 beta 0 1
|
||||
write_version 0.0.0 beta 1
|
||||
expect_failure resolve verify
|
||||
|
||||
write_version 65535.0.0 stable 2 1
|
||||
write_version 2100.0.0 stable 1
|
||||
expect_failure resolve verify
|
||||
|
||||
write_version 0.1000.0 stable 1
|
||||
expect_failure resolve verify
|
||||
|
||||
write_version 0.0.1000 stable 1
|
||||
expect_failure resolve verify
|
||||
|
||||
VNIDROP_BUILD_TIME_UTC=20260728146000 expect_failure resolve verify
|
||||
VNIDROP_BUILD_TIME_UTC=2026-07-28 expect_failure resolve verify
|
||||
VNIDROP_BUILD_TIME_UTC=20260229080000 expect_failure resolve verify
|
||||
|
||||
write_version 0.2.0 beta 2 1
|
||||
write_version 0.2.0 beta 1
|
||||
config_dir="$scratch/xcconfig"
|
||||
VNIDROP_APPLE_XCCONFIG_DIR="$config_dir" \
|
||||
"$script_dir/generate-apple-xcconfig.sh" all
|
||||
@@ -64,4 +74,14 @@ grep -Fx "CURRENT_PROJECT_VERSION = 20260728.1432.17" \
|
||||
grep -Fx "CURRENT_PROJECT_VERSION = 20260728.1432.17" \
|
||||
"$config_dir/DirectVersion.xcconfig" >/dev/null
|
||||
|
||||
VNIDROP_VERSION_FILE="$scratch/version.properties" \
|
||||
"$prepare_release" 0.2.1 >/dev/null
|
||||
[[ $(resolve product) == 0.2.1 ]]
|
||||
[[ $(resolve android-code) == 2001 ]]
|
||||
[[ $(resolve windows-package) == 1.2.1.0 ]]
|
||||
expect_failure env VNIDROP_VERSION_FILE="$scratch/version.properties" \
|
||||
"$prepare_release" 0.2.1
|
||||
expect_failure env VNIDROP_VERSION_FILE="$scratch/version.properties" \
|
||||
"$prepare_release" 0.1.999
|
||||
|
||||
printf 'Version resolver tests passed.\n'
|
||||
|
||||
Reference in New Issue
Block a user