ci: switch to cross-rs for cross-compilation

This commit is contained in:
2026-06-18 17:36:44 +08:00
parent 23af3f9c1d
commit cfc20d4b89
+25 -29
View File
@@ -9,54 +9,50 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: linux
runs-on: ubuntu-latest
target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-gnu
binary: ccsm
archive: ccsm-linux-amd64.tar.gz
- os: macos
runs-on: macos-latest
target: x86_64-apple-darwin
- target: x86_64-apple-darwin
binary: ccsm
archive: ccsm-darwin-amd64.tar.gz
- os: windows
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- target: x86_64-pc-windows-gnu
binary: ccsm.exe
archive: ccsm-windows-amd64.zip
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: https://gitea.com/actions/rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Install Rust
run: rustup update stable && rustup default stable
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Build (Linux)
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: cargo build --release
- name: Package (linux / macos)
if: matrix.os != 'windows'
- name: Install cross
if: matrix.target != 'x86_64-unknown-linux-gnu'
run: cargo install cross --locked
- name: Build with cross
if: matrix.target != 'x86_64-unknown-linux-gnu'
run: cross build --release --target ${{ matrix.target }}
- name: Package
run: |
cd target/${{ matrix.target }}/release
tar czf ${{ matrix.archive }} ${{ matrix.binary }}
- name: Package (windows)
if: matrix.os == 'windows'
run: |
cd target\${{ matrix.target }}\release
7z a ${{ matrix.archive }} ${{ matrix.binary }}
cd "target/${{ matrix.target }}/release"
if [[ "${{ matrix.target }}" == *-windows-* ]]; then
zip "${{ matrix.archive }}" "${{ matrix.binary }}"
else
tar czf "${{ matrix.archive }}" "${{ matrix.binary }}"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ccsm-${{ matrix.os }}-amd64
name: ${{ matrix.archive }}
path: target/${{ matrix.target }}/release/${{ matrix.archive }}