github: add buildci and its helper script
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
33
.github/buildci.sh
vendored
Normal file
33
.github/buildci.sh
vendored
Normal 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"
|
||||||
|
}
|
||||||
41
.github/workflows/buildci.yml
vendored
Normal file
41
.github/workflows/buildci.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Build CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: [amd64, arm64]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout project
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup cross compiling
|
||||||
|
run: |
|
||||||
|
source ./.github/buildci.sh
|
||||||
|
setup_cross_compiling ${{ matrix.arch }}
|
||||||
|
|
||||||
|
- name: Format
|
||||||
|
run: cargo fmt -- --check
|
||||||
|
|
||||||
|
- name: Clippy
|
||||||
|
run: cargo clippy -- -Dwarnings
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
source ./.github/buildci.sh
|
||||||
|
build_for_arch ${{ matrix.arch }} ${GITHUB_SHA::7}
|
||||||
|
|
||||||
|
- name: Export artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: build-artifacts
|
||||||
|
path: artifacts
|
||||||
Reference in New Issue
Block a user