Skip to content

Commit ded80eb

Browse files
committed
Add GitHub Actions workflows for CI/CD
- CI workflow: test suite, formatting check, clippy linting - Release workflow: cross-platform builds for Linux, macOS, Windows - Automatic release creation on version tags
1 parent 5faecf5 commit ded80eb

2 files changed

Lines changed: 146 additions & 0 deletions

File tree

.github/workflows/ci.yml

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

.github/workflows/release.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build for ${{ matrix.target }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
include:
16+
- target: x86_64-unknown-linux-gnu
17+
os: ubuntu-latest
18+
name: ccline-linux-x64.tar.gz
19+
- target: x86_64-pc-windows-gnu
20+
os: ubuntu-latest
21+
name: ccline-windows-x64.zip
22+
- target: x86_64-apple-darwin
23+
os: macos-latest
24+
name: ccline-macos-x64.tar.gz
25+
- target: aarch64-apple-darwin
26+
os: macos-latest
27+
name: ccline-macos-arm64.tar.gz
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Install Rust
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
targets: ${{ matrix.target }}
37+
38+
- name: Install cross-compilation tools
39+
if: matrix.target == 'x86_64-pc-windows-gnu'
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y mingw-w64
43+
44+
- name: Build binary
45+
run: cargo build --release --target ${{ matrix.target }}
46+
47+
- name: Package Linux/macOS
48+
if: matrix.os != 'windows-latest' && matrix.target != 'x86_64-pc-windows-gnu'
49+
run: |
50+
mkdir -p dist
51+
cp target/${{ matrix.target }}/release/ccometixline dist/ccline
52+
cd dist
53+
tar czf ../${{ matrix.name }} ccline
54+
55+
- name: Package Windows
56+
if: matrix.target == 'x86_64-pc-windows-gnu'
57+
run: |
58+
mkdir -p dist
59+
cp target/${{ matrix.target }}/release/ccometixline.exe dist/ccline.exe
60+
cd dist
61+
zip ../${{ matrix.name }} ccline.exe
62+
63+
- name: Upload artifact
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: ${{ matrix.name }}
67+
path: ${{ matrix.name }}
68+
69+
release:
70+
name: Create Release
71+
runs-on: ubuntu-latest
72+
needs: build
73+
if: startsWith(github.ref, 'refs/tags/')
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v4
77+
78+
- name: Download artifacts
79+
uses: actions/download-artifact@v4
80+
with:
81+
path: artifacts
82+
83+
- name: Create Release
84+
uses: softprops/action-gh-release@v1
85+
with:
86+
files: artifacts/*/*
87+
generate_release_notes: true
88+
draft: false
89+
prerelease: false
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)