Specify targets in RustlerPrecompiled config (#5) #12
Workflow file for this run
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: Compile & Upload NIFs | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "native/**" | |
- ".github/workflows/release.yml" | |
tags: | |
- "*" | |
pull_request: | |
paths: | |
- ".github/workflows/release.yml" | |
workflow_dispatch: | |
jobs: | |
compile_nifs: | |
name: ${{ matrix.job.platform }} (NIF ${{ matrix.nif }}) | |
runs-on: ${{ matrix.job.os }} | |
permissions: | |
contents: write | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
nif: ["2.16"] | |
job: | |
- { target: aarch64-apple-darwin, os: macos-13, platform: "macOS (ARM64)" } | |
- { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true, platform: "Linux (ARM64)" } | |
- { target: x86_64-apple-darwin, os: macos-13, platform: "macOS (x86_64)" } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, platform: "Linux (x86_64)" } | |
env: | |
EXSTATIC_BUILD: true # Ensure RustlerPrecompiled forces a build | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
targets: ${{ matrix.job.target }} | |
- name: Install Cross for cross-compilation | |
if: ${{ matrix.job.use-cross }} | |
run: cargo install cross --git https://github.com/cross-rs/cross | |
- name: Extract project version | |
shell: bash | |
run: | | |
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: v0-precomp | |
shared-key: ${{ matrix.job.target }}-${{ matrix.nif }} | |
workspaces: | | |
native/exstatic | |
- name: Compile the NIFs | |
id: build-crate | |
uses: philss/rustler-precompiled-action@v1.1.4 | |
with: | |
project-name: exstatic | |
project-version: ${{ env.PROJECT_VERSION }} | |
target: ${{ matrix.job.target }} | |
nif-version: ${{ matrix.nif }} | |
use-cross: ${{ matrix.job.use-cross }} | |
project-dir: "native/exstatic" | |
- name: Upload compiled NIF artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build-crate.outputs.file-name }} | |
path: ${{ steps.build-crate.outputs.file-path }} | |
- name: Publish NIFs to GitHub Releases | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
${{ steps.build-crate.outputs.file-path }} | |
if: startsWith(github.ref, 'refs/tags/') |