add install script and readme #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- "*" | |
env: | |
RUSTC_WRAPPER: sccache | |
SCCACHE_GHA_ENABLED: true | |
SCCACHE_CACHE_SIZE: 2G | |
SCCACHE_DIR: /home/runner/.cache/sccache | |
jobs: | |
build: | |
name: Build for ${{ matrix.target }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# Tier 1 Platforms | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
artifact_name: bping | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
artifact_name: bping.exe | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
artifact_name: bping | |
- target: i686-pc-windows-msvc | |
os: windows-latest | |
artifact_name: bping.exe | |
- target: i686-unknown-linux-gnu | |
os: ubuntu-latest | |
artifact_name: bping | |
gcc_package: gcc-multilib | |
# Tier 2 Platforms | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
artifact_name: bping | |
gcc_package: gcc-aarch64-linux-gnu | |
linker: aarch64-linux-gnu-gcc | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
artifact_name: bping | |
- target: arm-unknown-linux-gnueabi | |
os: ubuntu-latest | |
artifact_name: bping | |
gcc_package: gcc-arm-linux-gnueabi | |
linker: arm-linux-gnueabi-gcc | |
- target: armv7-unknown-linux-gnueabihf | |
os: ubuntu-latest | |
artifact_name: bping | |
gcc_package: gcc-arm-linux-gnueabihf | |
linker: arm-linux-gnueabihf-gcc | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
artifact_name: bping | |
gcc_package: musl-tools | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install build dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y curl build-essential pkg-config libssl-dev | |
if [ ! -z "${{ matrix.gcc_package }}" ]; then | |
sudo apt-get install -y ${{ matrix.gcc_package }} | |
fi | |
- name: Configure Cargo for cross-compilation | |
if: matrix.linker != '' | |
run: | | |
mkdir -p ~/.cargo | |
echo "[target.${{ matrix.target }}]" >> ~/.cargo/config.toml | |
echo "linker = \"${{ matrix.linker }}\"" >> ~/.cargo/config.toml | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Configure sccache | |
run: | | |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV | |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "v1-rust" | |
shared-key: "${{ matrix.target }}-build" | |
cache-targets: "true" | |
cache-on-failure: "true" | |
cache-all-crates: "true" | |
save-if: ${{ github.ref == 'refs/heads/master' }} | |
workspaces: | | |
. -> target | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Show sccache stats | |
run: sccache --show-stats | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.target }}-binary | |
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} |