Flow Architecture
appitool flow is an opinionated release orchestration engine inspired by Fastlane lanes. Every flow execution transitions sequentially through a standardized 7-stage lifecycle backed by a shared FlowContext and a strict error boundary in FlowRunner.
The 7-Stage Pipeline
┌─────────┐ ┌──────────┐ ┌─────────┐ ┌───────────┐ ┌────────────┐ ┌───────────┐ ┌─────────────┐
│ setup │──▶│ prebuild │──▶│ build │──▶│ postbuild │──▶│ prerelease │──▶│ release │──▶│ postrelease │
└─────────┘ └──────────┘ └─────────┘ └───────────┘ └────────────┘ └───────────┘ └─────────────┘| # | Stage (FlowStage) | Emoji | Display Name | Core Responsibilities |
|---|---|---|---|---|
| 1 | setup | 🔍 | Setup & Environment | Inspect project (Xcode / Gradle), resolve bundle ID / package name, sync Match certs/profiles or keystore, fetch latest remote build number. |
| 2 | prebuild | 🔧 | Pre-Build & Versioning | Compute next build number / versionCode (max(remote, local) + 1 via BuildNumberPolicy), snapshot project.pbxproj, apply temporary manual code signing to Xcode targets, and normalize literal Info.plist CFBundleVersion entries to $(CURRENT_PROJECT_VERSION) via XCodeTasks.updateBuildNumber. |
| 3 | build | 🔨 | Build Compilation | Run xcodebuild (injecting CURRENT_PROJECT_VERSION=<buildNumber> for .xcarchive, .ipa, and dSYM, then restoring project.pbxproj and any temporary Info.plist edits in defer) or ./gradlew (bundleRelease / assembleRelease) and record artifact paths in FlowContext. |
| 4 | postbuild | 📦 | Post-Build | Verify that the generated .ipa, .aab, or .apk artifact exists on disk, is non-empty, and log its file size; with --attest, sign its SLSA build provenance with Sigstore and write <artifact>.sigstore.json (AttestationPresetHelpers). |
| 5 | prerelease | 📝 | Pre-Release | Generate plain-text store release notes via GenerateReleaseNotesTask using platform tag prefix (🍏_ for iOS, 🤖_ for Android) and store character limits (left empty if HEAD already sits on a matching tag); supports --release-notes, --notes-from, and --notes-locale overrides and logs the resolved source and preview. |
| 6 | release | 🚀 | Release & Store Upload | Upload binary to App Store Connect / TestFlight, Google Play Console internal track, or Firebase App Distribution. |
| 7 | postrelease | 📣 | Post-Release & Notifications | Create & push the release Git tag (🍏_<version>_<buildNumber>[_adhoc] / 🤖_<version>_<buildNumber>[_adhoc]) via GitTagTask and dispatch completion notifications to configured Slack and KokoNo webhooks (previewed / skipped in --dry-run mode). |
Built-in Flow Presets
Choosing a platform (ios / android) and distribution (appstore, adhoc, development) automatically selects a FlowPreset:
| Command Invocation | Preset | Target Destination |
|---|---|---|
flow ios -d appstore | IOSInternalPreset (iOS Internal) | App Store Connect / TestFlight |
flow ios -d adhoc | IOSAdHocPreset (iOS AdHoc) | Firebase App Distribution (internal group) |
flow ios -d development | IOSDevelopmentPreset (iOS Development) | Firebase App Distribution (internal group) |
flow android -d appstore | AndroidInternalPreset (Android Internal) | Google Play Console (internal track) |
flow android -d adhoc | AndroidAdHocPreset (Android AdHoc) | Firebase App Distribution (internal group) |
flow android -d development | AndroidDevelopmentPreset (Android Development) | Firebase App Distribution (internal group) |
Presets share stage implementations and only supply what differs per destination. Sources are grouped by platform under
Sources/appitool/Flow/Presets/:iOS/IOSPresetHelpers.swift(project detection, Match sync, manual signing + build-number bump, archive/export),Android/AndroidPresetHelpers.swift(project/flavor detection, Gradle build), andShared/FirebasePresetHelpers.swift(latest Firebase build lookup and upload/distribution, used by the ad-hoc and development presets).
1. IOSInternalPreset (flow ios -d appstore)
- Required Configuration (
requirements):APPLE_KEY_IDAPPLE_ISSUER_IDAPPLE_KEYMATCH_GIT_URLMATCH_PASSWORD
- Stage Execution:
setup: Detects.xcworkspace/.xcodeproj, scheme, configuration, main target, bundle ID, and project version. RunsMatchTaskwithtype: .appstore(forcedreadonlywhen--dry-runis set). Queries App Store Connect (GetLatestBuildNumberTask) for the latest TestFlight build number.prebuild: Extracts signing identity (iPhone DistributionorApple Distribution) and Team ID from installed certificates. Snapshotsproject.pbxproj, configures manual code signing per target viaXCodeTasks.configureManualSigning, computesmax(appstore_build_number, project build number) + 1incontext.buildNumber, and callsXCodeTasks.updateBuildNumberto normalize literalInfo.plistCFBundleVersionvalues to$(CURRENT_PROJECT_VERSION)without editingproject.pbxproj(permanently whenCURRENT_PROJECT_VERSIONis already defined inproject.pbxproj, or registered for post-build restore otherwise; skipped in--dry-run).build: Prepares macOS keychain (KeychainManager), compiles.xcarchive(passingCURRENT_PROJECT_VERSION=<buildNumber>) and exports.ipawith.appStoreexport method and manual signing viaXcodeBuildTask, restoringproject.pbxprojand any temporaryInfo.plistedits immediately indefer(skipped in--dry-run).postbuild: Verifies.ipaexistence and non-zero file size (skipped in--dry-run).prerelease: Generates plain-text release notes (max 4,000 chars) from commits since the latest🍏_*tag (excluding*_adhoc/*_development) viaGenerateReleaseNotesTask.release: Uploads.ipaviaUploadToAppStoreTask, waits for App Store Connect build processing (unless--no-wait-processingis passed), and sets TestFlight "What to Test" notes viasetWhatsNewwhenchangelogis populated.postrelease: Creates and pushes Git tag🍏_<version>_<buildNumber>viaGitTagTaskand dispatches Slack/KokoNo notifications (skipped in--dry-run).
2. IOSAdHocPreset (flow ios -d adhoc)
- Required Configuration (
requirements):MATCH_GIT_URLMATCH_PASSWORDFIREBASE_IOS_APP_IDGOOGLE_KEY
- Stage Execution:
setup: Inspects iOS project, runsMatchTaskwithtype: .adhoc, and queries Firebase App Distribution for the latest build number viaFirebasePresetHelpers.fetchLatestBuild(an app with no releases yet resolves to build0; lookup failures stop the flow).prebuild: Snapshotsproject.pbxproj, configures manual signing on Xcode targets, computesmax(firebase_build_number, project build number) + 1incontext.buildNumber, and normalizes literalInfo.plistCFBundleVersionvalues to$(CURRENT_PROJECT_VERSION)viaXCodeTasks.updateBuildNumber(kept permanently whenCURRENT_PROJECT_VERSIONexists inproject.pbxproj, or registered for post-build restore otherwise; skipped in--dry-run).build: Prepares keychain, builds.xcarchive(passingCURRENT_PROJECT_VERSION=<buildNumber>) and exports.ipawith.adHocexport method, restoringproject.pbxprojand temporaryInfo.plistedits immediately indefer(skipped in--dry-run).postbuild: Verifies.ipaexistence and non-zero file size (skipped in--dry-run).prerelease: Generates plain-text release notes (max 4,000 chars) from commits since the latest🍏_*tag viaGenerateReleaseNotesTask.release: Uploads the.ipawith generated release notes via the sharedFirebasePresetHelpers.distribute, which runsUploadToFirebaseTaskwithensureGroupsExistso theinternaltester group is created on Firebase (createOrGetGroup) before upload.postrelease: Creates and pushes Git tag🍏_<version>_<buildNumber>_adhocviaGitTagTaskand dispatches success notification to configured Slack and KokoNo webhooks (skipped in--dry-run).
2b. IOSDevelopmentPreset (flow ios -d development)
Same stages and requirements as IOSAdHocPreset, with development signing:
setup: RunsMatchTaskwithtype: .development(development certificates and profiles).prebuild: Uses a development signing identity (Apple Development/iPhone Developer, falling back toApple Development).build: Exports the.ipawith the.developmentexport method.release: Uploads viaFirebasePresetHelpers.distribute. Development-signed builds install only on devices included in the development provisioning profile.postrelease: Tags🍏_<version>_<buildNumber>_development.
3. AndroidInternalPreset (flow android -d appstore)
- Required Configuration (
requirements):GOOGLE_KEY
- Stage Execution:
setup: ExtractspackageName,applicationId,namespace,versionName,versionCode, and flavors via regex (AndroidTasks.getAndroidIdentifiers) and Gradle evaluation (evaluateAppInfoViaGradle). When--flavor/ANDROID_FLAVORis set, the selected flavor's effectiveapplicationId(unless--package-nameis given),versionName, andversionCodeare used, and a warning is logged if the flavor is not found. IfMATCH_GIT_URLandMATCH_PASSWORDare configured, resolves the release keystore viaAndroidPresetHelpers.resolveMatchKeystore(the flow fails if the package name is unknown or the Match lookup fails, instead of building unsigned). Queries Google Play Console (internaltrack) for the latestversionCode.prebuild: SetsversionCodetomax(googleplay_version_code, project versionCode) + 1incontext.buildNumber.build: Executes GradlebundleRelease(orbundle<Flavor>Releasewith--flavor) producing an.aabwith the resolvedversionCodeandversionNameplus Match signing config if present. Both are passed as-PversionCode/-PversionName; theversionCodeis also set on every application variant output through a temporary Gradle init script (androidComponents.onVariants), so it applies even whenbuild.gradle(.kts)hardcodes it. TheversionNamestays as the project defines it unless--app-versionis passed, which sets it the same way.--build-numberreplaces the automatic increment on both platforms; a value not above the store's latest becomes latest + 1. With-d appstore, setup stops the flow when the version was already released (App Store: approved version the same or higher; Google Play: production release with thatversionName);--no-version-checkskips this check.postbuild: Verifies.aabexistence and logs file size.prerelease: Generates plain-text release notes (max 500 chars for Google Play) from commits since the latest🤖_*tag (excluding*_adhoc/*_development) viaGenerateReleaseNotesTask.release: Uploads.aaband generated release notes to Google Play Consoleinternaltrack withreleaseStatus: .completedviaUploadToGooglePlayConsoleTask.postrelease: Creates and pushes Git tag🤖_<version>_<buildNumber>viaGitTagTaskand dispatches success notification to Slack and KokoNo webhooks (skipped in--dry-run).
4. AndroidAdHocPreset (flow android -d adhoc)
- Required Configuration (
requirements):FIREBASE_ANDROID_APP_IDGOOGLE_KEY
- Stage Execution:
setup: Inspects Android project, resolves the release keystore from Match when configured (failing the flow if the lookup fails), and retrieves the latest Firebase App Distribution build viaFirebasePresetHelpers.fetchLatestBuild(an app with no releases yet resolves to build0; lookup failures stop the flow).prebuild: SetsversionCodetomax(firebase_build_number, project versionCode) + 1.build: Runs GradleassembleRelease(default.apk) orbundleRelease(if--format aabis specified); with--flavor, runsassemble<Flavor>Release/bundle<Flavor>Release.postbuild: Verifies artifact file integrity and logs size.prerelease: Generates plain-text release notes (max 4,000 chars) from commits since the latest🤖_*tag viaGenerateReleaseNotesTask.release: Uploads the.apk/.aabwith generated release notes via the sharedFirebasePresetHelpers.distribute(same as iOS Ad-Hoc), which runsUploadToFirebaseTaskwithensureGroupsExistso theinternaltester group is created before upload.postrelease: Creates and pushes Git tag🤖_<version>_<buildNumber>_adhocviaGitTagTaskand dispatches success notification to Slack and KokoNo webhooks (skipped in--dry-run).
5. AndroidDevelopmentPreset (flow android -d development)
Same stages and requirements as AndroidAdHocPreset, with a debug build:
setup: Does not resolve a Match keystore; the project's Gradle debug signing config signs the build.build: Runs GradleassembleDebug(default.apk) orbundleDebug(with--format aab); with--flavor, runsassemble<Flavor>Debug/bundle<Flavor>Debug. Artifact name:<Target>_[<flavor>_]debug.release: Uploads viaFirebasePresetHelpers.distribute.postrelease: Tags🤖_<version>_<buildNumber>_development.
Global Error Boundary & Cleanup
FlowRunner wraps all stage execution inside a unified error boundary:
- Pre-flight Validation:
preset.requirements(context:)runs before any stage executes, throwingFlowRequirementErrorwith the full list of missing configuration keys. - Temporary File & Keystore Cleanup:
TemporaryFileRestorer(owned byFlowContext.fileRestorer) snapshotsproject.pbxprojbefore signing mutations and any temporaryInfo.plistedits made whenCURRENT_PROJECT_VERSIONis missing inproject.pbxproj; iOSbuildrestores them indeferandFlowRunner'sdeferblock (plusSIGINT/SIGTERMsignal handlers) acts as an emergency fallback if a stage exits early. For Android, any temporary keystore decrypted by Match (context.androidSigningTempUrl) and empty~/.appitool/android/keystoresdirectories are deleted automatically. - Failure Handling: If any stage throws:
- Pipeline execution halts immediately.
FlowRunnerprints a highlighted banner showing the failing stage (context.currentStage) and error reason.NotifyTask().notifyAllConfigured(status: .failure, ...)dispatches failure alerts to Slack and KokoNo containingPlatform,Distribution,Failing Stage,Elapsed Time, andBundle ID/Package Name(skipped when--dry-runis active).
- Success Summary: Upon completing all configured stages,
FlowRunnerprints total elapsed time and per-stage durations.
