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: jobs:
build: build:
runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- os: linux - target: x86_64-unknown-linux-gnu
runs-on: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary: ccsm binary: ccsm
archive: ccsm-linux-amd64.tar.gz archive: ccsm-linux-amd64.tar.gz
- os: macos - target: x86_64-apple-darwin
runs-on: macos-latest
target: x86_64-apple-darwin
binary: ccsm binary: ccsm
archive: ccsm-darwin-amd64.tar.gz archive: ccsm-darwin-amd64.tar.gz
- os: windows - target: x86_64-pc-windows-gnu
runs-on: windows-latest
target: x86_64-pc-windows-msvc
binary: ccsm.exe binary: ccsm.exe
archive: ccsm-windows-amd64.zip archive: ccsm-windows-amd64.zip
runs-on: ${{ matrix.runs-on }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Rust toolchain - name: Install Rust
uses: https://gitea.com/actions/rust-toolchain@v1 run: rustup update stable && rustup default stable
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Build - name: Build (Linux)
run: cargo build --release --target ${{ matrix.target }} if: matrix.target == 'x86_64-unknown-linux-gnu'
run: cargo build --release
- name: Package (linux / macos) - name: Install cross
if: matrix.os != 'windows' 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: | run: |
cd target/${{ matrix.target }}/release cd "target/${{ matrix.target }}/release"
tar czf ${{ matrix.archive }} ${{ matrix.binary }} if [[ "${{ matrix.target }}" == *-windows-* ]]; then
zip "${{ matrix.archive }}" "${{ matrix.binary }}"
- name: Package (windows) else
if: matrix.os == 'windows' tar czf "${{ matrix.archive }}" "${{ matrix.binary }}"
run: | fi
cd target\${{ matrix.target }}\release
7z a ${{ matrix.archive }} ${{ matrix.binary }}
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ccsm-${{ matrix.os }}-amd64 name: ${{ matrix.archive }}
path: target/${{ matrix.target }}/release/${{ matrix.archive }} path: target/${{ matrix.target }}/release/${{ matrix.archive }}