feat:rework ci/cd to use cargo-cross

This commit is contained in:
Chance 2025-04-11 13:42:20 -04:00 committed by BitSyndicate
parent 655a5607fe
commit 2aa5f2157a

View file

@ -2,15 +2,15 @@ name: Build Zenyx ⚡
on:
push:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-pc-windows-gnu
@ -18,71 +18,43 @@ jobs:
include:
- target: x86_64-unknown-linux-gnu
binary_name: zenyx-x86_64-linux
deps: libwayland-dev wayland-protocols
pkg_config: ""
triple: x86_64-linux-gnu
binary_extension: ""
ext: ""
- target: aarch64-unknown-linux-gnu
binary_name: zenyx-aarch64-linux
deps: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libwayland-dev:arm64 wayland-protocols
pkg_config: aarch64-linux-gnu-pkg-config
triple: aarch64-linux-gnu
binary_extension: ""
ext: ""
- target: x86_64-pc-windows-gnu
binary_name: zenyx-x86_64-windows.exe
deps: mingw-w64
pkg_config: x86_64-w64-mingw32-pkg-config
triple: x86_64-w64-mingw32
binary_extension: ".exe"
ext: ".exe"
- target: aarch64-apple-darwin
binary_name: zenyx-aarch64-apple
ext: ""
runs-on: ubuntu-latest
steps:
- name: 📥 Clone repository
- name: 📥 Checkout source
uses: actions/checkout@v4
- name: 🛠️ Install dependencies
run: |
apt-get update
apt-get install -y \
${{ matrix.deps }} \
pkg-config \
${{ matrix.pkg_config }}
- name: 🔧 Setup pkg-config
if: matrix.pkg_config != ''
run: |
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/${{ matrix.triple }}/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_SYSROOT_DIR=/usr/${{ matrix.triple }}" >> $GITHUB_ENV
- name: 🦀 Install Rust target
uses: https://github.com/actions-rs/toolchain@v1
- name: 🛠️ Install Rust toolchain
uses: https://github.com/actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: 🏗️ Build
- name: 🚀 Build with cross
uses: https://github.com/actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
env:
CARGO_TARGET_${{ matrix.target }}_LINKER: ${{ matrix.triple }}-gcc
PKG_CONFIG_ALLOW_CROSS: 1
PKG_CONFIG_PATH: /usr/lib/${{ matrix.triple }}/pkgconfig
PKG_CONFIG_SYSROOT_DIR: /usr/${{ matrix.triple }}
args: --target ${{ matrix.target }}
- name: 📦 Package artifact
run: |
mkdir -p artifacts
cp target/${{ matrix.target }}/release/zenyx${{ matrix.binary_extension }} artifacts/${{ matrix.binary_name }}
cp target/${{ matrix.target }}/debug/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }}
chmod +x artifacts/${{ matrix.binary_name }}
- name: ⬆️ Upload artifact
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
uses: code.forgejo.org/forgejo/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: artifacts/${{ matrix.binary_name }}
path: artifacts/${{ matrix.binary_name }}