Skip to content

feat: musl build of ffi engine #24

feat: musl build of ffi engine

feat: musl build of ffi engine #24

name: Package FFI Engine
on:
pull_request:
branches: ["main"]
push:
tags: ["flipt-engine-ffi-v**"]
workflow_dispatch:
inputs:
tag:
description: "Tag (e.g. v0.1.0)"
required: true
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: Linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- name: Linux-x86_64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- name: Linux-arm64-musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
- name: Darwin-arm64
os: macos-latest
target: aarch64-apple-darwin
- name: Darwin-x86_64
os: macos-latest
target: x86_64-apple-darwin
runs-on: ${{ matrix.platform.os }}
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.platform.target}}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install and configure dependencies
run: |
if [[ "${{ matrix.platform.os }}" =~ ^ubuntu.*$ ]]; then
sudo apt-get install -qq musl-tools musl-dev crossbuild-essential-arm64
fi
cat >>~/.cargo/config <<EOF
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
EOF
- name: Install rust target
run: |
rustup update
rustup target add ${{ matrix.platform.target }}
- name: Run build
run: |
if [[ "${{ matrix.platform.target }}" == *-musl* ]]; then
export RUSTFLAGS="-C target-feature=-crt-static"
fi
cargo build -p flipt-engine-ffi --release --target ${{ matrix.platform.target }}
- if: startsWith(matrix.platform.name, 'Darwin')
run: |
strip -x target/${{ matrix.platform.target }}/release/libfliptengine.dylib
- if: matrix.platform.name == 'Linux-x86_64'
run: |
strip -x target/${{ matrix.platform.target }}/release/libfliptengine.so
- run: |
tar -czvf flipt-engine-ffi-${{ matrix.platform.name }}.tar.gz \
target/${{ matrix.platform.target }}/release/libfliptengine.* \
|| true
- name: Upload Artifacts (Pull Request)
uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: flipt-engine-ffi-${{ matrix.platform.name }}
path: flipt-engine-ffi-${{ matrix.platform.name }}.tar.gz
- name: Upload Release Assets (Tag)
uses: softprops/action-gh-release@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
tag_name: ${{ github.ref_name }}
files: |
flipt-engine-ffi-${{ matrix.platform.name }}.tar.gz
- name: Upload Release Assets (Workflow Dispatch)
uses: softprops/action-gh-release@v2
if: github.event_name == 'workflow_dispatch' && !endswith(github.event.inputs.tag, 'pre')
with:
tag_name: flipt-engine-ffi-${{ github.event.inputs.tag }}
files: |
flipt-engine-ffi-${{ matrix.platform.name }}.tar.gz