Skip to content

Commit

Permalink
Added Github CI, bumped up dependency versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
zlogic committed May 10, 2024
1 parent 2f9fb73 commit cd7f661
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 4 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/cargo-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Cargo build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
validate:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4

- name: Get current Rust version
id: get-rust-version
run: echo VERSION=$(rustc --version | sed s/\ /_/g) >> "$GITHUB_OUTPUT"

- name: Cache Rust dependencies and artifacts
id: cache-rust
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
${{ github.workspace }}/target
key: lint-${{ runner.os }}-${{ steps.get-rust-version.outputs.VERSION }}-${{ hashFiles('Cargo.*') }}

- name: Validate Rust code with clippy
run: cargo clippy

build-linux:
# Older Ubuntu versions will link with an older GLIBC and provide better compatibility
runs-on: ubuntu-20.04
needs: validate
strategy:
fail-fast: true
matrix:
include:
- arch: x86_64
os: ubuntu
- arch: aarch64
os: ubuntu

steps:
- uses: actions/checkout@v4

- name: Get current Rust version
id: get-rust-version
run: echo VERSION=$(rustc --version | sed s/\ /_/g) >> "$GITHUB_OUTPUT"

- name: Cache Rust dependencies and artifacts
id: cache-rust
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
${{ github.workspace }}/target
key: rust-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-${{ steps.get-rust-version.outputs.VERSION }}-${{ hashFiles('Cargo.*') }}

- name: Install compiler and prepare for cross-compilation
if: matrix.arch == 'aarch64'
run: |
rustup target add ${{ matrix.arch }}-unknown-linux-gnu
sudo apt-get update
sudo apt-get install -y crossbuild-essential-arm64 qemu-user-static
echo "LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC=/usr/bin/aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=/usr/bin/aarch64-linux-gnu-g++" >> $GITHUB_ENV
echo "CFLAGS=-march=armv8.2-a" >> $GITHUB_ENV
echo "CXXFLAGS=-march=armv8.2-a" >> $GITHUB_ENV
- name: Build
run: cargo build --target=${{ matrix.arch }}-unknown-linux-gnu --release

- name: Package application
run: tar -cvjf hypno-toadface-${{ matrix.os }}-${{ matrix.arch }}.tar.bz2 -C target/${{ matrix.arch }}-unknown-linux-gnu/release hypno-toadface

- name: Upload application
uses: actions/upload-artifact@v4
with:
name: hypno-toadface-${{ matrix.os }}-${{ matrix.arch }}
path: hypno-toadface-*.tar.bz2

package:
runs-on: ubuntu-latest
needs: [ "build-linux" ]
steps:
- name: Merge all applications
uses: actions/upload-artifact/merge@v4
with:
name: hypno-toadface-all
pattern: hypno-toadface-*
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd7f661

Please sign in to comment.