Skip to content

Commit 5e03f6f

Browse files
committed
Add GitHub Actions workflows for CI and releases
- CI workflow: runs on push/PR, checks formatting, clippy, and builds on all platforms - Release workflow: builds cross-platform binaries and publishes to GitHub releases on tags
1 parent 278e6db commit 5e03f6f

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Check formatting
23+
run: cargo fmt -- --check
24+
25+
- name: Run clippy
26+
run: cargo clippy -- -D warnings
27+
28+
- name: Build
29+
run: cargo build --verbose
30+
31+
- name: Run tests
32+
run: cargo test --verbose
33+
34+
build:
35+
name: Build on ${{ matrix.os }}
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
matrix:
39+
os: [ubuntu-latest, macos-latest, windows-latest]
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install Rust
45+
uses: dtolnay/rust-toolchain@stable
46+
47+
- name: Build
48+
run: cargo build --release

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build and Release
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
target: x86_64-unknown-linux-gnu
18+
artifact_name: llm-pricing
19+
asset_name: llm-pricing-linux-x86_64
20+
- os: ubuntu-latest
21+
target: x86_64-unknown-linux-musl
22+
artifact_name: llm-pricing
23+
asset_name: llm-pricing-linux-x86_64-musl
24+
- os: macos-latest
25+
target: x86_64-apple-darwin
26+
artifact_name: llm-pricing
27+
asset_name: llm-pricing-macos-x86_64
28+
- os: macos-latest
29+
target: aarch64-apple-darwin
30+
artifact_name: llm-pricing
31+
asset_name: llm-pricing-macos-aarch64
32+
- os: windows-latest
33+
target: x86_64-pc-windows-msvc
34+
artifact_name: llm-pricing.exe
35+
asset_name: llm-pricing-windows-x86_64.exe
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
with:
43+
targets: ${{ matrix.target }}
44+
45+
- name: Install musl tools
46+
if: matrix.target == 'x86_64-unknown-linux-musl'
47+
run: sudo apt-get install -y musl-tools
48+
49+
- name: Build
50+
run: cargo build --release --target ${{ matrix.target }}
51+
52+
- name: Strip binary (Linux and macOS)
53+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
54+
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
55+
56+
- name: Upload binaries to release
57+
uses: softprops/action-gh-release@v2
58+
if: startsWith(github.ref, 'refs/tags/')
59+
with:
60+
files: |
61+
target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
62+
name: ${{ matrix.asset_name }}
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
66+
create-release:
67+
name: Create Release
68+
runs-on: ubuntu-latest
69+
needs: build
70+
if: startsWith(github.ref, 'refs/tags/')
71+
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Create Release
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
draft: false
79+
prerelease: false
80+
generate_release_notes: true
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)