Repository navigation
Fix CI build versioning: real pre-release versions, build numbers, Apple and MSIX versions - #5
Merged
Merged
Conversation
This was referenced Nov 19, 2026
… versions Seven jobs carried identical copies of a "Set Build Version" step that wrote `version: <tag>` or `version: <last tag>-pre-<sha>` into pubspec.yaml with no build number. That caused several problems: - Pre-release builds were all labelled 0.0.0-pre-<sha>. CI checkouts are depth-1 clones. `git fetch --tags` downloads the full history behind every tag, but HEAD's own history stays cut off at depth 1, so `git describe` never reached a tag and fell back to 0.0.0. - iOS/macOS: Flutter strips every non-digit/non-dot from the build name on Apple platforms, so 0.0.6-pre-d217e1d became CFBundleShortVersionString 0.0.62171 (0.0.02171 as actually built). With no build number, CFBundleVersion fell back to the same value. - Android: versionCode was always 1. - Windows MSIX: msix_config.msix_version was never updated, so every MSIX claimed to be 0.0.2.0. - Sentry derives its release from the package version, so Apple pre-release builds reported nonsense releases. - deploy-web, the build served on GitHub Pages, never had a version step at all, so it reported the committed placeholder 0.0.2. - `sed -i -E` on the macOS (BSD sed) runners treats -E as a backup suffix, leaving a stray pubspec.yaml-E behind. Replace them with two CI-provider-neutral scripts, following the pattern of tool/build_web.sh (inputs as arguments, provider specifics kept out), wired up once in a local composite action. They share tool/release_tags.sh, so they agree on what a release tag is (v plus a full semver 2.0.0 version; final means no -pre-release part, even if build metadata contains a hyphen) and on when HEAD's history is cut off. tool/fetch_release_history.sh fetches what the version needs and no more. It lists the remote's release tags and their commits with ls-remote (annotated tags peeled); while HEAD's history is cut off, deepens HEAD by commit id in steps until it contains a final release's commit (so a detached PR merge commit works); then fetches just the tags whose commits are in that history, including in a full clone made without tags. Completeness is judged by whether any commit in HEAD's history is a shallow boundary, not whether the repository is shallow (another ref's shallow tip would otherwise keep it looping), and a deepen that makes no progress is an error. On this repo it fetches 21 of 776 commits and one tag, where the old `fetch --tags` pulled the full history for nothing. tool/build_version.sh works out the version and prints KEY=VALUE lines (WIMSY_VERSION, WIMSY_VERSION_CORE, WIMSY_BUILD_NUMBER, WIMSY_MSIX_VERSION). It takes --tag and --build-number, modifies nothing by default (safe to run locally to see what version a build would get), and only with --write-pubspec rewrites the pubspec's version and msix_version lines, so every tool that reads the pubspec picks the version up without extra flags. It keeps the existing scheme (release X.Y.Z, pre-release <base>-pre-<sha>) and adds: - `version: <display>+<build number>`, giving every platform a build number that increases with each CI run; - a pre-release base that is the nearest release tag unless the highest final release in HEAD's history is at least as high (an older release merged back in, or an rc whose final release exists), so the base never names an older version than HEAD contains; - msix_version X.Y.Z.0 for final releases and <highest final release>.<build> for pre-release *and* -rc tag builds, so rc -> later builds -> final release are all upgrades (errors past the 16-bit MSIX limit); - full semver validation of tags (malformed ones such as v1.2.3- or v1.08.3 fail up front instead of in pub), rejection of release tags carrying +build metadata, and dropping of build metadata from base tags; - a clear failure when HEAD's history is shallow and no final release is reachable, rather than silently guessing 0.0.0; - awk-based rewriting that behaves the same on all runners, preserves msix_version's indentation, keeps a CRLF file CRLF, and leaves the file untouched on any error. The line ending is detected from the raw bytes with od: Git for Windows' awk drops the CR of a CRLF line as it reads it, so it cannot tell the two apart itself, and on the Windows runner it turned the whole file into LF. .github/actions/build-version runs both scripts, passing the tag (only for v* tag refs) and github.run_number through env vars (so a tag name cannot inject shell) and teeing the output into $GITHUB_ENV. All eight jobs that build use it in one step, now including deploy-web. The macOS and iOS builds pass --build-name "$WIMSY_VERSION_CORE", so the bundle gets e.g. 0.0.6 (412) in place of 0.0.62171; the build number still comes from the pubspec. The .deb reads $WIMSY_VERSION, so its version is exactly as before (no +build). A new test-ci-scripts job runs the script tests on Linux, macOS and Windows in parallel with the builds, and publish-release waits for it. The macOS DMG verification now checks the version on every build, not just tags. tool/verify_macos_dmg.sh gains an optional expected CFBundleVersion argument, which CI passes, and reports a missing Info.plist key as a failed check instead of aborting under set -e. Known limitations, documented in build_version.sh: Apple platforms only take numeric versions, so a pre-release or -rc build shares its release's short version there (the build number differs). The run counter is shared by all branches, so it orders builds by when they ran, and restarts if the workflow file is renamed. Undotted rc numbers (rc10 vs rc9) sort lexically; tags should use rc.N. Ordering of pre-release display versions is unchanged here (see the follow-up). Testing: - New tool/test_build_version.sh (76 checks, run under LC_ALL=C) in the new test-ci-scripts job on all three runner types. It uses throwaway git repos and covers: no tags; nothing written (and a clean tree) without --write-pubspec; a pre-release after tags; release, v-less and -rc tags (rc MSIX after the last final release, and its 65535 limit); MSIX values for releases (including build 70000) and pre-releases after an rc; an older release merged back in nearer to HEAD (with dated commits so git describe really picks it); an rc superseded by its final release on the same commit (dated so describe picks the rc); a repo whose only tag is an rc; a non-semver v tag being ignored; build metadata on a base tag; indentation, CRLF (compared as raw bytes via od, since text tools on Windows can translate CRLF as they read) and --pubspec; and, on clones of a tagged origin with an annotated tag: build_version failing with guidance before history is fetched, a release build needing no history, the fetch reaching the last tag with only that history (31 of 86 commits), a detached HEAD, a remote with no tags, an orphan branch on a tagged remote (terminates with HEAD's full history, fetches no tags), and a full clone without tags (tags fetched). Failure cases (build number 0 or non-numeric, non-numeric tag, leading zeros, empty pre-release, a space, +build tag, pre-release build number over 65535, unknown argument, missing option value, missing msix_version line) each exit non-zero with the pubspec unchanged. - Mutation checks: removing the higher-base rule, the rc MSIX rule, the tag fetch for complete histories, the HEAD-history termination test, or the od line-ending detection (which reproduces the Windows awk behaviour on macOS) each makes the corresponding tests fail. - CI on a fork: the byte-level CRLF check failed on the Windows runner before the od detection was added (every 0d0a written as 0a), and passed on Linux and macOS. - Simulated the CI steps on a depth-1 clone of this repo: version 0.0.6-pre-<sha>, MSIX 0.0.6.412, 21 of 776 commits fetched. - Confirmed in flutter_tools (ios/xcode_build_settings.dart) that --build-name alone still takes the build number from the pubspec. - verify_macos_dmg.sh: passes with the v0.0.6 DMG's real build number; fails with a wrong one; with CFBundleVersion deleted it reports the failure and still runs the other checks. - Reviewed three times with /code-review; findings fixed or documented as limitations above. - shellcheck clean on all tool/*.sh; workflow and action YAML parse. - flutter analyze: no issues. flutter test: all 1044 passed. vendor/xmpp_stone dart test: all 190 passed. - Maestro flows not run locally (they need Openfire in Docker and an emulator, and would not exercise CI version stamping); the CI maestro-e2e job runs them against a CI-stamped build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pull request run on dwd/Wimsy (PR dwd#5) failed in every job with "deepening HEAD fetched no new commits; giving up". The run was created at 12:08 but only started at 16:10, after main had moved. By then GitHub had replaced the PR's merge commit (102d7d3 became f2558fd), so no ref pointed to the commit the run checked out. GitHub still serves such a commit by id, which is why actions/checkout's --depth=1 fetch worked, but `git fetch --deepen=N` on it returns nothing. GitHub does serve it at an absolute depth, so fetch_release_history.sh now asks for --depth=<current + step> each time round the loop. The starting depth is HEAD's commit count, which is at least the clone's depth; asking for less than a clone already has would cut its history back rather than extend it. The no-progress error now names the commit and remote. Testing: - Reproduced against GitHub with a depth-1 checkout of 102d7d3, as the run made: the old script fails with the same error; the new one fetches 24 commits, finds v0.0.6 and stamps 0.0.6-pre-102d7d3. Fetching the merge commit's parents instead was tried and rejected: the commit stays marked shallow, so git does not follow them. - tool/test_build_version.sh: 80 checks pass (76 before). New cases: - a merge commit that no ref points to, fetched by id from a remote with uploadpack.allowAnySHA1InWant. Local git still deepens such a commit, so this passes on the old code too and cannot catch the GitHub behaviour; it checks the fetch works on that kind of commit. - a depth-15 clone, checking a deeper starting clone still works. - shellcheck -x clean on both scripts. - flutter analyze, flutter test, vendored dart tests and Maestro not run locally: no Dart code changed; CI covers them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fishbowler
force-pushed
the
version-fixes
branch
from
November 19, 2026 17:04
fff062a to
fafdb91
Compare
dwd
pushed a commit
that referenced
this pull request
Nov 20, 2026
build-android had no Gradle cache (the Flutter action caches the Flutter SDK, not ~/.gradle), so every run downloaded all of Gradle's dependencies, including the plugins for Flutter's own Gradle plugin loader. That is slow, and makes the job fail whenever those repositories hiccup: a fork run failed with the Gradle Plugin Portal answering "Could not find org.jetbrains.kotlin:kotlin-stdlib:2.2.21" for an artifact that exists, and passed on re-run. Gradle's own download retries don't help there, as a not-found response is treated as definite. Add gradle/actions/setup-gradle@v6 to build-android, before the first Gradle build. Its init scripts apply to every Gradle run in the job, including those started by `flutter build apk`, and it caches the Gradle User Home (dependencies, wrapper distributions, generated jars) between runs. Only default-branch runs write the cache; branch and pull-request runs restore it. build-android is the only job that runs Gradle; maestro-e2e uses the APK it uploads. It uses the default (enhanced) cache provider: proprietary, under the Gradle Technologies Terms of Use, free for public repositories, with restore-key matching and cleanup. `cache-provider: basic` is the MIT-licensed alternative. No retry around the build step: with a warm cache the repositories are rarely contacted, and a retry would mostly delay genuine failures. Testing: - Workflow YAML parses; the step is in build-android immediately before "Build Android (release)". - Merges cleanly with the version-fixes and prerelease ordering branches (#5, #6). - flutter analyze: no issues. flutter test: all 1044 passed. vendor/xmpp_stone dart test: all 190 passed. - Maestro flows not run locally: CI-only change; the CI maestro-e2e job covers them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The workflow had seven identical copies of a "Set Build Version" step. Between them they produced the following wrong or missing versions:
0.0.0-pre-<sha>. CI uses depth-1 clones.git fetch --tagsdownloads the full history behind every tag, but HEAD's own history stays cut off at depth 1, sogit describenever reaches a tag and falls back to0.0.0.0.0.6-pre-d217e1dbecameCFBundleShortVersionString0.0.62171. There was no build number, soCFBundleVersionrepeated the same value.versionCodewas always 1.0.0.2.0.msix_versionin the pubspec was never updated.deploy-webhad no version step at all, so the live GitHub Pages site reported the committed placeholder0.0.2.sed -i -Eleft a straypubspec.yaml-Eon the macOS runners. BSD sed reads-Eas a backup-file suffix.Changes
The fix keeps the existing version scheme: releases are
X.Y.Zfrom the tag, pre-releases<base>-pre-<sha>. It fixes how the version is worked out and applied.tool/fetch_release_history.shfetches only the history needed to find the last release:ls-remote, which downloads no history.On this repo that's 21 of 776 commits and one tag. It handles a detached HEAD (pull-request merge commits), orphan branches, remotes with no tags, and full clones made without tags.
tool/build_version.shworks out the version, printsKEY=VALUElines and changes nothing unless asked. It takes--tagand--build-number, so nothing in it is specific to GitHub; it follows the same pattern astool/build_web.sh. Running it locally shows what version a build would get.--write-pubspecwrites the result intopubspec.yaml, so every tool that reads the pubspec picks it up:flutter build,msix:createandpackage_info_plus(and through it, Sentry).version: <display>+<build number>. The build number isgithub.run_number.X.Y.Z.0for final releases. Pre-release and rc-tag builds get<last final release>.<build>, so rc → later builds → final release are all upgrades.0.0.0..github/actions/build-versionis a small local action that maps GitHub's tag and run number onto the scripts and exports the results to later steps. The tag is passed through an environment variable rather than pasted into the script, so a tag name can't inject shell commands. All eight jobs that build use it in one step, includingdeploy-web.Workflow
--build-name "$WIMSY_VERSION_CORE", so bundles get e.g.0.0.6 (412).test-ci-scriptsjob runs the scripts' tests on Linux, macOS and Windows alongside the builds.publish-releasewaits for it.Testing
tool/test_build_version.sh: 76 checks in throwaway git repos. They cover:git describereally picks the tricky tag.test-ci-scriptson all three operating systems andmaestro-e2e. Stamped values from real runs:WIMSY_VERSION=0.0.6-pre-<sha>,WIMSY_MSIX_VERSION=0.0.6.<run>ok: bundle version 0.0.6,ok: bundle build number <run>flutter analyze,flutter testandvendor/xmpp_stonedart testall pass. The Maestro flows weren't run locally, since the app code is unchanged; CI'smaestro-e2epassed.Known limitations
These are documented in
tool/build_version.sh:github.run_numberis shared by all branches and restarts if the workflow file is renamed.rc10<rc9), so userc.Ntags.Not in this PR
0.0.6-pre-<sha>still sorts before0.0.6under semver. That scheme change is a separate follow-up PR, so it can be accepted or declined on its own.🤖 Generated with Claude Code