Skip to content

Commit fe9866b

Browse files
committed
ci: Add arch option to build.sh
1 parent 7d49ffd commit fe9866b

File tree

3 files changed

+25
-41
lines changed

3 files changed

+25
-41
lines changed

.github/workflows/release_x86_64.yml renamed to .github/workflows/release.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and release x86_64 binaries
1+
name: Build and release
22

33
on: [push]
44

@@ -8,14 +8,22 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
target: ["x86_64"]
11+
target: ["x86_64", "aarch64"]
1212
os: ["ubuntu18.04", "ubuntu20.04", "ubuntu22.04", "alpine"]
1313
steps:
1414
- uses: actions/checkout@v4
1515

16+
- name: Install QEMU
17+
if: matrix.target == 'aarch64'
18+
run: |
19+
sudo apt-get update
20+
sudo apt-get install -y qemu-user-static
21+
sudo update-binfmts --enable qemu-arm
22+
sudo update-binfmts --enable qemu-aarch64
23+
1624
- name: Build libbaihook
1725
run: |
18-
./build.sh ${{ matrix.os }}
26+
./build.sh --arch ${{ matrix.target }} ${{ matrix.os }}
1927
2028
- name: Release to GitHub
2129
uses: softprops/action-gh-release@v2

.github/workflows/release_aarch64.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

build.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,27 @@ usage() {
1414
echo ""
1515
echo "OPTIONS"
1616
echo " -h, --help Show this help message and exit."
17+
echo " --arch Specify the target architecture (default: uname -m)."
1718
echo " --clean Run 'make clean' instead of 'make'."
1819
echo " --force-cmake Force to re-run cmake to refresh build scripts."
1920
}
2021

22+
arch=$(uname -m)
23+
2124
while [ $# -gt 0 ]; do
2225
case $1 in
2326
-h | --help) usage; exit 1 ;;
2427
--force-cmake) FORCE_CMAKE=1 ;;
2528
--clean) CLEAN=1 ;;
29+
--arch) shift; arch=$1 ;;
2630
*)
2731
break
2832
esac
2933
shift
3034
done
3135

3236
distro="$1"
33-
arch="$(uname -m)"
37+
3438
case $distro in
3539
ubuntu22.04)
3640
distro="ubuntu"
@@ -56,7 +60,15 @@ user="$(id -u):$(id -g)"
5660
# to prevent "fatal: unable to look up current user in the passwd file: no such user" error from git
5761
git_fix="-e GIT_COMMITTER_NAME=devops -e [email protected]"
5862

59-
docker build -t lablup/hook-dev:${distro_ver} -f Dockerfile.${distro_ver} .
63+
if [ "$arch" = "aarch64" ]; then
64+
echo '{ "experimental": true }' | sudo tee /etc/docker/daemon.json
65+
sudo systemctl restart docker
66+
67+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
68+
fi
69+
70+
docker build --platform=linux/${arch} -t lablup/hook-dev:${distro_ver} -f Dockerfile.${distro_ver} .
71+
6072
docker_run="docker run --rm ${git_fix} -v "$(pwd):/root" -u ${user} -w=/root lablup/hook-dev:${distro_ver} /bin/sh -c"
6173

6274
if [ "$FORCE_CMAKE" -eq 1 -o ! -f "Makefile" ]; then

0 commit comments

Comments
 (0)