Skip to content

Ask Gradle for VERSION_NAME in CI, and take the newest released Xcode - #391

Open
smelfungus wants to merge 2 commits into
masterfrom
fix/version-from-gradle
Open

smelfungus wants to merge 2 commits into
masterfrom
fix/version-from-gradle

Conversation

@smelfungus

@smelfungus smelfungus commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

CI read VERSION_NAME with sed -n 's/^VERSION_NAME=//p' gradle.properties in five places, and the two macOS jobs picked Xcode with ls -d /Applications/Xcode_*.app | sort -V | tail -1. This PR reads both through the tool that owns the value.

VERSION_NAME from Gradle

VERSION_NAME = 2.0.1 and VERSION_NAME: 2.0.1 are the same property to Gradle (Java properties allow spaces and :), but the sed reads nothing from them. With either spelling the tag check would fail with an empty version, a hand-run snapshot would publish -SNAPSHOT, and check-api-removals.sh would lose the major-bump exemption. A -PVERSION_NAME override was invisible to sed too.

  • A root printVersionName task prints providers.gradleProperty("VERSION_NAME"), the provider LibraryConventionPlugin sets every module's version from. It keeps no state, so it works with the configuration cache.
  • build.yml (the POM check and the consumer link), publish.yml (the tag check and the publish step) and scripts/check-api-removals.sh read ./gradlew -q printVersionName. A Gradle failure now stops the step, where an empty sed result went on. The publish step's call passes --no-configuration-cache like the step's other Gradle calls.
  • -q comes first in each call: the wrapper only sees -q before the first word that isn't an option, and without it the wrapper writes its download progress to stdout (seen on the box, below). The build file's comment says so.
  • In build-ios, the removal check moves after setup-java and setup-gradle, since it now runs Gradle. It still runs on macOS before anything is built.
  • check-api-removals.sh takes the major as the digits the version starts with, as its sed did, and exits 2 with an ::error:: when Gradle can't print the version, like its other can't-compare failures.

The newest released Xcode

The runner images give a beta or a release candidate release-looking symlinks: while 26.1 beta 3 was installed, /Applications/Xcode_26.1.app and Xcode_26.1.0.app pointed at Xcode_26.1_beta_3.app (actions/runner-images history of macos-15-arm64-Readme.md). Sorting the names takes the beta, or Xcode_26.3_Release_Candidate_2.app while that was installed (replayed below).

scripts/newest-xcode.sh does what maxim-lobanov/setup-xcode's latest-stable does, in a script so the publish job gains no third-party action: it lists /Applications/Xcode*.app, skips symlinks, skips an app whose name says beta or Release_Candidate or whose Contents/Resources/LicenseInfo.plist licenseType says Beta, reads CFBundleShortVersionString from each Contents/Info.plist with PlistBuddy, and prints the highest, compared number by number with POSIX sort -n keys. With none it exits 1 with an ::error::, where the old line went on to xcode-select -s /Contents/Developer. Both workflows call it; the step's echo "Using $XCODE", xcode-select and xcodebuild -version are unchanged.

Rollout

CI only; nothing published changes. No file format changes: gradle.properties stays as it is.

Tested

Run on the agent box (Linux); the macOS steps run on this PR's own CI.

  • Xcode picker, old line vs new script, on fake /Applications folders built from the runner images' listings (real directories with XML Info.plist and LicenseInfo.plist, the images' symlinks; PlistBuddy stood in for by a plistlib script answering -c 'Print :Key'):

    # Layout Old pick New pick
    1 macos-15 today (16.0 to 26.3, 9 apps, 11 symlinks) Xcode_26.3.0.app, a symlink to 26.3 Xcode_26.3.app (26.3), same Xcode
    2 26.1 beta 3 installed, with its symlinks Xcode_26.1_beta_3.app Xcode_26.0.1.app
    3 26.3 RC 2 installed, with its symlinks Xcode_26.3_Release_Candidate_2.app Xcode_26.2.app
    4 16.4, 16.9, 16.10 and Xcode_16.app (16.0) Xcode_16.10.app Xcode_16.10.app
    5 a beta named like a release (licenseType Beta), Xcode-beta.app, an app with a version that isn't one, Xcode.app 26.4 Xcode_27.0.app (the beta) Xcode_26.4.1.app
    6 only a beta Xcode_27.0_beta.app none: exit 1, ::error::No released Xcode ...

    Every difference is a beta or release candidate left out; with none installed (1, 4) the same Xcode is picked.

  • Workflows: actionlint 1.7.12 with shellcheck 0.9.0 on both files: clean (master: two SC2012 infos, on the ls lines this removes). Every run: block extracted with yq passes bash -n (14 in build.yml, 8 in publish.yml). shellcheck on newest-xcode.sh: clean; on check-api-removals.sh: the same two SC2317 infos as on master.

  • The wrapper and -q: with a fresh Gradle home, ./gradlew --no-daemon -I <init script> -q printVersionName wrote the wrapper's 274-byte Downloading https://services.gradle.org/... progress to stdout; ./gradlew -q --no-daemon -I <init script> printVersionName downloaded and unpacked the same distribution and wrote nothing.

  • This PR's CI (run 44865691490, image macos-15-arm64 20261118.0550): build-android and build-ios pass. build-ios picked /Applications/Xcode_26.3.app (Xcode 26.3, 17C529); master's last run took /Applications/Xcode_26.3.0.app, the symlink to the same Xcode 26.3 17C529. check-api-removals.sh read the version through Gradle on both runners and compared against v2.0.0 as before ("No declaration published in v2.0.0 is missing."). The POM check found all 24 POMs at the version printVersionName printed, and the consumer linked against it, so its stdout was exactly the version on macOS. The first push failed build-ios: macOS's bash 3.2 misparsed the script's case patterns inside $(...); the second commit moves the loop into a function.

  • How the property is read: Gradle loads gradle.properties with java.util.Properties. On copies of the real file, java.util.Properties and the old sed read:

    # Line sed java.util.Properties
    1 VERSION_NAME=2.0.0 (as committed) 2.0.0 2.0.0
    2 VERSION_NAME = 2.0.1 (empty) 2.0.1
    3 VERSION_NAME: 2.0.2 (empty) 2.0.2
    4 VERSION_NAME=2.0.3 (empty) 2.0.3
  • printVersionName on the box for those spellings, a -PVERSION_NAME=9.9.9 override, a missing VERSION_NAME, and the configuration cache stored and reused: not run. The job waited hours for the box's one build slot and was stopped. On this PR's CI, printVersionName read the real file on both runners (removal check, POM check, consumer link).

Not run: the publish workflow (it uploads to Maven Central); anything on macOS by hand. Gradle's daemon-JVM provisioning on a runner (JetBrains 21 from foojay) can't happen on the box, which has the JDK and no downloads; this PR's macOS job is the first run of printVersionName in that state.

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.
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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant