-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |