Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .agents/skills/release-update/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ existing production binary and no store binary or compliance update is needed.
- `bun eas:prod:android`
- `bun eas:prod:ios`
- `bun eas:preview:android` for an internal-distribution check first
- or the Codemagic `ios-production` / `android-production` workflows, started
by hand on the merged commit. They load the `production` EAS environment,
sign from the secure `bookoo_production` group, fail unless the bundle
targets the production Convex host (and, on Android, unless the upload key
signed it), then upload to TestFlight and a Play internal draft. Review
submission and rollout stay manual.
6. Inspect EAS build metadata and download the artifacts when URLs are
available. Verify Android is a readable AAB with the expected package and
version, and iOS is an IPA archive with the expected bundle and version. A
Expand Down
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ EXPO_PUBLIC_LAYERS_APP_ID=
# @cpk-org/bookoo project id so EAS can resolve the project before cloud env is loaded.
EAS_PROJECT_ID=

# --- Codemagic store builds ----------------------------------------------------
# Store build number (iOS CFBundleVersion / Android versionCode) for builds made
# outside EAS. Codemagic sets it above the latest uploaded store build; EAS
# builds keep their remote numbers and leave it unset.
BOOKOO_BUILD_NUMBER=

# --- Local simulator state verification --------------------------------------
# Development-only switches used to capture otherwise conditional UI states.
# Leave both blank for ordinary development and every release candidate.
Expand Down
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ Always write commit messages in Angular Conventional Commits format.
pin. A native dependency upgrade requires rebuilt candidates and fresh E2E.
- Never enqueue an EAS cloud build. Every EAS native build must use
`eas build --local`, including production and store-candidate builds.
- Store binaries may instead come from the manual Codemagic `ios-production`
and `android-production` workflows in `codemagic.yaml`. They upload to
TestFlight and a Play internal draft only, never submit for review, and
number each build one above the latest store build. The EAS remote counter
then falls behind: raise it with `eas build:version:set` before the next EAS
store build.
- Direct local Xcode and Gradle builds remain the preferred fast path for
simulator, emulator, and connected-device E2E checks.
- Store submission is a separate operation: inspect the locally built IPA or
Expand Down
6 changes: 6 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ table or function names outside that authority.
pin. A native dependency upgrade requires rebuilt candidates and fresh E2E.
- Never enqueue an EAS cloud build. Every EAS native build must use
`eas build --local`, including production and store-candidate builds.
- Store binaries may instead come from the manual Codemagic `ios-production`
and `android-production` workflows in `codemagic.yaml`. They upload to
TestFlight and a Play internal draft only, never submit for review, and
number each build one above the latest store build. The EAS remote counter
then falls behind: raise it with `eas build:version:set` before the next EAS
store build.
- Direct local Xcode and Gradle builds remain the preferred fast path for
simulator, emulator, and connected-device E2E checks.
- Store submission is a separate operation: inspect the locally built IPA or
Expand Down
9 changes: 9 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ const variant = process.env.BOOKOO_APP_VARIANT;
if (variant !== undefined && variant !== 'qa' && variant !== 'production')
throw new Error('BOOKOO_APP_VARIANT must be qa or production');
const qa = variant === 'qa';
// Builds made outside EAS (Codemagic) pass the store build number in; EAS
// builds keep `appVersionSource: remote` and leave this unset.
const storeBuildNumber = process.env.BOOKOO_BUILD_NUMBER?.trim() || undefined;
if (storeBuildNumber !== undefined && !/^[1-9]\d*$/.test(storeBuildNumber))
throw new Error('BOOKOO_BUILD_NUMBER must be a positive integer');
if (
qa &&
['production', 'purchase-test'].includes(process.env.EAS_BUILD_PROFILE ?? '')
Expand Down Expand Up @@ -376,6 +381,7 @@ export default ({config}: ConfigContext): ExpoConfig => ({
],
ios: {
bundleIdentifier: qa ? QA_APPLICATION_ID : APPLICATION_ID,
...(storeBuildNumber === undefined ? {} : {buildNumber: storeBuildNumber}),
appleTeamId: APPLE_TEAM_ID,
supportsTablet: true,
usesAppleSignIn: true,
Expand Down Expand Up @@ -408,6 +414,9 @@ export default ({config}: ConfigContext): ExpoConfig => ({
},
android: {
package: qa ? QA_APPLICATION_ID : APPLICATION_ID,
...(storeBuildNumber === undefined
? {}
: {versionCode: Number(storeBuildNumber)}),
adaptiveIcon: {
foregroundImage: './assets/adaptive-icon-foreground.png',
monochromeImage: './assets/adaptive-icon-foreground.png',
Expand Down
163 changes: 161 additions & 2 deletions codemagic.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Codemagic native build checks for BooKoo.
# Codemagic native builds for BooKoo.
#
# These workflows prove that the native iOS and Android projects still build.
# The QA workflows prove that the native iOS and Android projects still build.
# They use the QA app identity and no signing or store credentials, so they
# run the same for forks and pull requests. Lint, typecheck and tests stay in
# GitHub Actions (.github/workflows/ci.yml).
#
# The production workflows build signed store binaries and upload them to
# TestFlight and the Play internal track as a draft. They never submit for
# review or roll out; those stay manual store actions. They start only by hand
# and read every credential from the secure `bookoo_production` group.
# Codemagic builds a pull request from the yaml on its source branch, so PR
# webhooks stay off until fork builds are proven unable to reach that group.

definitions:
environment: &environment
Expand All @@ -30,6 +37,24 @@ definitions:
- &install_dependencies
name: Install dependencies
script: bun install --frozen-lockfile
- &load_production_env
name: Load the EAS production environment
script: |
set -euo pipefail
bunx eas-cli@23.0.0 env:exec production --non-interactive \
'node scripts/codemagic/print-public-env.mjs' \
| grep -E '^EXPO_PUBLIC_[A-Z0-9_]+=' > /tmp/bookoo-public.env
test -s /tmp/bookoo-public.env
cat /tmp/bookoo-public.env >> "$CM_ENV"
echo "Loaded $(wc -l < /tmp/bookoo-public.env | tr -d ' ') EXPO_PUBLIC_* variables"
rm /tmp/bookoo-public.env
# YAML merge keys are shallow: each production workflow lists its own `vars`.
# app.config.ts keys its production guards (required ad and map ids, no QA
# identity) on the EAS_BUILD_* names, so these builds set them too.
production_environment: &production_environment
node: 22.14.0
groups:
- bookoo_production

workflows:
ios-qa-simulator:
Expand Down Expand Up @@ -79,3 +104,137 @@ workflows:
script: cd android && ./gradlew :app:assembleRelease --no-daemon
artifacts:
- android/app/build/outputs/**/*.apk

ios-production:
name: iOS production (TestFlight upload)
instance_type: mac_mini_m2
max_build_duration: 90
environment:
<<: *production_environment
vars:
CI: '1'
EXPO_NO_DOTENV: '1'
STAGE: production
BOOKOO_APP_VARIANT: production
EAS_BUILD_PROFILE: production
EAS_BUILD_PLATFORM: ios
BUN_VERSION: '1.3.13'
APP_STORE_APPLE_ID: '6805969489'
xcode: latest
cocoapods: default
scripts:
- *install_bun
- *install_dependencies
- *load_production_env
- name: Pick the next build number
script: |
set -euo pipefail
testflight=$(app-store-connect get-latest-testflight-build-number "$APP_STORE_APPLE_ID" | tail -1)
store=$(app-store-connect get-latest-app-store-build-number "$APP_STORE_APPLE_ID" | tail -1) || store=0
[[ "$testflight" =~ ^[0-9]+$ && "$store" =~ ^[0-9]+$ ]]
next=$(( (testflight > store ? testflight : store) + 1 ))
echo "BOOKOO_BUILD_NUMBER=$next" >> "$CM_ENV"
echo "Build number $next"
- name: Install the App Store signing files
script: |
set -euo pipefail
keychain initialize
echo "$BOOKOO_IOS_DIST_P12_BASE64" | base64 --decode > /tmp/bookoo-dist.p12
keychain add-certificates \
--certificate /tmp/bookoo-dist.p12 \
--certificate-password "$BOOKOO_IOS_DIST_P12_PASSWORD"
rm /tmp/bookoo-dist.p12
profiles="$HOME/Library/MobileDevice/Provisioning Profiles"
mkdir -p "$profiles"
echo "$BOOKOO_IOS_PROFILE_BASE64" | base64 --decode \
> "$profiles/bookoo-app-store.mobileprovision"
- name: Generate the iOS project
script: bunx expo prebuild --no-install --platform ios
- name: Install pods
script: cd ios && pod install
- name: Build the signed IPA
script: |
set -euo pipefail
xcode-project use-profiles
xcode-project build-ipa \
--workspace ios/BooKoo.xcworkspace \
--scheme BooKoo
- name: Check the bundle carries the production backend
script: |
set -euo pipefail
host=$(node -p 'new URL(process.env.EXPO_PUBLIC_CONVEX_URL).host')
ipa=$(ls build/ios/ipa/*.ipa)
unzip -p "$ipa" 'Payload/BooKoo.app/main.jsbundle' | grep -a -q "$host"
echo "main.jsbundle targets $host"
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
publishing:
app_store_connect:
api_key: $APP_STORE_CONNECT_PRIVATE_KEY
key_id: $APP_STORE_CONNECT_KEY_IDENTIFIER
issuer_id: $APP_STORE_CONNECT_ISSUER_ID
submit_to_testflight: false
submit_to_app_store: false

android-production:
name: Android production (Play internal draft)
instance_type: linux_x2
max_build_duration: 90
environment:
<<: *production_environment
vars:
CI: '1'
EXPO_NO_DOTENV: '1'
STAGE: production
BOOKOO_APP_VARIANT: production
EAS_BUILD_PROFILE: production
EAS_BUILD_PLATFORM: android
BUN_VERSION: '1.3.13'
PACKAGE_NAME: dev.hyo.bookoo
# Public SHA-256 of the Play upload certificate. A release signed with
# any other key fails here instead of at the Play upload.
UPLOAD_CERT_SHA256: 'A1:86:1E:6C:45:25:63:64:F5:27:1D:7A:A9:76:95:9D:77:70:40:F2:3C:AD:14:39:55:16:A6:8A:B9:A4:B1:01'
java: 17
scripts:
- *install_bun
- *install_dependencies
- *load_production_env
- name: Pick the next version code
script: |
set -euo pipefail
latest=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME" | tail -1)
[[ "$latest" =~ ^[0-9]+$ ]]
next=$((latest + 1))
echo "BOOKOO_BUILD_NUMBER=$next" >> "$CM_ENV"
echo "Version code $next"
- name: Install the upload keystore
script: |
set -euo pipefail
echo "$BOOKOO_UPLOAD_KEYSTORE_BASE64" | base64 --decode > /tmp/bookoo-upload.jks
echo "BOOKOO_UPLOAD_KEYSTORE_PATH=/tmp/bookoo-upload.jks" >> "$CM_ENV"
- name: Generate the Android project
script: |
set -euo pipefail
bunx expo prebuild --no-install --platform android
echo "apply from: new File(rootDir, '../scripts/codemagic/release-signing.gradle')" \
>> android/app/build.gradle
- name: Build the signed app bundle
script: cd android && ./gradlew :app:bundleRelease --no-daemon
- name: Check the signature and the production backend
script: |
set -euo pipefail
aab=android/app/build/outputs/bundle/release/app-release.aab
keytool -printcert -jarfile "$aab" | grep -q "SHA256: $UPLOAD_CERT_SHA256"
host=$(node -p 'new URL(process.env.EXPO_PUBLIC_CONVEX_URL).host')
unzip -p "$aab" base/assets/index.android.bundle | grep -a -q "$host"
echo "Signed with the upload key; bundle targets $host"
artifacts:
- android/app/build/outputs/bundle/release/*.aab
- android/app/build/outputs/mapping/release/mapping.txt
publishing:
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
submit_as_draft: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bookoo",
"version": "1.4.0",
"version": "1.5.0",
"description": "BooKoo — shared ledger app",
"main": "expo-router/entry",
"private": true,
Expand Down
17 changes: 17 additions & 0 deletions scripts/codemagic/print-public-env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Prints the EXPO_PUBLIC_* variables of the current process as KEY=value lines
// for Codemagic's $CM_ENV. `codemagic.yaml` runs it inside
// `eas env:exec production`, so the store build bundles exactly the values the
// EAS production environment holds. $CM_ENV is line-based: a multi-line value
// would corrupt every variable after it, so one fails the build instead.
const lines = Object.entries(process.env)
.filter(([name]) => name.startsWith('EXPO_PUBLIC_'))
.sort(([a], [b]) => a.localeCompare(b))
.map(([name, value]) => {
if (/[\r\n]/.test(value ?? ''))
throw new Error(`${name} spans several lines`);
return `${name}=${value}`;
});

if (lines.length === 0)
throw new Error('The EAS production environment returned no EXPO_PUBLIC_*');
process.stdout.write(`${lines.join('\n')}\n`);
27 changes: 27 additions & 0 deletions scripts/codemagic/release-signing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Signs Codemagic store builds with BooKoo's Play upload key.
//
// `codemagic.yaml` decodes the keystore from the `bookoo_production` group and
// appends `apply from:` for this file to the generated android/app/build.gradle,
// so it is evaluated after Expo's `android {}` block and replaces the debug
// signing config the template gives release builds.
def env = { String name ->
def value = System.getenv(name)
if (!value) throw new GradleException("${name} is required to sign a store build")
value
}

android {
signingConfigs {
upload {
storeFile file(env('BOOKOO_UPLOAD_KEYSTORE_PATH'))
storePassword env('BOOKOO_UPLOAD_KEYSTORE_PASSWORD')
keyAlias env('BOOKOO_UPLOAD_KEY_ALIAS')
keyPassword env('BOOKOO_UPLOAD_KEY_PASSWORD')
}
}
buildTypes {
release {
signingConfig signingConfigs.upload
}
}
}
Loading
Loading