@@ -5,7 +5,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55REPO_DIR=" ${SCRIPT_DIR} /nanobot"
66GITHUB_REPO=" HKUDS/nanobot"
77
8- # ── 1. Parse target platform and python version arguments ─────────────────────
8+ # Parse target platform and python version arguments
99if [ $# -lt 2 ]; then
1010 echo " Usage: $0 <platform> <python-version>" >&2
1111 echo " e.g. $0 armv7 3.11" >&2
@@ -16,7 +16,7 @@ PLATFORM="$1"
1616PY_VERSION=" $2 "
1717PY_VERSION_NODOT=" ${PY_VERSION// ./ } "
1818
19- # ── Pre-flight checks ────────────────────────────────────────────────────────
19+ # Pre-flight checks
2020if ! command -v docker > /dev/null 2>&1 ; then
2121 echo " Error: docker is required." >&2
2222 exit 1
@@ -27,7 +27,15 @@ if ! docker buildx version >/dev/null 2>&1; then
2727 exit 1
2828fi
2929
30- # ── 2. Find latest release version from GitHub ───────────────────────────────
30+ # Ensure a buildx builder with cross-platform support exists
31+ BUILDER_NAME=" nanobot-multiarch"
32+ if ! docker buildx inspect " $BUILDER_NAME " > /dev/null 2>&1 ; then
33+ echo " ==> Creating buildx builder '${BUILDER_NAME} ' with QEMU support ..."
34+ docker buildx create --name " $BUILDER_NAME " --driver docker-container --bootstrap
35+ fi
36+ docker buildx use " $BUILDER_NAME "
37+
38+ # Find latest release version from GitHub
3139echo " ==> Fetching latest release from github.com/${GITHUB_REPO} ..."
3240
3341CURL_OPTS=(-fsSL)
4856
4957echo " Latest release : $LATEST_VERSION "
5058
51- # ── 3. Compare with current version ──────────────────────────────────────────
59+ # Compare with current version
5260CURRENT_VERSION=" ${NANOBOT_VERSION_CURRENT:- } "
5361echo " Current version: ${CURRENT_VERSION:- <not set>} "
5462
@@ -57,9 +65,9 @@ if [ "$LATEST_VERSION" = "$CURRENT_VERSION" ]; then
5765 exit 0
5866fi
5967
60- echo " ==> Version differs – proceeding with download and build."
68+ echo " ==> Version differs - proceeding with download and build."
6169
62- # ── 4. Download and extract the latest release ───────────────────────────────
70+ # Download and extract the latest release
6371TARBALL_URL=" https://github.com/${GITHUB_REPO} /archive/refs/tags/${LATEST_VERSION} .tar.gz"
6472DOWNLOAD_DIR=" ${SCRIPT_DIR} /downloads"
6573TARBALL_PATH=" ${DOWNLOAD_DIR} /${LATEST_VERSION} .tar.gz"
@@ -74,7 +82,7 @@ rm -rf "$REPO_DIR"
7482mkdir -p " $REPO_DIR "
7583tar -xzf " $TARBALL_PATH " -C " $REPO_DIR " --strip-components=1
7684
77- # ── 5. Build the Python wheelhouse for the specified platform ─────────────────
85+ # Build the Python wheelhouse for the specified platform
7886EXTRAS=" ${EXTRAS:- } "
7987OUT_DIR=" ${SCRIPT_DIR} /dist/${PLATFORM} -py${PY_VERSION_NODOT} -wheelhouse"
8088
@@ -111,7 +119,7 @@ docker buildx build \
111119 --output " type=local,dest=$OUT_DIR " \
112120 " $REPO_DIR "
113121
114- # buildx local output keeps stage root; wheelhouse will be under $OUT_DIR/wheelhouse
122+ # Check if wheelhouse was generated
115123WHEEL_DIR=" $OUT_DIR /wheelhouse"
116124if [ ! -d " $WHEEL_DIR " ]; then
117125 echo " Error: wheelhouse output not found at $WHEEL_DIR " >&2
0 commit comments