Skip to content

Fix build number for release.yml flow#115

Merged
pappz merged 5 commits intomainfrom
fix-cicd-for-release-yml
May 7, 2026
Merged

Fix build number for release.yml flow#115
pappz merged 5 commits intomainfrom
fix-cicd-for-release-yml

Conversation

@evgeniyChepelev
Copy link
Copy Markdown
Collaborator

@evgeniyChepelev evgeniyChepelev commented May 5, 2026

Description

Release workflow now fetches the latest build number from App Store Connect before building
Build number is automatically set to latest + 1 for the release version derived from the git tag
Falls back to 1 if no builds exist yet for that version
Consistent with the same logic already in testflight.yml

Added APP_STORE_APP_ID_TVOS secret support to fetch tvOS build number independently from iOS
tvOS and iOS now each query App Store Connect separately and get their own latest + 1 build number
Fixed tvOS not receiving the correct MARKETING_VERSION — now passed via new version input in build-upload-tvos.yml
Added tvOS build to release.yml (was missing entirely)
Fixed if: inputs.upload → if: inputs.upload == true in both build workflows to ensure upload step is not skipped

Summary by CodeRabbit

  • Chores
    • Release and test workflows now compute and supply separate iOS and tvOS build numbers automatically.
  • New Features
    • Added an optional marketing-version override for tvOS build uploads.
  • Bug Fixes
    • Upload step now runs only when upload is explicitly set to true, preventing unintended uploads.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

A new GitHub Actions job, fetch-build-number, queries App Store Connect using an ES256 JWT to read latest iOS and tvOS build versions, computes the next build numbers, and exposes them. The build and build-tvos jobs now depend on that job and pass the respective computed build-number into their reusable build-upload workflows; upload steps require inputs.upload == true.

Changes

iOS / tvOS Build Number Automation

Layer / File(s) Summary
Data Shape / Job Outputs
.github/workflows/release.yml, .github/workflows/testflight.yml
Adds jobs.fetch-build-number.outputs.build-number and jobs.fetch-build-number.outputs.build-number-tvos; adds jobs.gate.outputs.build-number-tvos in testflight.yml.
Core Implementation
.github/workflows/release.yml (new job), .github/workflows/testflight.yml (fetch logic)
New fetch-build-number job: installs cryptography, decodes App Store Connect private key, generates ES256 JWT, queries ASC builds for APP_ID_IOS and APP_ID_TVOS filtered by tag-derived VERSION, parses latest attributes.version, computes next build numbers (default '1' when missing/non-numeric, otherwise increments), and sets GITHUB_OUTPUT outputs. testflight.yml refactors ASC fetch into a fetch_latest shell function and writes both latest-build and latest-build-tvos.
Wiring / Integration
.github/workflows/release.yml, .github/workflows/testflight.yml
build and build-tvos jobs now needs: [prepare, fetch-build-number] and pass build-number / build-number-tvos into ./.github/workflows/build-upload.yml and ./.github/workflows/build-upload-tvos.yml respectively; testflight.yml finalizes and exports build-number-tvos.
Reusable Workflow Inputs
.github/workflows/build-upload-tvos.yml
Adds optional workflow_call input version (marketing version override) and outputs version-args=MARKETING_VERSION=... when provided; xcodebuild archive includes these version args.
Conditional Tightening
.github/workflows/build-upload.yml, .github/workflows/build-upload-tvos.yml
"Export and Upload to App Store Connect" step condition changed from if: inputs.upload to if: inputs.upload == true to require explicit boolean true.
Tests / Docs / Minor Edits
.github/workflows/*
Various lines updated across the workflows to propagate new inputs/outputs and integrate the new job.

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions (release.yml)
    participant JWT as JWT Generator (cryptography step)
    participant ASC as App Store Connect API
    participant Gate as Gate/Finalize (testflight.yml)
    participant BuildWF as Reusable Build Workflow (build-upload*.yml)

    GHA->>JWT: decode key & generate ES256 JWT
    GHA->>ASC: GET /v1/builds?filter[app]=APP_ID_IOS&filter[preReleaseVersion]=VERSION
    ASC-->>GHA: latest iOS build JSON
    GHA->>ASC: GET /v1/builds?filter[app]=APP_ID_TVOS&filter[preReleaseVersion]=VERSION
    ASC-->>GHA: latest tvOS build JSON
    GHA->>GHA: parse attributes.version, compute next build-number and build-number-tvos
    GHA->>Gate: export build-number outputs
    GHA->>BuildWF: invoke reusable workflows with ref, version, build-number(s)
    BuildWF->>BuildWF: run export/upload step only if inputs.upload == true
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • netbirdio/ios-client#104: Implements querying App Store Connect to auto-increment build numbers (same feature area).
  • netbirdio/ios-client#97: Modifies CI to compute/accept TestFlight build-number and pass it into reusable build-upload workflows.
  • netbirdio/ios-client#69: Adds build-upload workflow and related wiring that this PR extends by supplying build-number inputs.

Suggested reviewers

  • pappz
  • mlsmaycon

🐰
I hop and fetch the latest score,
A build-number found, then one more.
Signed with a key, swift and fleet,
Released in order, tidy and neat—
Hooray for CI’s carrot treat! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix build number for release.yml flow' is directly related to the main changes: fetching build numbers from App Store Connect and passing them to the release workflow jobs.
Description check ✅ Passed The description provides comprehensive details on the changes, including fetch logic, tvOS support, and workflow fixes, covering all significant alterations in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-cicd-for-release-yml

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release.yml:
- Around line 64-67: The shell assignment for NEXT can become empty because the
python one-liner only prints on the true branch; update the python call so it
always prints a value (or fails loudly) — e.g., replace the current python3 -c
"v='$LATEST'; print(int(v)+1) if v.isdigit() else '1'" with a command that
always prints like python3 -c "v='$LATEST'; print(str(int(v)+1) if v.isdigit()
else '1')" (or alternatively explicitly validate LATEST and exit non‑zero to
fail loudly); ensure this fixes NEXT being empty and that the downstream
build-number no longer receives an empty string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06182eae-392d-4f78-a540-48e23278be0e

📥 Commits

Reviewing files that changed from the base of the PR and between c76475b and 29f4914.

📒 Files selected for processing (1)
  • .github/workflows/release.yml

Comment thread .github/workflows/release.yml Outdated
@evgeniyChepelev
Copy link
Copy Markdown
Collaborator Author

/testFlight

@evgeniyChepelev
Copy link
Copy Markdown
Collaborator Author

/testflight

1 similar comment
@evgeniyChepelev
Copy link
Copy Markdown
Collaborator Author

/testflight

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/release.yml (1)

64-67: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Make the fallback branch print a value.

The current one-liner only prints on the isdigit() branch, so any non-digit LATEST makes NEXT empty instead of "1". That silently bypasses the App Store-derived fallback logic.

Suggested fix
-            NEXT=$(python3 -c "v='$LATEST'; print(int(v)+1) if v.isdigit() else '1'")
+            NEXT=$(python3 - "$LATEST" <<'PY'
+import sys
+
+v = sys.argv[1]
+print(int(v) + 1 if v.isdigit() else 1)
+PY
+            )
#!/bin/bash
set -euo pipefail

python3 <<'PY'
import subprocess

for v in ["7", "1.2", "none"]:
    cmd = ["python3", "-c", f"v='{v}'; print(int(v)+1) if v.isdigit() else '1'"]
    out = subprocess.run(cmd, capture_output=True, text=True, check=True)
    print(f"{v!r} -> stdout={out.stdout.strip()!r}")
PY

Expected result: "1.2" and "none" currently produce empty stdout, confirming that NEXT can become empty.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yml around lines 64 - 67, The python one-liner
that sets NEXT from LATEST only prints when v.isdigit(), leaving NEXT empty for
non-digit LATEST values; update the command used to compute NEXT (the python3 -c
"v='$LATEST'...") to ensure the else branch prints a value, e.g. replace
print(int(v)+1) if v.isdigit() else '1' with a single print that covers both
branches such as print(int(v)+1 if v.isdigit() else 1) so NEXT is always
assigned (refer to the NEXT and LATEST variables and the python3 -c invocation).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release.yml:
- Around line 37-38: The fetch-build-number job currently queries only
APP_STORE_APP_ID_IOS and its output is reused for tvOS, which can mismatch; add
a new secret (e.g., APP_STORE_APP_ID_TVOS) and create a new job
fetch-build-number-tvos that mirrors fetch-build-number but uses
APP_STORE_APP_ID_TVOS, run it before build-tvos, and have build-tvos consume the
tvOS-specific build number output instead of the iOS output; update references
in the workflow (jobs: fetch-build-number, fetch-build-number-tvos, build-tvos)
so tvOS uses the new job output.

---

Duplicate comments:
In @.github/workflows/release.yml:
- Around line 64-67: The python one-liner that sets NEXT from LATEST only prints
when v.isdigit(), leaving NEXT empty for non-digit LATEST values; update the
command used to compute NEXT (the python3 -c "v='$LATEST'...") to ensure the
else branch prints a value, e.g. replace print(int(v)+1) if v.isdigit() else '1'
with a single print that covers both branches such as print(int(v)+1 if
v.isdigit() else 1) so NEXT is always assigned (refer to the NEXT and LATEST
variables and the python3 -c invocation).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d569c814-4c08-4c52-9fd2-66d6bc7471f4

📥 Commits

Reviewing files that changed from the base of the PR and between 29f4914 and c046738.

📒 Files selected for processing (3)
  • .github/workflows/build-upload-tvos.yml
  • .github/workflows/build-upload.yml
  • .github/workflows/release.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/build-upload.yml

Comment thread .github/workflows/release.yml Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

TestFlight builds uploaded 0.2.1 (2) for c046738 — iOS + tvOS

View workflow run

@evgeniyChepelev
Copy link
Copy Markdown
Collaborator Author

/testflight

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/testflight.yml (1)

286-363: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Notify messages only surface the iOS build number, now that iOS and tvOS builds diverge.

Both notify (Line 295, 309, 312) and notify-merge (Line 339, 355) construct their messages using only needs.gate.outputs.build-number (the iOS build number). Since this PR intentionally gives tvOS its own independent build number (build-number-tvos), the commit/PR comment will silently show the iOS number for both platforms, making it hard to cross-reference the correct tvOS build in App Store Connect.

💬 Suggested fix for notify and notify-merge

In the notify job, expose the tvOS build number alongside the iOS one:

            const buildNumber     = '${{ needs.gate.outputs.build-number }}';
+           const buildNumberTvos = '${{ needs.gate.outputs.build-number-tvos }}';
            const version         = '${{ needs.gate.outputs.version }}';

Then update the success message body:

-             body = `**TestFlight builds uploaded** \`${version} (${buildNumber})\` for \`${shortSha}\` — iOS + tvOS\n\n[View workflow run](${runUrl})`;
+             body = `**TestFlight builds uploaded** \`${version}\` for \`${shortSha}\` — iOS (${buildNumber}) + tvOS (${buildNumberTvos})\n\n[View workflow run](${runUrl})`;

Apply the same pattern to notify-merge:

            const version     = process.env.VERSION;
            const buildNumber = process.env.BUILD_NUMBER;
+           const buildNumberTvos = '${{ needs.gate.outputs.build-number-tvos }}';
            ...
-           const body = `**TestFlight** \`${version} (${buildNumber})\` — iOS ${iosBadge} tvOS ${tvosBadge}\n\n[View workflow run](${runUrl})`;
+           const body = `**TestFlight** \`${version}\` — iOS ${iosBadge} (${buildNumber}) tvOS ${tvosBadge} (${buildNumberTvos})\n\n[View workflow run](${runUrl})`;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/testflight.yml around lines 286 - 363, The notify and
notify-merge steps currently only surface the iOS build number
(needs.gate.outputs.build-number / BUILD_NUMBER) but tvOS has a separate build
number (needs.gate.outputs.build-number-tvos); update both jobs to read and
expose the tvOS build number: in the notify job add build-number-tvos to the
interpolated inputs and create a const buildNumberTvos (from
needs.gate.outputs.build-number-tvos) and include it in the PR comment body
alongside buildNumber (e.g., show `iOS: <buildNumber> tvOS: <buildNumberTvos>`);
do the same in notify-merge by adding BUILD_NUMBER_TVOS to env, reading
process.env.BUILD_NUMBER_TVOS into a buildNumberTvos const and include it in the
commit comment body so both platforms’ build numbers are clearly shown.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In @.github/workflows/testflight.yml:
- Around line 286-363: The notify and notify-merge steps currently only surface
the iOS build number (needs.gate.outputs.build-number / BUILD_NUMBER) but tvOS
has a separate build number (needs.gate.outputs.build-number-tvos); update both
jobs to read and expose the tvOS build number: in the notify job add
build-number-tvos to the interpolated inputs and create a const buildNumberTvos
(from needs.gate.outputs.build-number-tvos) and include it in the PR comment
body alongside buildNumber (e.g., show `iOS: <buildNumber> tvOS:
<buildNumberTvos>`); do the same in notify-merge by adding BUILD_NUMBER_TVOS to
env, reading process.env.BUILD_NUMBER_TVOS into a buildNumberTvos const and
include it in the commit comment body so both platforms’ build numbers are
clearly shown.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a789917e-6514-4c65-83f7-b1f4bb5b5e4e

📥 Commits

Reviewing files that changed from the base of the PR and between c046738 and f53a332.

📒 Files selected for processing (3)
  • .github/workflows/build-upload-tvos.yml
  • .github/workflows/release.yml
  • .github/workflows/testflight.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml

@pappz pappz merged commit b5ca6c4 into main May 7, 2026
16 checks passed
@pappz pappz deleted the fix-cicd-for-release-yml branch May 7, 2026 11:18
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.

2 participants