summaryrefslogtreecommitdiff
path: root/docker/scripts/package.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docker/scripts/package.sh')
-rwxr-xr-xdocker/scripts/package.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/docker/scripts/package.sh b/docker/scripts/package.sh
new file mode 100755
index 0000000..8d58e39
--- /dev/null
+++ b/docker/scripts/package.sh
@@ -0,0 +1,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/"