Skip to content

Commit 829eb63

Browse files
chore: add github workflow configs
1 parent f05b15e commit 829eb63

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
fmt:
13+
name: Check Formatting
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt
23+
24+
- name: Check formatting
25+
run: cargo fmt --all -- --check
26+
27+
clippy:
28+
name: Clippy Lint
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Install Rust toolchain
35+
uses: dtolnay/rust-toolchain@stable
36+
with:
37+
components: clippy
38+
39+
- name: Rust Cache
40+
uses: Swatinem/rust-cache@v2
41+
42+
- name: Run Clippy
43+
run: cargo clippy --all-targets --all-features -- -D warnings
44+
45+
test:
46+
name: Run Tests
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Install Rust toolchain
53+
uses: dtolnay/rust-toolchain@stable
54+
55+
- name: Rust Cache
56+
uses: Swatinem/rust-cache@v2
57+
58+
- name: Run tests
59+
run: cargo test --all-targets --all-features

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build:
12+
name: Build on ${{ matrix.os }} for ${{ matrix.target }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
target: x86_64-unknown-linux-gnu
20+
artifact_name: this-is-c
21+
asset_name: this-is-c-linux-amd64
22+
23+
- os: windows-latest
24+
target: x86_64-pc-windows-msvc
25+
artifact_name: this-is-c.exe
26+
asset_name: this-is-c-windows-amd64
27+
28+
- os: macos-latest
29+
target: x86_64-apple-darwin
30+
artifact_name: this-is-c
31+
asset_name: this-is-c-macos-amd64
32+
33+
- os: macos-latest
34+
target: aarch64-apple-darwin
35+
artifact_name: this-is-c
36+
asset_name: this-is-c-macos-arm64
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Setup Rust toolchain
42+
uses: dtolnay/rust-toolchain@stable
43+
with:
44+
targets: ${{ matrix.target }}
45+
46+
- name: Rust Cache
47+
uses: Swatinem/rust-cache@v2
48+
with:
49+
key: ${{ matrix.target }}
50+
51+
- name: Build binary
52+
run: cargo build --release --target ${{ matrix.target }}
53+
54+
- name: Package binary (Unix)
55+
if: runner.os != 'Windows'
56+
run: |
57+
cd target/${{ matrix.target }}/release
58+
tar -czf ../../../${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
59+
echo "ASSET_FILE=${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
60+
61+
- name: Package binary (Windows)
62+
if: runner.os == 'Windows'
63+
shell: bash
64+
run: |
65+
cd target/${{ matrix.target }}/release
66+
7z a ../../../${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
67+
echo "ASSET_FILE=${{ matrix.asset_name }}.zip" >> $GITHUB_ENV
68+
69+
- name: Upload artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: binary-${{ matrix.target }}
73+
path: ${{ env.ASSET_FILE }}
74+
75+
publish:
76+
name: Publish Release
77+
needs: build
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Download all artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
pattern: binary-*
84+
merge-multiple: true
85+
path: dist
86+
87+
- name: Publish to GitHub Release
88+
uses: softprops/action-gh-release@v2
89+
with:
90+
files: dist/*
91+
draft: false
92+
generate_release_notes: true

0 commit comments

Comments
 (0)