Skip to content

Commit

Permalink
feat: add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
suyulin committed Dec 25, 2024
1 parent 1e0abee commit c44e6a8
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and Test

on:
push:
branches:
- main
pull_request:
branches:
- main

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

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

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
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
run: cargo build --release

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

- name: Package binary (only for release builds)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p dist
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp target/release/afptool-rs.exe dist/
else
cp target/release/afptool-rs dist/
fi
- name: Upload Release Artifacts
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v3
with:
name: afptool-rs-${{ matrix.os }}
path: dist/

0 comments on commit c44e6a8

Please sign in to comment.