-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (166 loc) · 5.13 KB
/
ci.yml
File metadata and controls
199 lines (166 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test --verbose
- name: Test binary build
run: cargo build --release
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit
coverage:
name: Code Coverage
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate coverage report
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
build-release:
name: Build Release Binaries
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create archive
shell: bash
run: |
binary_name="commitcraft${{ matrix.suffix }}"
binary_path="target/${{ matrix.target }}/release/${binary_name}"
if [[ "${{ runner.os }}" == "Windows" ]]; then
archive_name="commitcraft-${{ matrix.target }}.zip"
7z a "$archive_name" "$binary_path"
else
archive_name="commitcraft-${{ matrix.target }}.tar.gz"
tar -czf "$archive_name" -C "target/${{ matrix.target }}/release" "$binary_name"
fi
echo "ARCHIVE_NAME=$archive_name" >> $GITHUB_ENV
echo "ARCHIVE_PATH=$archive_name" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_PATH }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: [test, build-release]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: ${{ contains(github.ref, '-') }}
files: artifacts/**/*
generate_release_notes: true
body: |
## 🚀 What's New
This release includes various improvements and bug fixes.
## 📦 Installation
### Quick Install (Linux/macOS)
```bash
curl -sSL https://raw.githubusercontent.com/san0808/commitcraft/main/install.sh | bash
```
### Manual Download
Download the appropriate binary for your platform from the assets below.
### Cargo Install
```bash
cargo install commitcraft
```
## 🎯 Usage
```bash
# First time setup
commitcraft setup
# Generate commit message
git add .
commitcraft
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [test]
if: startsWith(github.ref, 'refs/tags/v') && vars.ENABLE_CRATES_PUBLISH == 'true'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
continue-on-error: true