feat(ci): seperate build and setup jobs
This commit is contained in:
parent
6b0fad2509
commit
13a7170b25
1 changed files with 52 additions and 40 deletions
|
@ -5,29 +5,49 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
setup:
|
||||||
name: Build ${{ matrix.target }}
|
name: 🔧 Setup Environment
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
cache-hit: ${{ steps.cache-tools.outputs.cache-hit }}
|
||||||
|
steps:
|
||||||
|
- name: 📥 Checkout source
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
services:
|
- name: 🗄️ Cache tools
|
||||||
docker:
|
uses: https://github.com/actions/cache@v4
|
||||||
image: docker:dind
|
id: cache-tools
|
||||||
options: >-
|
with:
|
||||||
--privileged
|
path: |
|
||||||
--env DOCKER_TLS_CERTDIR=""
|
~/.cargo/bin
|
||||||
ports:
|
/tmp/zig
|
||||||
- 2375:2375
|
key: tools-v1-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: 🦀 Install Rust toolchain
|
||||||
|
uses: https://github.com/actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
components: rust-src
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: 📦 Install Zig and cargo-zigbuild
|
||||||
|
if: steps.cache-tools.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/zig
|
||||||
|
curl -L https://ziglang.org/builds/zig-linux-x86_64-0.11.0.tar.xz | tar -xJ -C /tmp/zig --strip-components=1
|
||||||
|
curl -L https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||||
|
cargo binstall -y cargo-zigbuild
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: 🏗️ Build ${{ matrix.target }}
|
||||||
|
needs: setup
|
||||||
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
target:
|
target:
|
||||||
- x86_64-unknown-linux-gnu
|
- x86_64-unknown-linux-gnu
|
||||||
- aarch64-unknown-linux-gnu
|
- aarch64-unknown-linux-gnu
|
||||||
- powerpc64le-unknown-linux-gnu
|
|
||||||
- s390x-unknown-linux-gnu
|
|
||||||
- riscv64gc-unknown-linux-gnu
|
|
||||||
- x86_64-pc-windows-gnu
|
|
||||||
- x86_64-pc-windows-msvc
|
- x86_64-pc-windows-msvc
|
||||||
include:
|
include:
|
||||||
- target: x86_64-unknown-linux-gnu
|
- target: x86_64-unknown-linux-gnu
|
||||||
|
@ -36,18 +56,6 @@ jobs:
|
||||||
- target: aarch64-unknown-linux-gnu
|
- target: aarch64-unknown-linux-gnu
|
||||||
binary_name: zenyx-aarch64-linux
|
binary_name: zenyx-aarch64-linux
|
||||||
ext: ""
|
ext: ""
|
||||||
- target: powerpc64le-unknown-linux-gnu
|
|
||||||
binary_name: zenyx-powerpc64le-linux
|
|
||||||
ext: ""
|
|
||||||
- target: s390x-unknown-linux-gnu
|
|
||||||
binary_name: zenyx-s390x-linux
|
|
||||||
ext: ""
|
|
||||||
- target: riscv64gc-unknown-linux-gnu
|
|
||||||
binary_name: zenyx-riscv64-linux
|
|
||||||
ext: ""
|
|
||||||
- target: x86_64-pc-windows-gnu
|
|
||||||
binary_name: zenyx-x86_64-windows-gnu.exe
|
|
||||||
ext: ".exe"
|
|
||||||
- target: x86_64-pc-windows-msvc
|
- target: x86_64-pc-windows-msvc
|
||||||
binary_name: zenyx-x86_64-windows-msvc.exe
|
binary_name: zenyx-x86_64-windows-msvc.exe
|
||||||
ext: ".exe"
|
ext: ".exe"
|
||||||
|
@ -56,33 +64,37 @@ jobs:
|
||||||
- name: 📥 Checkout source
|
- name: 📥 Checkout source
|
||||||
uses: https://github.com/actions/checkout@v4
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
- name: 🛠️ Install Rust toolchain
|
- name: 🗄️ Restore tool cache
|
||||||
|
uses: https://github.com/actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin
|
||||||
|
/tmp/zig
|
||||||
|
key: tools-v1-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: 📍 Add Zig to PATH
|
||||||
|
run: echo "/tmp/zig" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: 🎯 Install Rust target
|
||||||
uses: https://github.com/actions-rs/toolchain@v1
|
uses: https://github.com/actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
override: true
|
override: true
|
||||||
components: rust-src
|
|
||||||
|
|
||||||
- name: 🧩 Restore Cargo cache
|
- name: 🗄️ Restore Cargo cache
|
||||||
uses: https://github.com/actions/cache@v4
|
uses: https://github.com/actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
~/.cargo/git
|
~/.cargo/git
|
||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-cargo-${{ matrix.target }}-
|
cargo-${{ matrix.target }}-
|
||||||
|
|
||||||
- name: 🧰 Install Cross
|
- name: 🚀 Build release binary
|
||||||
run: cargo install cross --locked
|
run: cargo zigbuild --target ${{ matrix.target }} --release
|
||||||
|
|
||||||
- name: 🚀 Build with cross
|
|
||||||
env:
|
|
||||||
DOCKER_HOST: tcp://localhost:2375
|
|
||||||
CROSS_CONTAINER_IN_CONTAINER: true
|
|
||||||
run: cross build --target ${{ matrix.target }} --release
|
|
||||||
|
|
||||||
- name: 📦 Package artifact
|
- name: 📦 Package artifact
|
||||||
run: |
|
run: |
|
||||||
|
@ -93,4 +105,4 @@ jobs:
|
||||||
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.binary_name }}
|
name: ${{ matrix.binary_name }}
|
||||||
path: artifacts/${{ matrix.binary_name }}
|
path: artifacts/${{ matrix.binary_name }}
|
Loading…
Add table
Add a link
Reference in a new issue