Skip to content

ci: Add arch option to build.sh #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
name: Build and release x86_64 binaries
name: Build and release

on: [push]

jobs:
release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
if: contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
target: ["x86_64"]
target: ["x86_64", "aarch64"]
os: ["ubuntu18.04", "ubuntu20.04", "ubuntu22.04", "alpine"]
steps:
- uses: actions/checkout@v4

- name: Install QEMU
if: matrix.target == 'aarch64'
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
sudo update-binfmts --enable qemu-aarch64

- name: Build libbaihook
run: |
./build.sh ${{ matrix.os }}
./build.sh --arch ${{ matrix.target }} ${{ matrix.os }}

- name: Release to GitHub
uses: softprops/action-gh-release@v2
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/release_aarch64.yml

This file was deleted.

28 changes: 19 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@ usage() {
echo ""
echo "OPTIONS"
echo " -h, --help Show this help message and exit."
echo " --arch Specify the target architecture (default: uname -m)."
echo " --clean Run 'make clean' instead of 'make'."
echo " --force-cmake Force to re-run cmake to refresh build scripts."
}

ARCH=$(uname -m)

while [ $# -gt 0 ]; do
case $1 in
-h | --help) usage; exit 1 ;;
--force-cmake) FORCE_CMAKE=1 ;;
--clean) CLEAN=1 ;;
*)
break
--arch) ARCH=$2; shift;;
--arch=*) ARCH="${1#*=}" ;;
*) distro="$1"
esac
shift
done

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

docker build -t lablup/hook-dev:${distro_ver} -f Dockerfile.${distro_ver} .
if [ "$ARCH" = "aarch64" ]; then
echo '{ "experimental": true }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
fi

docker build --platform=linux/${ARCH} -t lablup/hook-dev:${distro_ver} -f Dockerfile.${distro_ver} .

docker_run="docker run --rm ${git_fix} -v "$(pwd):/root" -u ${user} -w=/root lablup/hook-dev:${distro_ver} /bin/sh -c"

if [ "$FORCE_CMAKE" -eq 1 -o ! -f "Makefile" ]; then
Expand All @@ -68,9 +78,9 @@ if [ "$CLEAN" -eq 1 ]; then
$docker_run 'make clean'
rm -r CMakeFiles googletest-build googletest-download CMakeCache.txt cmake_install.cmake Makefile
else
echo ">> Building for ${distro} ${arch} ..."
echo ">> Building for ${distro} ${ARCH} ..."
$docker_run 'make'
cp "baihook/libbaihook.so" "libbaihook.${distro_ver}.${arch}.so"
cp "test/test-hook" "test-hook.${distro_ver}.${arch}.bin"
cp "test/test-hooked" "test-hooked.${distro_ver}.${arch}.bin"
cp "baihook/libbaihook.so" "libbaihook.${distro_ver}.${ARCH}.so"
cp "test/test-hook" "test-hook.${distro_ver}.${ARCH}.bin"
cp "test/test-hooked" "test-hooked.${distro_ver}.${ARCH}.bin"
fi