agentic-mobile-kit 0.7.9 → 0.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-mobile-kit",
3
- "version": "0.7.9",
3
+ "version": "0.7.10",
4
4
  "description": "One setup for AI-assisted development of React Native apps, bare or Expo: shared rules and workflows for Claude Code, Codex and Antigravity, git hooks, device checks with screenshots, and release tooling for the App Store and Google Play.",
5
5
  "license": "MIT",
6
6
  "author": "prakashpro1",
@@ -15,7 +15,7 @@ const inProgress = d => {
15
15
  const specs = fs.existsSync('specs') ? fs.readdirSync('specs').filter(inProgress) : [];
16
16
  if (specs.length === 0) process.exit(0); // no spec in progress (quick change, bug fix, or finished work)
17
17
 
18
- const changed = execSync('git status --porcelain', { encoding: 'utf8' })
18
+ const changed = execSync('git status --porcelain --untracked-files=all', { encoding: 'utf8' }) // every new file, not just its new folder
19
19
  .split('\n').filter(Boolean).map(l => l.slice(3));
20
20
  const codeChanged = changed.some(f => !f.startsWith('specs/') && !f.startsWith('.amk/'));
21
21
  const handoffUpdated = changed.some(f => /^specs\/[^/]+\/progress\.md$/.test(f));
@@ -23,7 +23,10 @@
23
23
  # or UDID), AMK_ANDROID_DEVICE (adb serial: the only way to check on a phone, whose app data the flows clear),
24
24
  # AMK_ANDROID_AVD (the emulator to use, started if it isn't running; other devices are left alone),
25
25
  # AMK_IOS_TABLET (iPad simulator name or UDID), AMK_ANDROID_TABLET_AVD (tablet emulator), AMK_ANDROID_TABLET (serial),
26
- # AMK_PARALLEL (1 or 0: overrides plan's choice)
26
+ # AMK_PARALLEL (1 or 0: overrides plan's choice), AMK_DEVICE_WAIT (minutes to wait for a device in use, 30),
27
+ # AMK_LOCK_DIR (where runs on this machine claim devices; /tmp/agentic-mobile-kit-<user id>)
28
+ # A device in use by another run (any project on this machine) is skipped for a free one of the same kind, or waited
29
+ # for when it was named or none is free.
27
30
  # Flows that log in read ${MAESTRO_EMAIL} and the like from a local, gitignored .maestro/.env.local (never committed).
28
31
  set -eu
29
32
 
@@ -77,6 +80,54 @@ screens_for() {
77
80
  maestro_version() { maestro --version 2> /dev/null | tail -n 1 | tr -d '\r '; }
78
81
  maestro_at_least() { [ "$(printf '%s\n%s\n' "$1" "$(maestro_version)" | sort -V | head -n 1)" = "$1" ]; }
79
82
 
83
+ # Locks shared by every project and agent on this machine, so two runs never use one device (or build one project)
84
+ # at once: a run claims a device by creating a folder named after it, and gives it back when it's done with it. A
85
+ # claim whose run ended without giving it back is taken over.
86
+ locks=${AMK_LOCK_DIR:-/tmp/agentic-mobile-kit-$(id -u 2> /dev/null || echo 0)}
87
+ mkdir -p "$locks" 2> /dev/null || true
88
+ project=$(printf %s "$root" | cksum | cut -d ' ' -f 1)
89
+ held=""
90
+ lock_path() { echo "$locks/$(printf %s "$1" | tr -c 'A-Za-z0-9._-' _)"; }
91
+ # whether a Maestro run started outside the kit is using device $1 (its command line names the device)
92
+ maestro_on() { ps -ax -o command 2> /dev/null | grep -E -- "--(device|udid)[ =]$1( |$)" | grep -q maestro; }
93
+ # claims $1 for this run; with a device ID in $2, also when no other Maestro run is using that device
94
+ claim() {
95
+ l=$(lock_path "$1")
96
+ if mkdir "$l" 2> /dev/null; then
97
+ printf '%s\n%s\n%s\n' "$$" "$(basename "$root") (${label:-${spec:-$mode}})" "$(date +%H:%M)" > "$l/owner"
98
+ held="$held $l"
99
+ if [ -n "${2:-}" ] && maestro_on "$2"; then unclaim "$1"; return 1; fi
100
+ return 0
101
+ fi
102
+ owner=$(sed -n 1p "$l/owner" 2> /dev/null || true)
103
+ [ "$owner" != "$$" ] || return 0 # this run holds it already
104
+ # its run ended, or was stopped before it could say who it was
105
+ if { [ -n "$owner" ] && ! kill -0 "$owner" 2> /dev/null; } || { [ -z "$owner" ] && [ -n "$(find "$l" -maxdepth 0 -mmin +1 2> /dev/null)" ]; }; then
106
+ rm -f "$l/owner"
107
+ rmdir "$l" 2> /dev/null && { claim "$@"; return; }
108
+ fi
109
+ return 1
110
+ }
111
+ unclaim() { l=$(lock_path "$1"); rm -f "$l/owner"; rmdir "$l" 2> /dev/null || true; held=$(echo "$held" | sed "s| $l||"); }
112
+ release() { for l in $held; do rm -f "$l/owner"; rmdir "$l" 2> /dev/null || true; done; held=""; }
113
+ trap release EXIT
114
+ trap 'exit 130' INT TERM
115
+ holder() {
116
+ l=$(lock_path "$1")
117
+ if [ -f "$l/owner" ]; then echo "$(sed -n 2p "$l/owner") since $(sed -n 3p "$l/owner")"; else echo "another Maestro run"; fi
118
+ }
119
+ # claims $1 as claim does, waiting while it's in use (AMK_DEVICE_WAIT minutes, 30 by default); $3 names it in messages
120
+ claim_wait() {
121
+ claim "$1" "${2:-}" && return 0
122
+ echo " waiting for $3: in use by $(holder "$1")"
123
+ waited=0
124
+ until claim "$1" "${2:-}"; do
125
+ [ "$waited" -lt $((${AMK_DEVICE_WAIT:-30} * 60)) ] || { echo " gave up waiting for $3 after ${AMK_DEVICE_WAIT:-30} minutes"; return 1; }
126
+ sleep 5
127
+ waited=$((waited + 5))
128
+ done
129
+ }
130
+
80
131
  run_flow() { # screen device app_id file name orientation
81
132
  # Maestro's own log, which has errors its output leaves out; it adds to the file, so one run's log at a time
82
133
  debug="$evidence/maestro-logs/$1-$5"
@@ -100,9 +151,12 @@ run_flow() { # screen device app_id file name orientation
100
151
  return $rc
101
152
  }
102
153
 
103
- run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to turn it)
154
+ run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to turn it) [again]
104
155
  out="$evidence/$1"
105
156
  mkdir -p "$out"
157
+ # this run's screenshots are the ones newer than this; the status before it, for running the screen again
158
+ : > "$out/.started"
159
+ [ -n "${5:-}" ] || before=$status
106
160
  files=$(flow_files)
107
161
  if [ -z "$files" ]; then
108
162
  # launchApp returns before the app has drawn, and a splash screen stays up until the JavaScript has loaded:
@@ -117,8 +171,13 @@ run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to
117
171
  name=$(basename "$f" .yaml)
118
172
  ok=0
119
173
  run_flow "$1" "$2" "$3" "$f" "$name" "$4" || ok=$?
120
- # an emulator sometimes drops its adb connection for a moment: reconnect, then run the flow once more
121
- if [ "$ok" != 0 ] && [ "${1%%-*}" = android ] && grep -qs 'device offline' "$debug/maestro.log"; then
174
+ # Maestro now and then stops before a flow starts (it printed nothing), and an emulator sometimes drops its adb
175
+ # connection for a moment: run the flow once more (after reconnecting)
176
+ if [ "$ok" != 0 ] && [ ! -s "$out/$name.log" ]; then
177
+ echo " $1: Maestro stopped before flow $name started; running it once more"
178
+ ok=0
179
+ run_flow "$1" "$2" "$3" "$f" "$name" "$4" || ok=$?
180
+ elif [ "$ok" != 0 ] && [ "${1%%-*}" = android ] && grep -qs 'device offline' "$debug/maestro.log"; then
122
181
  echo " $1: the device went offline during flow $name; running it once more"
123
182
  "$adb" reconnect offline > /dev/null 2>&1 || true
124
183
  android_ready "$2" || true
@@ -140,11 +199,32 @@ run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to
140
199
  rm -f "$png.bmp"
141
200
  done ;;
142
201
  esac
202
+ # a screen checked in the wrong orientation would pass for another screen: a turned one's screenshots are wider than
203
+ # tall, an upright one's taller than wide. A device that didn't turn usually does the next time
204
+ case $1 in *-landscape) want=wide was=upright ;; *) want=tall was=turned ;; esac
205
+ wrong=$(find "$out" -name '*.png' -newer "$out/.started" | WANT=$want node -e '
206
+ const fs = require("fs");
207
+ for (const f of fs.readFileSync(0, "utf8").split("\n").filter(Boolean)) {
208
+ const b = Buffer.alloc(24), fd = fs.openSync(f, "r");
209
+ fs.readSync(fd, b, 0, 24, 0);
210
+ fs.closeSync(fd);
211
+ if ((b.readUInt32BE(16) > b.readUInt32BE(20)) !== (process.env.WANT === "wide")) console.log(f);
212
+ }' | wc -l | tr -d ' ')
213
+ if [ "$wrong" != 0 ] && [ -z "${5:-}" ]; then
214
+ echo " $1: $wrong screenshots show the screen $was, not as this screen needs; running its flows once more"
215
+ find "$out" -name '*.png' -newer "$out/.started" -exec rm -f {} +
216
+ status=$before
217
+ run_flows "$1" "$2" "$3" "$4" again
218
+ return
219
+ fi
143
220
  shots=$(find "$out" -name '*.png' | wc -l | tr -d ' ')
144
221
  echo "$1: flows $passed/$total passed, $shots screenshots in ${out#"$root"/}"
145
222
  if [ "$shots" = 0 ]; then
146
223
  echo " $1: no screenshots were saved, so there's no evidence; treating this as a failure"
147
224
  status=1
225
+ elif [ "$wrong" != 0 ]; then
226
+ echo " $1: $wrong screenshots show the screen $was: the device or the app didn't turn, so this screen isn't checked; treating this as a failure"
227
+ status=1
148
228
  fi
149
229
  }
150
230
 
@@ -153,6 +233,10 @@ run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to
153
233
  check_screens() { # platform phone tablet app_id screens…
154
234
  p=$1 phone=$2 tab=$3 id=$4
155
235
  shift 4
236
+ # before 2.6, two Maestro runs clash even on different devices (one port): checks on this machine take turns
237
+ if ! maestro_at_least 2.6.0; then
238
+ claim_wait maestro "" "Maestro (before 2.6 it runs one check at a time on this machine)" || { status=1; return; }
239
+ fi
156
240
  for screen in "$@"; do
157
241
  case $screen in
158
242
  tablet-*) [ -n "$tab" ] || continue; on=$tab where=$p-tablet ;;
@@ -174,6 +258,7 @@ check_screens() { # platform phone tablet app_id screens…
174
258
  fi
175
259
  run_flows "$where" "$on" "$id" "$turn"
176
260
  done
261
+ release # this platform's devices, and Maestro's turn, for other runs
177
262
  }
178
263
 
179
264
  quick() {
@@ -216,25 +301,30 @@ ios() {
216
301
  screens=$(screens_for ios)
217
302
  [ -n "$screens" ] || { echo "ios: none of the app's screens is $only"; return; }
218
303
  if echo "$screens" | grep -q '^phone-'; then
219
- device=$(simulator iPhone "${AMK_IOS_DEVICE:-}")
304
+ take_simulator iPhone "${AMK_IOS_DEVICE:-}" || { status=1; return; }
305
+ device=$taken
220
306
  if [ -z "$device" ]; then
221
307
  if [ -n "${AMK_IOS_DEVICE:-}" ]; then echo "ios: no simulator has the name or UDID \"$AMK_IOS_DEVICE\""; else echo "ios: no iPhone simulator found (set AMK_IOS_DEVICE)"; fi
222
308
  status=1; return
223
309
  fi
224
310
  fi
225
311
  if echo "$screens" | grep -q '^tablet-'; then
226
- tablet=$(simulator iPad "${AMK_IOS_TABLET:-}")
312
+ take_simulator iPad "${AMK_IOS_TABLET:-}" || { status=1; return; }
313
+ tablet=$taken
227
314
  if [ -z "$tablet" ] && [ -n "${AMK_IOS_TABLET:-}" ]; then echo "ios: no simulator has the name or UDID \"$AMK_IOS_TABLET\""; status=1; return; fi
228
315
  [ -n "$tablet" ] || echo "ios: the app runs on iPad, but there's no iPad simulator, so iPads aren't checked (add one in Xcode, or set AMK_IOS_TABLET)"
229
316
  fi
230
317
  for d in $device $tablet; do xcrun simctl boot "$d" 2> /dev/null || true; done
231
318
  fi
319
+ # one build of this project at a time; a check without its own build waits for one that's under way
320
+ claim_wait "build-ios-$project" "" "the iOS build of this project" || { status=1; return; }
232
321
  if [ "$no_build" = 0 ]; then
233
322
  if ! CONFIGURATION=Release sh scripts/amk/ios-build.sh > "$evidence/ios-build.log" 2>&1; then
234
323
  echo "ios: release build FAILED, see ${evidence#"$root"/}/ios-build.log"; status=1; return
235
324
  fi
236
- [ "$build_only" = 0 ] || { echo "ios: release build done"; return; }
237
325
  fi
326
+ unclaim "build-ios-$project"
327
+ [ "$build_only" = 0 ] || { echo "ios: release build done"; return; }
238
328
  # the newest app: the scheme just built (another scheme's app may still be there from an earlier build)
239
329
  app=$(ls -dt ios/DerivedData/Build/Products/*-iphonesimulator/*.app 2> /dev/null | head -n 1)
240
330
  [ -n "$app" ] || { echo "ios: there's no build to check yet: run sh scripts/amk/verify.sh build first"; status=1; return; }
@@ -246,18 +336,32 @@ ios() {
246
336
  check_screens ios "$device" "$tablet" "$app_id" $screens
247
337
  }
248
338
 
249
- # a simulator's UDID: the one named in $2 (name or UDID), else a booted $1 (iPhone or iPad), else one with the newest iOS
250
- simulator() {
339
+ # the simulators for $1 (iPhone or iPad), best first: the one named in $2 (name or UDID); else the booted ones,
340
+ # then the others, newest iOS first
341
+ simulators() {
251
342
  xcrun simctl list devices available -j | KIND=$1 WANT=$2 node -e '
252
343
  const all = Object.entries(JSON.parse(require("fs").readFileSync(0, "utf8")).devices)
253
344
  .flatMap(([rt, ds]) => ds.map(d => ({ ...d, v: (rt.match(/iOS-(\d+)-(\d+)/) || []).slice(1).map(Number) })))
254
345
  .filter(d => d.v.length);
255
346
  const want = process.env.WANT;
256
347
  // by device type: a simulator can have any name, such as a separate one kept for tests
257
- const kind = all.filter(d => (d.deviceTypeIdentifier || d.name).includes(process.env.KIND));
258
- const pick = want ? all.find(d => d.udid === want || d.name === want)
259
- : kind.find(d => d.state === "Booted") || kind.sort((a, b) => b.v[0] - a.v[0] || b.v[1] - a.v[1])[0];
260
- console.log(pick ? pick.udid : "");'
348
+ const kind = all.filter(d => (d.deviceTypeIdentifier || d.name).includes(process.env.KIND))
349
+ .sort((a, b) => (b.state === "Booted") - (a.state === "Booted") || b.v[0] - a.v[0] || b.v[1] - a.v[1]);
350
+ const list = want ? all.filter(d => d.udid === want || d.name === want).slice(0, 1) : kind;
351
+ console.log(list.map(d => d.udid).join("\n"));'
352
+ }
353
+ # a simulator for $1 (iPhone or iPad) that this run holds, in $taken: the one named in $2, once it's free; else the
354
+ # first free one; else the best one, once it's free. Empty when there's none
355
+ take_simulator() {
356
+ taken=""
357
+ candidates=$(simulators "$1" "$2")
358
+ [ -n "$candidates" ] || return 0
359
+ first=$(echo "$candidates" | head -n 1)
360
+ if [ -z "$2" ]; then
361
+ for u in $candidates; do claim "ios-$u" "$u" && { taken=$u; break; }; done
362
+ [ -z "$taken" ] || [ "$taken" = "$first" ] || echo "ios: $first is in use by $(holder "ios-$first"), so checking on $taken"
363
+ fi
364
+ [ -n "$taken" ] || { claim_wait "ios-$first" "$first" "the $1 simulator $first" || return 1; taken=$first; }
261
365
  }
262
366
 
263
367
  # a running emulator's adb serial: of the AVD named in $1 if one is, else of the kind in $2 (phone or tablet) if given
@@ -285,11 +389,42 @@ avd_width() {
285
389
  END { if (d) print int((w + 0 < h + 0 ? w : h) * 160 / d) }' \
286
390
  "${ANDROID_AVD_HOME:-${ANDROID_USER_HOME:-$HOME/.android}/avd}/$1.avd/config.ini" 2> /dev/null || true
287
391
  }
288
- # the first AVD of the kind $1 (phone or tablet)
289
- first_avd() {
290
- for a in $avds; do
291
- if [ "$(kind_of "$(avd_width "$a")")" = "$1" ]; then echo "$a"; return; fi
292
- done
392
+ # the emulators of the kind $1 (phone or tablet), best first: the running ones, then the others
393
+ emulators() {
394
+ {
395
+ for d in $("$adb" devices | awk 'NR > 1 && $2 == "device" && /^emulator-/ { print $1 }'); do
396
+ [ "$(kind_of "$(device_width "$d")")" != "$1" ] || "$adb" -s "$d" emu avd name 2> /dev/null | head -n 1 | tr -d '\r'
397
+ done
398
+ for a in $avds; do [ "$(kind_of "$(avd_width "$a")")" != "$1" ] || echo "$a"; done
399
+ } | awk 'NF && !seen[$0]++'
400
+ }
401
+ # an Android device of the kind $1 that this run holds, in $taken (its serial): the device ($2, an adb serial) or
402
+ # emulator ($3) named for it, once it's free; else the first free emulator of that kind, running or not; else the
403
+ # best one, once it's free. Empty when there's none of that kind. An emulator is claimed by its name, however named
404
+ take_android() {
405
+ taken="" pick=""
406
+ if [ -n "$2" ]; then
407
+ key=android-$2
408
+ case $2 in emulator-*) key=android-avd-$("$adb" -s "$2" emu avd name 2> /dev/null | head -n 1 | tr -d '\r') ;; esac
409
+ claim_wait "$key" "$2" "$2" || return 1
410
+ taken=$2
411
+ return 0
412
+ fi
413
+ if [ -n "$3" ]; then
414
+ echo "$avds" | grep -qxF "$3" || { echo "android: there's no emulator named $3 (see: emulator -list-avds)"; return 1; }
415
+ names=$3
416
+ else
417
+ names=$(emulators "$1")
418
+ fi
419
+ [ -n "$names" ] || return 0
420
+ first=$(echo "$names" | head -n 1)
421
+ if [ -z "$3" ]; then
422
+ for n in $names; do claim "android-avd-$n" "$(running_emulator "$n")" && { pick=$n; break; }; done
423
+ [ -z "$pick" ] || [ "$pick" = "$first" ] || echo "android: emulator $first is in use by $(holder "android-avd-$first"), so checking on $pick"
424
+ fi
425
+ [ -n "$pick" ] || { claim_wait "android-avd-$first" "$(running_emulator "$first")" "emulator $first" || return 1; pick=$first; }
426
+ taken=$(running_emulator "$pick")
427
+ [ -n "$taken" ] || taken=$(start_emulator "$pick") || { echo "android: emulator $pick didn't start"; return 1; }
293
428
  }
294
429
  # starts the AVD $1 and prints its serial once adb sees it (up to 5 minutes)
295
430
  start_emulator() {
@@ -350,19 +485,15 @@ android() {
350
485
  [ -n "$screens" ] || { echo "android: none of the app's screens is $only"; return; }
351
486
  avds=$("$sdk/emulator/emulator" -list-avds 2> /dev/null || true)
352
487
  if echo "$screens" | grep -q '^phone-'; then
353
- device=${AMK_ANDROID_DEVICE:-$(running_emulator "${AMK_ANDROID_AVD:-}" phone)}
488
+ take_android phone "${AMK_ANDROID_DEVICE:-}" "${AMK_ANDROID_AVD:-}" || { status=1; return; }
489
+ # only tablet emulators: one of them
490
+ [ -n "$taken" ] || take_android tablet "" "" || { status=1; return; }
491
+ device=$taken
354
492
  if [ -z "$device" ]; then
355
- avd=${AMK_ANDROID_AVD:-$(first_avd phone)}
356
- [ -n "$avd" ] || avd=$(echo "$avds" | head -n 1) # only tablet emulators: one of them
357
- if [ -n "$avd" ]; then
358
- echo "$avds" | grep -qxF "$avd" || { echo "android: there's no emulator named $avd (see: emulator -list-avds)"; status=1; return; }
359
- device=$(start_emulator "$avd") || { echo "android: emulator $avd didn't start"; status=1; return; }
360
- else
361
493
  phone=$("$adb" devices | awk 'NR > 1 && $2 == "device" { print $1; exit }')
362
494
  echo "android: no emulator found (create one in Android Studio)"
363
495
  [ -z "$phone" ] || echo " or check on the phone $phone, which clears the app's data on it: AMK_ANDROID_DEVICE=$phone sh scripts/amk/verify.sh android"
364
496
  status=1; return
365
- fi
366
497
  fi
367
498
  case $device in
368
499
  emulator-*) echo "android: checking on $device" ;;
@@ -370,17 +501,9 @@ android() {
370
501
  esac
371
502
  fi
372
503
  if echo "$screens" | grep -q '^tablet-'; then
373
- tablet=${AMK_ANDROID_TABLET:-$(running_emulator "${AMK_ANDROID_TABLET_AVD:-}" tablet)}
374
- if [ -z "$tablet" ]; then
375
- tablet_avd=${AMK_ANDROID_TABLET_AVD:-$(first_avd tablet)}
376
- if [ -z "$tablet_avd" ]; then
377
- echo "android: the app runs on tablets, but there's no tablet emulator, so tablets aren't checked (create one in Android Studio: Device Manager > Tablet, or set AMK_ANDROID_TABLET_AVD)"
378
- elif ! echo "$avds" | grep -qxF "$tablet_avd"; then
379
- echo "android: there's no emulator named $tablet_avd (see: emulator -list-avds)"; status=1; return
380
- else
381
- tablet=$(start_emulator "$tablet_avd") || { echo "android: emulator $tablet_avd didn't start, so tablets aren't checked"; tablet=""; }
382
- fi
383
- fi
504
+ take_android tablet "${AMK_ANDROID_TABLET:-}" "${AMK_ANDROID_TABLET_AVD:-}" || { status=1; return; }
505
+ tablet=$taken
506
+ [ -n "$tablet" ] || echo "android: the app runs on tablets, but there's no tablet emulator, so tablets aren't checked (create one in Android Studio: Device Manager > Tablet, or set AMK_ANDROID_TABLET_AVD)"
384
507
  [ "$tablet" != "$device" ] || tablet="" # only tablet emulators: the one in use is checked as the phone
385
508
  case $tablet in
386
509
  "") ;;
@@ -398,6 +521,8 @@ android() {
398
521
  sleep 2
399
522
  done
400
523
  fi
524
+ # one build of this project at a time; a check without its own build waits for one that's under way
525
+ claim_wait "build-android-$project" "" "the Android build of this project" || { status=1; return; }
401
526
  if [ "$no_build" = 0 ]; then
402
527
  # native code for that CPU type only, as run-android --active-arch-only does: much faster than all four
403
528
  set -- -PreactNativeArchitectures="$abi"
@@ -410,8 +535,9 @@ android() {
410
535
  if ! (cd android && ./gradlew "assemble${variant}Release" --no-daemon -q "$@") > "$evidence/android-build.log" 2>&1; then
411
536
  echo "android: release build FAILED, see ${evidence#"$root"/}/android-build.log"; status=1; return
412
537
  fi
413
- [ "$build_only" = 0 ] || { echo "android: release build done"; return; }
414
538
  fi
539
+ unclaim "build-android-$project"
540
+ [ "$build_only" = 0 ] || { echo "android: release build done"; return; }
415
541
  # apps that split APKs by CPU type get one per type: take this device's, else the universal one
416
542
  apks=$(ls android/app/build/outputs/apk/${flavor:+$flavor/}release/*.apk 2> /dev/null || true)
417
543
  [ -n "$apks" ] || { echo "android: there's no build to check yet: run sh scripts/amk/verify.sh build first"; status=1; return; }
@@ -446,10 +572,10 @@ build() {
446
572
  build_only=1
447
573
  ios_pid=""
448
574
  if [ "$(uname -s)" = Darwin ]; then
449
- (ios; exit $status) > "$evidence/build-ios.out" 2>&1 &
575
+ (trap release EXIT; ios; exit $status) > "$evidence/build-ios.out" 2>&1 &
450
576
  ios_pid=$!
451
577
  fi
452
- (android; exit $status) > "$evidence/build-android.out" 2>&1 &
578
+ (trap release EXIT; android; exit $status) > "$evidence/build-android.out" 2>&1 &
453
579
  android_pid=$!
454
580
  [ -z "$ios_pid" ] || wait "$ios_pid" || status=1
455
581
  wait "$android_pid" || status=1