Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
suyulin committed Dec 25, 2024
1 parent 32b1968 commit d886e80
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,53 @@
name: Release
name: Publish afptool-rs

on:
push:
tags:
- "v*"
- '*'

jobs:
build:
name: Build and Test on ${{ matrix.os }}
name: Publish binaries
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta, nightly]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
# 检出代码
- name: Checkout source code
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Install Rust
# 设置 Rust 工具链
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
toolchain: stable
override: true

- name: Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin
target
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Compile the project
# 构建项目
- name: Build project
run: cargo build --release

- name: Run tests
run: cargo test --verbose

# 打包二进制文件
- name: Package binary (only for release builds)
if: startsWith(github.ref, 'refs/tags/')
- name: Package binary
run: |
mkdir -p dist
if [ "${{ runner.os }}" = "Windows" ]; then
cp target/release/afptool-rs.exe dist/
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/release/afptool-rs.exe dist/afptool-rs-${{ matrix.os }}.exe
else
cp target/release/afptool-rs dist/
cp target/release/afptool-rs dist/afptool-rs-${{ matrix.os }}
fi
shell: bash
# 上传二进制文件到 Release
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/afptool-rs-${{ matrix.os }}*
asset_name: afptool-rs-${{ matrix.os }}
tag: ${{ github.ref_name }}
overwrite: true
body: |
This is the cross-platform release for afptool-rs.
- Built for ${{ matrix.os }} using GitHub Actions.

0 comments on commit d886e80

Please sign in to comment.