Skip to content

Integrate RustlerPrecompiled for Precompiled NIFs & CI/CD Enhancements #4

Integrate RustlerPrecompiled for Precompiled NIFs & CI/CD Enhancements

Integrate RustlerPrecompiled for Precompiled NIFs & CI/CD Enhancements #4

Workflow file for this run

name: Build Precompiled NIFs
on:
push:
branches:
- main
paths:
- "native/**"
- ".github/workflows/release.yml"
tags:
- "*"
pull_request:
paths:
- ".github/workflows/release.yml"
workflow_dispatch:
jobs:
build_release:
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
permissions:
contents: write
id-token: write
attestations: write
strategy:
fail-fast: false
matrix:
nif: ["2.16"] # Only build for OTP 26 and 27
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 (needed for linux ARM64 target)
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: Build the project
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: Artifact attestation (security verification)
uses: actions/attest-build-provenance@v1
with:
subject-path: ${{ steps.build-crate.outputs.file-path }}
- name: Upload NIF artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build-crate.outputs.file-name }}
path: ${{ steps.build-crate.outputs.file-path }}
- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.build-crate.outputs.file-path }}
if: startsWith(github.ref, 'refs/tags/')