Skip to content

只打包对应平台库而非 target 目录,以减小体积 #4

只打包对应平台库而非 target 目录,以减小体积

只打包对应平台库而非 target 目录,以减小体积 #4

Workflow file for this run

name: Build easytier-ffi
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
strategy:
matrix:
include:
# Linux targets - dynamic libraries (.so)
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
lib_pattern: "*.so"
- target: i686-unknown-linux-gnu
os: ubuntu-latest
lib_pattern: "*.so"
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
lib_pattern: "*.so"
# Windows targets - dynamic libraries (.dll)
- target: x86_64-pc-windows-msvc
os: windows-latest
lib_pattern: "*.dll"
- target: i686-pc-windows-msvc
os: windows-latest
lib_pattern: "*.dll"
- target: aarch64-pc-windows-msvc
os: windows-latest
lib_pattern: "*.dll"
# macOS targets - dynamic libraries (.dylib)
- target: x86_64-apple-darwin
os: macos-latest
lib_pattern: "*.dylib"
- target: aarch64-apple-darwin
os: macos-latest
lib_pattern: "*.dylib"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Install protoc
uses: arduino/setup-protoc@v1
with:
version: '3.20.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install cross-compilation dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
case "${{ matrix.target }}" in
i686-unknown-linux-gnu)
sudo apt-get install -y gcc-multilib
;;
aarch64-unknown-linux-gnu)
sudo apt-get install -y gcc-aarch64-linux-gnu
;;
esac
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Build package
run: cargo build --package easytier-ffi --release --target ${{ matrix.target }}
- name: Find and list dynamic libraries
run: |
echo "Looking for dynamic libraries in target/${{ matrix.target }}/release/"
find target/${{ matrix.target }}/release/ -name "${{ matrix.lib_pattern }}" -type f | while read file; do
echo "Found: $file"
ls -la "$file"
done
- name: Upload dynamic libraries
uses: actions/upload-artifact@v4
with:
name: easytier-ffi-${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ matrix.lib_pattern }}
retention-days: 7
if-no-files-found: error