Skip to content

Commit a5b65da

Browse files
copyleftdevclaude
andcommitted
ci: add CI and release workflows
CI runs fmt/clippy/test/build on every push and PR to main. Release builds cross-platform binaries (linux x86_64/aarch64, macOS x86_64/aarch64) and publishes a GitHub Release on tag push. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent f6e20b0 commit a5b65da

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
check:
14+
name: Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust stable
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt, clippy
23+
24+
- name: Cache cargo
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
32+
restore-keys: ${{ runner.os }}-cargo-
33+
34+
- name: Check formatting
35+
run: cargo fmt --all -- --check
36+
37+
- name: Clippy
38+
run: cargo clippy --all-targets --all-features -- -D warnings
39+
40+
- name: Test
41+
run: cargo test
42+
43+
- name: Build
44+
run: cargo build

.github/workflows/release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions:
8+
contents: write
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
name: Build ${{ matrix.target }}
16+
runs-on: ${{ matrix.runner }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- target: x86_64-unknown-linux-gnu
22+
runner: ubuntu-latest
23+
use_cross: false
24+
- target: aarch64-unknown-linux-gnu
25+
runner: ubuntu-latest
26+
use_cross: true
27+
- target: x86_64-apple-darwin
28+
runner: macos-13
29+
use_cross: false
30+
- target: aarch64-apple-darwin
31+
runner: macos-latest
32+
use_cross: false
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Install Rust stable
38+
uses: dtolnay/rust-toolchain@stable
39+
with:
40+
targets: ${{ matrix.target }}
41+
42+
- name: Cache cargo
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
~/.cargo/registry
47+
~/.cargo/git
48+
target
49+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}
50+
restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo-
51+
52+
- name: Install cross
53+
if: matrix.use_cross
54+
run: cargo install cross --git https://github.com/cross-rs/cross
55+
56+
- name: Build (native)
57+
if: "!matrix.use_cross"
58+
run: cargo build --release --target ${{ matrix.target }}
59+
60+
- name: Build (cross)
61+
if: matrix.use_cross
62+
run: cross build --release --target ${{ matrix.target }}
63+
64+
- name: Rename binary
65+
run: cp target/${{ matrix.target }}/release/hookbin hookbin-${{ matrix.target }}
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: hookbin-${{ matrix.target }}
71+
path: hookbin-${{ matrix.target }}
72+
73+
release:
74+
name: Release
75+
needs: build
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Download all artifacts
79+
uses: actions/download-artifact@v4
80+
with:
81+
path: artifacts
82+
83+
- name: Collect binaries and generate checksums
84+
run: |
85+
mkdir release
86+
cp artifacts/hookbin-*/hookbin-* release/
87+
cd release
88+
sha256sum hookbin-* > SHA256SUMS
89+
90+
- name: Create GitHub Release
91+
uses: softprops/action-gh-release@v2
92+
with:
93+
generate_release_notes: true
94+
files: release/*

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "stable"
3+
components = ["rustfmt", "clippy"]

0 commit comments

Comments
 (0)