---
name: Test & Build
on:
push:
branches:
- '*'
workflow_dispatch:
permissions:
contents: write
jobs:
test:
uses: ./.github/workflows/test.yml
coverage:
uses: ./.github/workflows/coverage.yml
secrets: inherit
build:
name: Build
runs-on: ${{ matrix.os }}
needs:
- test
strategy:
matrix:
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Get package name from Cargo.toml
id: package
shell: bash
run: |
PACKAGE_NAME=$(awk -F '"' '/^name = / {print $2; exit}' Cargo.toml)
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "Package name: $PACKAGE_NAME"
- name: Branch name
run: echo "${GITHUB_REF##*/}"
- name: Get the release version from the tag
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system deps (musl)
if: matrix.build == 'linux'
run: |
sudo apt-get update -y
sudo apt-get install -y musl-dev musl-tools
- name: Build zlib for musl
if: matrix.build == 'linux'
run: |
curl -fsSL https://zlib.net/fossils/zlib-1.3.1.tar.gz -o /tmp/zlib-1.3.1.tar.gz
rm -rf /tmp/zlib-src /tmp/musl-zlib
mkdir -p /tmp/zlib-src /tmp/musl-zlib
tar -xf /tmp/zlib-1.3.1.tar.gz -C /tmp/zlib-src --strip-components=1
(
cd /tmp/zlib-src
CC=musl-gcc ./configure --prefix=/tmp/musl-zlib --static
make -j"$(nproc)"
make install
)
{
echo 'PKG_CONFIG_ALLOW_CROSS=1'
echo 'PKG_CONFIG_PATH=/tmp/musl-zlib/lib/pkgconfig'
echo 'CFLAGS_x86_64_unknown_linux_musl=-I/tmp/musl-zlib/include'
echo 'LIBRARY_PATH=/tmp/musl-zlib/lib'
} >> "$GITHUB_ENV"
- name: Build (Linux musl)
if: matrix.build == 'linux'
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Build
if: matrix.build != 'linux'
run: cargo build --release --locked --target ${{ matrix.target }}