From 65b743c8a537297dad4197d9037f1ac78aaacb00 Mon Sep 17 00:00:00 2001 From: Illia Achour Date: Fri, 20 Nov 2026 23:08:42 -0500 Subject: [PATCH 1/2] Ask Gradle for VERSION_NAME in CI, and take the newest released Xcode CI read VERSION_NAME from gradle.properties with sed, which matches only VERSION_NAME= at the start of a line. VERSION_NAME = 2.0.1 and VERSION_NAME: 2.0.1 are the same property to Gradle, but sed reads nothing from them: the tag check would fail with an empty version, a hand-run snapshot would publish -SNAPSHOT, and the API removal check would lose the major-bump exemption. A -PVERSION_NAME override was invisible to it too. A root printVersionName task prints the property as Gradle resolves it, which is what every library module publishes, and the workflows and scripts/check-api-removals.sh read it from there. The macOS job runs the removal check after Java and Gradle are set up, since the check now runs Gradle. Both macOS jobs took the last Xcode_*.app by name. The runner images give a beta or a release candidate release-looking symlinks (Xcode_26.1.app pointing at Xcode_26.1_beta_3.app), so while one is installed CI builds and publishes with it. scripts/newest-xcode.sh skips symlinks, betas and release candidates, and compares the CFBundleShortVersionString in each app's Info.plist. --- .github/workflows/build.yml | 20 +++++++++------- .github/workflows/publish.yml | 12 ++++++---- build.gradle.kts | 10 ++++++++ scripts/check-api-removals.sh | 7 +++++- scripts/newest-xcode.sh | 45 +++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 14 deletions(-) create mode 100755 scripts/newest-xcode.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f61bf57c..f56b68fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,23 +74,25 @@ jobs: with: # The API removal check reads the dumps at the last release tag. fetch-depth: 0 - # publish.yml runs this on macOS, whose awk, sort and comm are BSD's. Running it here - # too means a difference shows on a pull request rather than first on a release tag. - - name: Check nothing the last release published was removed - run: bash scripts/check-api-removals.sh - uses: actions/setup-java@v6 with: distribution: 'zulu' java-version: '21' - uses: gradle/actions/setup-gradle@v6 + # publish.yml runs this on macOS, whose awk, sort and comm are BSD's. Running it here + # too means a difference shows on a pull request rather than first on a release tag. + # It asks Gradle for VERSION_NAME, so it runs once Java and Gradle are set up. + - name: Check nothing the last release published was removed + run: bash scripts/check-api-removals.sh # macos-15 defaults to Xcode 16.4, whose iOS SDK predates UIViewLayoutRegion — a # symbol Compose Multiplatform's ui-uikit references. Kotlin/Native static caches # link whole modules rather than tree-shaking, so any iOS *test executable* fails to # link without a 26.x SDK (the static framework link survives because an archive - # never resolves external symbols). The image ships several Xcodes; take the newest. + # never resolves external symbols). The image ships several Xcodes; take the newest + # release, by the version in each app's Info.plist, skipping betas and release candidates. - name: Select the newest installed Xcode run: | - XCODE=$(ls -d /Applications/Xcode_*.app | sort -V | tail -1) + XCODE="$(bash scripts/newest-xcode.sh)" echo "Using $XCODE" sudo xcode-select -s "$XCODE/Contents/Developer" xcodebuild -version @@ -106,7 +108,7 @@ jobs: run: ./gradlew publishToMavenLocal - name: Check each module published its six targets run: | - VERSION="$(sed -n 's/^VERSION_NAME=//p' gradle.properties)" + VERSION="$(./gradlew -q printVersionName)" for module in color color-compose colorpicker-foundation colorpicker-material3; do for suffix in "" -android -jvm -wasm-js -iosarm64 -iossimulatorarm64; do pom="$HOME/.m2/repository/codes/side/$module$suffix/$VERSION/$module$suffix-$VERSION.pom" @@ -120,4 +122,6 @@ jobs: # depends on colorpicker-material3 alone, as an app does, and links a dynamic iOS framework against what # was just published, which resolves every native symbol the libraries need. - name: Link an app against the published artifacts - run: ./gradlew -p tools/consumer compileKotlinJvm linkDebugFrameworkIosSimulatorArm64 -PpickerVersion="$(sed -n 's/^VERSION_NAME=//p' gradle.properties)" + run: | + VERSION="$(./gradlew -q printVersionName)" + ./gradlew -p tools/consumer compileKotlinJvm linkDebugFrameworkIosSimulatorArm64 -PpickerVersion="$VERSION" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 477f5092..4bc1ee39 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -55,10 +55,11 @@ jobs: # symbol Compose Multiplatform's ui-uikit references. Kotlin/Native static caches # link whole modules rather than tree-shaking, so any iOS *test executable* fails to # link without a 26.x SDK (the static framework link survives because an archive - # never resolves external symbols). The image ships several Xcodes; take the newest. + # never resolves external symbols). The image ships several Xcodes; take the newest + # release, by the version in each app's Info.plist, skipping betas and release candidates. - name: Select the newest installed Xcode run: | - XCODE=$(ls -d /Applications/Xcode_*.app | sort -V | tail -1) + XCODE="$(bash scripts/newest-xcode.sh)" echo "Using $XCODE" sudo xcode-select -s "$XCODE/Contents/Developer" xcodebuild -version @@ -66,12 +67,13 @@ jobs: # The version lives in gradle.properties, not in the tag. Publishing the wrong one # is unrecoverable because Maven Central is immutable, so refuse to start on a - # mismatch rather than redeploying an already-released coordinate. + # mismatch rather than redeploying an already-released coordinate. Gradle reads the + # version, so this compares the tag with what the publication will carry. - name: Check the tag matches VERSION_NAME if: startsWith(github.ref, 'refs/tags/v') run: | TAG_VERSION="${GITHUB_REF_NAME#v}" - PROJECT_VERSION="$(sed -n 's/^VERSION_NAME=//p' gradle.properties)" + PROJECT_VERSION="$(./gradlew -q printVersionName)" echo "tag=$TAG_VERSION gradle.properties=$PROJECT_VERSION" if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then echo "::error::Tag $GITHUB_REF_NAME does not match VERSION_NAME=$PROJECT_VERSION. Bump VERSION_NAME and retag." @@ -98,7 +100,7 @@ jobs: # command line so gradle.properties is never edited just to test. - name: Publish to Maven Central run: | - VERSION="$(sed -n 's/^VERSION_NAME=//p' gradle.properties)" + VERSION="$(./gradlew -q printVersionName --no-configuration-cache)" if [ "${{ inputs.snapshot }}" = "true" ]; then # VERSION_NAME may be a snapshot already; it must not publish as -SNAPSHOT-SNAPSHOT. VERSION="${VERSION%-SNAPSHOT}" diff --git a/build.gradle.kts b/build.gradle.kts index d9a3bd22..bfe956e9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,3 +28,13 @@ apiValidation { enabled = true } } + +// CI and scripts/check-api-removals.sh ask Gradle for the version rather than reading gradle.properties themselves, +// so they get the one the modules publish: the file read as Gradle reads it, or a -PVERSION_NAME override. +// They run `./gradlew -q printVersionName` with -q first: the wrapper sees -q only before the first word that isn't an +// option (a task name, or an option's value such as -I's), and without it writes its download progress to stdout too. +tasks.register("printVersionName") { + description = "Prints VERSION_NAME, the version every library module publishes." + val versionName = providers.gradleProperty("VERSION_NAME") + doLast { println(versionName.get()) } +} diff --git a/scripts/check-api-removals.sh b/scripts/check-api-removals.sh index bb65adf5..45d041b1 100755 --- a/scripts/check-api-removals.sh +++ b/scripts/check-api-removals.sh @@ -30,7 +30,12 @@ git rev-parse --verify --quiet "$ref^{commit}" > /dev/null || { echo "Comparing the API dumps against $ref." # Only a vX.Y.Z tag says which major version it was; any other ref is compared without the exemption. -current_major="$(sed -n 's/^VERSION_NAME=\([0-9]*\).*/\1/p' gradle.properties)" +# Gradle reads VERSION_NAME as the build that publishes it does; its major is the digits it starts with. +version_name="$(./gradlew -q printVersionName)" || { + echo "::error::Gradle could not print VERSION_NAME." >&2 + exit 2 +} +current_major="${version_name%%[!0-9]*}" ref_version="${ref#v}" ref_major="${ref_version%%.*}" if [[ "$ref_major" =~ ^[0-9]+$ ]] && [ "$current_major" -gt "$ref_major" ]; then diff --git a/scripts/newest-xcode.sh b/scripts/newest-xcode.sh new file mode 100755 index 00000000..28639f99 --- /dev/null +++ b/scripts/newest-xcode.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Prints the path of the newest released Xcode in /Applications, or in the directory given. +# +# An app's version is the CFBundleShortVersionString in its Info.plist, compared number by number, so 26.10 is newer +# than 26.9 whatever the app is called. A beta or a release candidate is skipped: the runner images name one +# Xcode_26.1_beta_3.app or Xcode_26.3_Release_Candidate.app, and a beta's LicenseInfo.plist says Beta too. Symlinks +# are skipped, so the release-looking names the images give a beta (Xcode_26.1.app) are not taken for a release; each +# release is listed under its own name. +# +# Usage: scripts/newest-xcode.sh [dir] +set -euo pipefail + +dir="${1:-/Applications}" + +plist_value() { + /usr/libexec/PlistBuddy -c "Print :$1" "$2" 2> /dev/null +} + +lowercase() { + printf '%s' "$1" | tr '[:upper:]' '[:lower:]' +} + +tab="$(printf '\t')" +newest="$( + for app in "$dir"/Xcode*.app; do + if [ ! -d "$app" ] || [ -L "$app" ]; then + continue + fi + case "$(lowercase "$(basename "$app")")" in + *beta* | *release_candidate*) continue ;; + esac + case "$(lowercase "$(plist_value licenseType "$app/Contents/Resources/LicenseInfo.plist" || true)")" in + *beta*) continue ;; + esac + version="$(plist_value CFBundleShortVersionString "$app/Contents/Info.plist" || true)" + if [[ "$version" =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?$ ]]; then + printf '%s\t%s\t%s\t%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[3]:-0}" "${BASH_REMATCH[5]:-0}" "$app" + fi + done | sort -t "$tab" -k1,1n -k2,2n -k3,3n | tail -n 1 | cut -f 4 +)" +if [ -z "$newest" ]; then + echo "::error::No released Xcode with a version in its Info.plist is in $dir." >&2 + exit 1 +fi +echo "$newest" From 4fe28ccf4a34e397dfaa796ac498776f367e1ff6 Mon Sep 17 00:00:00 2001 From: Illia Achour Date: Fri, 20 Nov 2026 23:21:08 -0500 Subject: [PATCH 2/2] Keep newest-xcode.sh's loop out of a command substitution macOS runs it with bash 3.2, which misparses a case pattern's closing parenthesis inside $(...) and stopped the build-ios job with a syntax error. The loop is a function now, and the substitution only calls it. --- scripts/newest-xcode.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/newest-xcode.sh b/scripts/newest-xcode.sh index 28639f99..2cda242c 100755 --- a/scripts/newest-xcode.sh +++ b/scripts/newest-xcode.sh @@ -20,8 +20,10 @@ lowercase() { printf '%s' "$1" | tr '[:upper:]' '[:lower:]' } -tab="$(printf '\t')" -newest="$( +# One line per released Xcode: its major, minor and patch, then its path, tab-separated. The loop is a function, not +# written inside $(...): macOS's bash 3.2 misparses a case pattern's ) there. +releases() { + local app version for app in "$dir"/Xcode*.app; do if [ ! -d "$app" ] || [ -L "$app" ]; then continue @@ -36,8 +38,11 @@ newest="$( if [[ "$version" =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?$ ]]; then printf '%s\t%s\t%s\t%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[3]:-0}" "${BASH_REMATCH[5]:-0}" "$app" fi - done | sort -t "$tab" -k1,1n -k2,2n -k3,3n | tail -n 1 | cut -f 4 -)" + done +} + +tab="$(printf '\t')" +newest="$(releases | sort -t "$tab" -k1,1n -k2,2n -k3,3n | tail -n 1 | cut -f 4)" if [ -z "$newest" ]; then echo "::error::No released Xcode with a version in its Info.plist is in $dir." >&2 exit 1