Skip to content

Commit a4a08db

Browse files
committed
ci: github actions workflows for test + release, badges, expanded usage docs
1 parent f45443f commit a4a08db

2 files changed

Lines changed: 282 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
paths:
7+
- '**/*.rs'
8+
- '**/Cargo.toml'
9+
- 'Cargo.lock'
10+
- 'rust-toolchain.toml'
11+
- 'rust-toolchain'
12+
- '.github/workflows/ci.yml'
13+
pull_request:
14+
branches: [master, main]
15+
paths:
16+
- '**/*.rs'
17+
- '**/Cargo.toml'
18+
- 'Cargo.lock'
19+
- 'rust-toolchain.toml'
20+
- 'rust-toolchain'
21+
- '.github/workflows/ci.yml'
22+
workflow_dispatch:
23+
24+
env:
25+
CARGO_TERM_COLOR: always
26+
CARGO_INCREMENTAL: 0
27+
RUST_BACKTRACE: short
28+
29+
jobs:
30+
test:
31+
name: ${{ matrix.name }}
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
include:
37+
- name: Linux (x86_64)
38+
os: ubuntu-latest
39+
target: x86_64-unknown-linux-gnu
40+
- name: Linux (aarch64)
41+
os: ubuntu-24.04-arm
42+
target: aarch64-unknown-linux-gnu
43+
- name: macOS (x86_64)
44+
os: macos-13
45+
target: x86_64-apple-darwin
46+
- name: macOS (aarch64)
47+
os: macos-latest
48+
target: aarch64-apple-darwin
49+
- name: Windows (x86_64)
50+
os: windows-latest
51+
target: x86_64-pc-windows-msvc
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Install Rust toolchain
57+
uses: dtolnay/rust-toolchain@stable
58+
with:
59+
targets: ${{ matrix.target }}
60+
61+
- name: Cache cargo
62+
uses: Swatinem/rust-cache@v2
63+
with:
64+
shared-key: ${{ matrix.target }}
65+
66+
- name: Install cmake (Linux)
67+
if: runner.os == 'Linux'
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y cmake build-essential pkg-config
71+
72+
- name: Install cmake (macOS)
73+
if: runner.os == 'macOS'
74+
run: |
75+
brew install cmake || true
76+
77+
# Windows runners come with cmake + MSVC build tools preinstalled.
78+
79+
- name: Build (default features)
80+
run: cargo build --workspace --all-targets --target ${{ matrix.target }}
81+
82+
- name: Test (default features)
83+
run: cargo test --workspace --target ${{ matrix.target }}
84+
85+
- name: Build (--features unicorn)
86+
run: cargo build --workspace --all-targets --features unicorn --target ${{ matrix.target }}
87+
88+
- name: Test (--features unicorn)
89+
run: cargo test --workspace --features unicorn --target ${{ matrix.target }}
90+
91+
fmt:
92+
name: rustfmt
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: dtolnay/rust-toolchain@stable
97+
with:
98+
components: rustfmt
99+
- run: cargo fmt --all --check
100+
101+
doc:
102+
name: rustdoc
103+
runs-on: ubuntu-latest
104+
env:
105+
RUSTDOCFLAGS: -Dwarnings
106+
steps:
107+
- uses: actions/checkout@v4
108+
- uses: dtolnay/rust-toolchain@stable
109+
- uses: Swatinem/rust-cache@v2
110+
- name: Install cmake
111+
run: sudo apt-get update && sudo apt-get install -y cmake build-essential pkg-config
112+
- run: cargo doc --workspace --no-deps --features unicorn

.github/workflows/release.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Release tag (e.g. v0.1.0)'
11+
required: true
12+
default: 'v0.1.0'
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
CARGO_INCREMENTAL: 0
17+
RUST_BACKTRACE: short
18+
19+
jobs:
20+
build:
21+
name: ${{ matrix.name }}
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- name: Linux (x86_64)
28+
os: ubuntu-latest
29+
target: x86_64-unknown-linux-gnu
30+
archive: tar.gz
31+
bin: strix
32+
- name: Linux (aarch64)
33+
os: ubuntu-24.04-arm
34+
target: aarch64-unknown-linux-gnu
35+
archive: tar.gz
36+
bin: strix
37+
- name: macOS (x86_64)
38+
os: macos-13
39+
target: x86_64-apple-darwin
40+
archive: tar.gz
41+
bin: strix
42+
- name: macOS (aarch64)
43+
os: macos-latest
44+
target: aarch64-apple-darwin
45+
archive: tar.gz
46+
bin: strix
47+
- name: Windows (x86_64)
48+
os: windows-latest
49+
target: x86_64-pc-windows-msvc
50+
archive: zip
51+
bin: strix.exe
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Install Rust toolchain
57+
uses: dtolnay/rust-toolchain@stable
58+
with:
59+
targets: ${{ matrix.target }}
60+
61+
- name: Cache cargo
62+
uses: Swatinem/rust-cache@v2
63+
with:
64+
shared-key: release-${{ matrix.target }}
65+
66+
- name: Install cmake (Linux)
67+
if: runner.os == 'Linux'
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y cmake build-essential pkg-config
71+
72+
- name: Install cmake (macOS)
73+
if: runner.os == 'macOS'
74+
run: brew install cmake || true
75+
76+
- name: Resolve release tag
77+
id: tag
78+
shell: bash
79+
run: |
80+
if [ -n "${{ github.event.inputs.tag }}" ]; then
81+
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
82+
else
83+
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
84+
fi
85+
86+
- name: Build release CLI
87+
run: cargo build --release --features unicorn -p strix-cli --target ${{ matrix.target }}
88+
89+
- name: Strip binary (Unix)
90+
if: runner.os != 'Windows'
91+
run: strip target/${{ matrix.target }}/release/${{ matrix.bin }} || true
92+
93+
- name: Package (Unix tar.gz)
94+
if: matrix.archive == 'tar.gz'
95+
shell: bash
96+
run: |
97+
staging="strix-${{ steps.tag.outputs.tag }}-${{ matrix.target }}"
98+
mkdir -p "$staging"
99+
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$staging/"
100+
cp README.md LICENSE.txt 2>/dev/null "$staging/" || cp README.md "$staging/"
101+
tar -C . -czf "${staging}.tar.gz" "$staging"
102+
echo "ASSET=${staging}.tar.gz" >> "$GITHUB_ENV"
103+
104+
- name: Package (Windows zip)
105+
if: matrix.archive == 'zip'
106+
shell: bash
107+
run: |
108+
staging="strix-${{ steps.tag.outputs.tag }}-${{ matrix.target }}"
109+
mkdir -p "$staging"
110+
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$staging/"
111+
cp README.md "$staging/"
112+
7z a "${staging}.zip" "$staging" > /dev/null
113+
echo "ASSET=${staging}.zip" >> "$GITHUB_ENV"
114+
115+
- name: Compute sha256
116+
shell: bash
117+
run: |
118+
if command -v sha256sum >/dev/null 2>&1; then
119+
sha256sum "$ASSET" > "${ASSET}.sha256"
120+
else
121+
shasum -a 256 "$ASSET" > "${ASSET}.sha256"
122+
fi
123+
124+
- name: Upload artifact
125+
uses: actions/upload-artifact@v4
126+
with:
127+
name: strix-${{ matrix.target }}
128+
path: |
129+
${{ env.ASSET }}
130+
${{ env.ASSET }}.sha256
131+
132+
release:
133+
name: Publish GitHub release
134+
needs: build
135+
runs-on: ubuntu-latest
136+
permissions:
137+
contents: write
138+
steps:
139+
- uses: actions/checkout@v4
140+
141+
- name: Download all artifacts
142+
uses: actions/download-artifact@v4
143+
with:
144+
path: dist
145+
merge-multiple: true
146+
147+
- name: List artifacts
148+
run: ls -la dist/
149+
150+
- name: Resolve release tag
151+
id: tag
152+
run: |
153+
if [ -n "${{ github.event.inputs.tag }}" ]; then
154+
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
155+
else
156+
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
157+
fi
158+
159+
- name: Create GitHub Release
160+
uses: softprops/action-gh-release@v2
161+
with:
162+
tag_name: ${{ steps.tag.outputs.tag }}
163+
name: ${{ steps.tag.outputs.tag }}
164+
generate_release_notes: true
165+
files: |
166+
dist/*.tar.gz
167+
dist/*.zip
168+
dist/*.sha256
169+
draft: false
170+
prerelease: false

0 commit comments

Comments
 (0)