aboutsummaryrefslogtreecommitdiff
path: root/docker/scripts/package.sh
blob: 8d58e399df749b93bbf9eb5311ea3d3834394292 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Author:  cirakg & claude ai
# Summary: Build the signed .iq package for the Connect IQ Store beta, plus release .prg files for sideload tests.
#
# Usage:   package.sh [DEVICE ...]      (devices for the .prg files; default: TEST_DEVICES)
# Output:  build/package/otp-wallet-<version>.iq   all 72 products, release, signed
#          build/package/prg/<DEVICE>.prg          release builds for sideload tests
#
# The .iq is what you upload as a beta app (README section 4). It is built
# with the same strict settings as every other build: type check level 3 and
# no compiler warnings.
set -euo pipefail
# shellcheck source=ciq-env.sh
source "$(dirname "${BASH_SOURCE[0]}")/ciq-env.sh"

ciq_require_sdk
ciq_require_key

version="$(sed -n 's/^ *const VERSION = "\([0-9.]*\)";.*/\1/p' /work/source/app/AppInfo.mc)"
[[ -n "${version}" ]] || die "could not read VERSION from source/app/AppInfo.mc"

out="${BUILD_DIR}/package"
mkdir -p "${out}/prg"
iq="${out}/otp-wallet-${version}.iq"
compile_log="${out}/otp-wallet-${version}.log"

log "exporting ${iq#/work/} for every product in manifest.xml (this takes a while)"
if ! monkeyc -e -r -f "/work/monkey.jungle;/work/icons.jungle" -o "${iq}" -y "${DEV_KEY}" -l 3 -w \
  >"${compile_log}" 2>&1; then
  cat "${compile_log}" >&2
  die "packaging failed"
fi
if grep -q "^WARNING" "${compile_log}"; then
  grep "^WARNING" "${compile_log}" >&2
  die "compiler warnings while packaging; warnings count as errors"
fi

devices=("$@")
((${#devices[@]} > 0)) || read -r -a devices <<<"${TEST_DEVICES:-}"
for device in "${devices[@]}"; do
  build-app.sh release "${device}"
  cp "${BUILD_DIR}/release/${device}.prg" "${out}/prg/${device}.prg"
done

log "package ready: ${iq#/work/} ($(du -h "${iq}" | cut -f1)); release .prg files in build/package/prg/"