-
Notifications
You must be signed in to change notification settings - Fork 18
285 lines (238 loc) · 9.02 KB
/
Copy pathci.yml
File metadata and controls
285 lines (238 loc) · 9.02 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: CI
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: compare git tag with cargo metadata (Unix)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows'
run: |
PUSHED_TAG=${GITHUB_REF##*/}
CURR_VER=$( grep version crates/kiorg/Cargo.toml | head -n 1 | awk '{print $3}' | tr -d '"' )
if [[ "${PUSHED_TAG}" != "v${CURR_VER}" ]]; then
echo "Cargo metadata has version set to ${CURR_VER}, but got pushed tag ${PUSHED_TAG}."
exit 1
fi
- name: compare git tag with cargo metadata (Windows)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && runner.os == 'Windows'
run: |
$PUSHED_TAG = (Split-Path -Path $env:GITHUB_REF -Leaf)
$CURR_VER_Line = Select-String -Path crates/kiorg/Cargo.toml -Pattern "version" | Select-Object -First 1
if ($null -eq $CURR_VER_Line) {
Write-Error "Could not find 'version' in crates/kiorg/Cargo.toml"
exit 1
}
# Example of a Cargo.toml version line: version = "0.1.0"
# We want to extract "0.1.0"
$CURR_VER_Match = $CURR_VER_Line.Line | Select-String -Pattern 'version\s*=\s*"(?<version>[^"]+)"'
if ($null -eq $CURR_VER_Match) {
Write-Error "Could not parse version from Cargo.toml line: $($CURR_VER_Line.Line)"
exit 1
}
$CURR_VER = $CURR_VER_Match.Matches[0].Groups['version'].Value
if ("v$CURR_VER" -ne $PUSHED_TAG) {
Write-Error "Cargo metadata has version set to $CURR_VER, but got pushed tag $PUSHED_TAG."
exit 1
}
- name: Install system dependencies (Linux only)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
# enable this job for other platforms when we start to run out of disk space
# on mac or window
- name: Clean disk space (Linux only)
if: runner.os == 'Linux'
run: bash .github/workflows/clean_disk_space.sh
- name: Run tests
run: cargo nextest run
bundle-linux:
name: Bundle Packaging (Linux - ${{ matrix.arch }})
needs: test
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: x86_64
runner: ubuntu-latest
- arch: aarch64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies (Linux only)
run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
cargo build --release
cd target/release
zip -r ../../kiorg-${{ matrix.arch }}-linux.zip kiorg
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: kiorg-${{ github.event.pull_request.head.sha || github.sha }}-${{ matrix.arch }}-linux.zip
path: kiorg-${{ matrix.arch }}-linux.zip
if-no-files-found: error
- name: Upload binary to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: kiorg-${{ github.ref_name }}-${{ matrix.arch }}-linux.zip
file: kiorg-${{ matrix.arch }}-linux.zip
tag: ${{ github.ref }}
bundle-macos:
name: Bundle Packaging (macOS)
needs: test
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- uses: cargo-bins/cargo-binstall@v1.12.4
- name: Install cargo-bundle
env:
# avoid rate limits
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo binstall --force cargo-bundle@0.6.1 && cargo-bundle --version
- name: Create App bundle
run: |
cargo bundle --release --target aarch64-apple-darwin
- name: Install create-dmg
run: npm install --global create-dmg
- name: Create DMG using create-dmg
run: |
# create-dmg will fail without code signing identity, ignore that error for now
create-dmg --overwrite --dmg-title="Kiorg" target/aarch64-apple-darwin/release/bundle/osx/Kiorg.app || true
mv Kiorg\ *.dmg Kiorg-aarch64.dmg
- name: Create CLI binary
run: |
cargo build --release --target aarch64-apple-darwin
cd target/aarch64-apple-darwin/release
zip -r ../../../kiorg-aarch64-macos.zip kiorg
- name: Create App bundle zip
run: |
cd target/aarch64-apple-darwin/release/bundle/osx
tar -czf ../../../../../Kiorg-aarch64.app.bundle.tar.gz Kiorg.app
- name: Upload DMG artifact
uses: actions/upload-artifact@v4
with:
name: Kiorg-${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
path: Kiorg-aarch64.dmg
if-no-files-found: error
- name: Upload App bundle artifact
uses: actions/upload-artifact@v4
with:
name: Kiorg-${{ github.event.pull_request.head.sha || github.sha }}-app.bundle.tar.gz
path: Kiorg-aarch64.app.bundle.tar.gz
if-no-files-found: error
- name: Upload macOS CLI binary
uses: actions/upload-artifact@v4
with:
name: kiorg-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-macos.zip
path: kiorg-aarch64-macos.zip
if-no-files-found: error
- name: Upload CLI binary to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: kiorg-${{ github.ref_name }}-aarch64-macos.zip
file: kiorg-aarch64-macos.zip
tag: ${{ github.ref }}
- name: Upload DMG to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: Kiorg-${{ github.ref_name }}-aarch64.dmg
file: Kiorg-aarch64.dmg
tag: ${{ github.ref }}
- name: Upload App bundle to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: Kiorg-${{ github.ref_name }}-aarch64-app.bundle.tar.gz
file: Kiorg-aarch64.app.bundle.tar.gz
tag: ${{ github.ref }}
bundle-windows:
name: Bundle Packaging (Windows)
needs: test
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
cargo build --no-default-features --release
cd target\release
Compress-Archive -Path kiorg.exe -DestinationPath ..\..\kiorg-x86_64-windows.zip
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: kiorg-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-windows.zip
path: kiorg-x86_64-windows.zip
if-no-files-found: error
- name: Upload binary to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: kiorg-${{ github.ref_name }}-x86_64-windows.zip
file: kiorg-x86_64-windows.zip
tag: ${{ github.ref }}