Skip to content

ios-testflight.yml: build-number auto-increment off-by-one when Apple's highest == this run's run_number #660

Closed

Description

@github-actions

Found during principal review of PR #659 (fix(ci): never pick a build number lower than what Apple has already seen, commit fc36bde).

In .github/workflows/ios-testflight.yml's "Determine Build Number" step, the auto-increment branch (no explicit build_number input) does:

RUN_NUMBER=${{ github.run_number }}
BUILD_NUMBER=$(( HIGHEST > RUN_NUMBER ? HIGHEST + 1 : RUN_NUMBER ))

where HIGHEST is the max build number Apple has seen for this app across every upload path (queried live via the App Store Connect API).

When HIGHEST == RUN_NUMBER — Apple has already seen a build numbered exactly this workflow run's run_number, via any other upload path (explicit build_number dispatch input, the CircleCI fallback pipeline, etc.) — the > comparison is false, so BUILD_NUMBER is set to RUN_NUMBER, which equals HIGHEST. That's a build number Apple has already seen, i.e. exactly the class of bug this PR otherwise fixes (a lower-or-equal build number is invisible to/rejected by TestFlight, per this PR's own root-cause writeup). Verified the arithmetic directly:

$ HIGHEST=150; RUN_NUMBER=150; echo $(( HIGHEST > RUN_NUMBER ? HIGHEST + 1 : RUN_NUMBER ))
150   # collides with HIGHEST, should be 151

Concretely reachable in this repo's own workflow: run_number only increments once per dispatch of this workflow, but HIGHEST also tracks builds uploaded via explicit build_number input (used routinely for manual testing/verification, e.g. the build-149 test in PR #659 itself) or the separate CircleCI fallback path. Either can push HIGHEST up independent of run_number, and run_number will eventually catch up to a value some other path already used.

Fix: use >= instead of > (or unconditionally max(HIGHEST, RUN_NUMBER) + 1, which is what the PR description itself says it implements — the code doesn't quite match that description).

Not immediately merge-blocking on its own since this file is already risk:high (touches .github/workflows/**, always human-merge regardless), but should be fixed before or shortly after merge.

Activity

  1. libravault-xyz commented on Aug 26, 2026

    @libravault-xyz
    Collaborator

    Fixed inline in PR #659 (commit a6f4714, squash-merged) rather than as a follow-up — the ternary now always adds 1 to whichever of HIGHEST/RUN_NUMBER is greater, so the HIGHEST==RUN_NUMBER case can no longer resolve to a build number Apple has already seen. Verified: HIGHEST=150 RUN_NUMBER=150 now yields 151. Confirmed working end-to-end for real: build 149 (dispatched under the pre-fix explicit-input path) reached the user's device and sent a real TestFlight notification email within minutes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions