Skip to content

Commit

Permalink
chore: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dundunHa committed Dec 22, 2024
1 parent bed1282 commit 81aa5ff
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
push:
branches: [ "main" ]
tags:
- 'v*' # 当推送版本标签时触发,如 v1.0.0
- 'v*'
pull_request:
branches: [ "main" ]

permissions:
contents: write # 这给予了创建 release 的权限
contents: write
packages: write
pull-requests: write

Expand All @@ -24,22 +24,24 @@ jobs:
matrix:
include:
# Linux x86_64 构建
- target: x86_64-unknown-linux-gnu
- target: x86_64-linux-gnu
os: ubuntu-latest

# Linux ARM64 构建
- target: aarch64-unknown-linux-gnu
- target: aarch64-linux-gnu
os: ubuntu-latest
cross: true

# Linux ARM v7 构建
- target: armv7-unknown-linux-gnueabihf
- target: armv7-linux-gnueabihf
os: ubuntu-latest
cross: true

# macOS Intel 构建
- target: x86_64-apple-darwin
os: macos-latest

# macOS ARM (M1/M2) 构建
# macOS ARM 构建
- target: aarch64-apple-darwin
os: macos-latest

Expand All @@ -52,21 +54,25 @@ jobs:
steps:
- uses: actions/checkout@v3

# 使用 cross 工具来处理交叉编译
- name: Install cross
if: matrix.cross
run: cargo install cross

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

# 为 Linux ARM 目标安装必要的依赖
- name: Install ARM dependencies
if: contains(matrix.target, 'arm')
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
# 根据是否需要交叉编译选择不同的构建命令
- name: Build Binary
run: |
cargo build --verbose --release --target ${{ matrix.target }}
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --verbose --release --target ${{ matrix.target }}
else
cargo build --verbose --release --target ${{ matrix.target }}
fi
shell: bash

# 创建发布包
- name: Package Binary
Expand Down

0 comments on commit 81aa5ff

Please sign in to comment.