github: add buildci and its helper script

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2022-01-20 04:33:33 +05:30
parent 689db9548a
commit 3968796a49
2 changed files with 74 additions and 0 deletions

33
.github/buildci.sh vendored Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
set -xe
# Setup cross compiling for arm64
setup_cross_compiling() {
__ARCH=$1
if [ "$__ARCH" == "arm64" ]; then
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-gnu
fi
}
# Building for the given architecture
build_for_arch() {
__ARCH=$1
__SHA=$2
# Statically compile
case "$__ARCH" in \
arm64) export __TARGET='aarch64-unknown-linux-gnu' ;;
amd64) export __TARGET='x86_64-unknown-linux-gnu' ;;
esac
# Build and install
cargo install --target $__TARGET --path .
# Export them artifacts
mkdir -p artifacts
cp -av /home/runner/.cargo/bin/bin "artifacts/bin-$__SHA-$__TARGET"
}