Rust builder for Action on Linux.
Can be used for self-hosted runners on Linux.
x86_64-pc-windows-gnullvmaarch64-pc-windows-gnullvm
x86_64-unknown-linux-muslx86_64-unknown-linux-gnuaarch64-unknown-linux-muslaarch64-unknown-linux-gnuarmv7-unknown-linux-musleabihf
x86_64-apple-darwinaarch64-apple-darwin
Just specify jobs.<job_id>.container.image as android99/rust-action-builder.
name: Build
on:
push:
branches: [main]
workflow_dispatch: {}
jobs:
build:
name: Build ${{ matrix.os }} Platform
runs-on: ubuntu-latest
container:
image: android99/rust-action-builder
env:
TARGET: ${{ matrix.target }}
BINARY: ${{ matrix.binary }}
strategy:
matrix:
fail-fast: false
include:
- os: Windows
target: x86_64-pc-windows-gnullvm
binary: app.exe
artifact: app-windows-x86_64
- os: Linux
target: x86_64-unknown-linux-musl
binary: app
artifact: app-linux-x86_64
- os: macOS
target: universal-apple-darwin
binary: app
artifact: app-macos-universal
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build Binary
run: |
if [ "$TARGET" = universal-apple-darwin ]; then
cargo build -r --target x86_64-apple-darwin --target aarch64-apple-darwin
mkdir -p "target/$TARGET/release"
lipo -create \
"target/x86_64-apple-darwin/release/$BINARY" \
"target/aarch64-apple-darwin/release/$BINARY" \
-output "target/$TARGET/release/$BINARY"
else
cargo build -r --target "$TARGET"
fi
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: target/${{ matrix.target }}/release/${{ matrix.binary }}
if-no-files-found: error