-
-
Notifications
You must be signed in to change notification settings - Fork 0
377 lines (337 loc) · 12.7 KB
/
ci.yml
File metadata and controls
377 lines (337 loc) · 12.7 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
---
name: CI
permissions: {}
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
setup_release:
name: Setup Release
outputs:
publish_release: ${{ steps.setup_release.outputs.publish_release }}
release_body: ${{ steps.setup_release.outputs.release_body }}
release_commit: ${{ steps.setup_release.outputs.release_commit }}
release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }}
release_tag: ${{ steps.setup_release.outputs.release_tag }}
release_version: ${{ steps.setup_release.outputs.release_version }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Release
id: setup_release
uses: LizardByte/actions/actions/release_setup@4125866b7b655a6fe038b0e22a43a4c5d259af79 # v2026.417.35446
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu # Debian
os: ubuntu-latest
container: ''
shell: bash
cargo_env: ''
# TODO: Fix compiling for musl
# - target: x86_64-unknown-linux-musl # Alpine
# os: ubuntu-latest
# container: alpine:latest
# shell: sh
# cargo_env: "source $HOME/.cargo/env"
- target: aarch64-unknown-linux-gnu # Debian
os: ubuntu-24.04-arm
container: ''
shell: bash
cargo_env: ''
# TODO: Fix cross compiling for the below targets
# - target: aarch64-unknown-linux-musl # Alpine
# os: ubuntu-24.04-arm
# container: alpine:latest
# shell: sh
# cargo_env: "source $HOME/.cargo/env"
# - target: armv7-unknown-linux-gnueabihf # Raspberry Pi 2-5/Debian
# os: ubuntu-24.04-arm
# shell: bash
# - target: armv7-unknown-linux-musleabihf # Raspberry Pi 2-5/Alpine
# os: ubuntu-24.04-arm
# container: alpine:latest
# shell: sh
# cargo_env: "source $HOME/.cargo/env"
# - target: arm-unknown-linux-gnueabihf # Raspberry Pi 0-1/Debian
# os: ubuntu-24.04-arm
# shell: bash
# - target: arm-unknown-linux-musleabihf # Raspberry Pi 0-1/Alpine
# os: ubuntu-24.04-arm
# container: alpine:latest
# shell: sh
# cargo_env: "source $HOME/.cargo/env"
- target: x86_64-apple-darwin # macOS/Intel
os: macos-latest
container: ''
shell: bash
cargo_env: ''
- target: aarch64-apple-darwin # macOS/Apple Silicon
os: macos-latest
container: ''
shell: bash
cargo_env: ''
- target: x86_64-pc-windows-msvc # Windows
os: windows-latest
container: ''
shell: bash
cargo_env: ''
name: Build (${{ matrix.target }})
needs: setup_release
permissions:
contents: read
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container }}
defaults:
run:
shell: ${{ matrix.shell }}
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup cross compiling (Debian)
id: cross_compile
if: contains(matrix.os, 'ubuntu') && matrix.container == null
run: |
echo "::group::distro detection"
# detect dist name like bionic, focal, etc
dist_name=$(lsb_release -cs)
ubuntu_version=$(lsb_release -rs)
ubuntu_major_version=${ubuntu_version%%.*}
echo "detected dist name: $dist_name"
echo "detected ubuntu version: $ubuntu_version"
echo "detected ubuntu major version: $ubuntu_major_version"
echo "::endgroup::"
echo "::group::install aptitude"
sudo apt-get update # must run before changing sources file
sudo apt-get install -y \
aptitude
echo "::endgroup::"
echo "::group::dependencies prep"
dependencies=()
# extra dependencies for cross-compiling
cross_compile=false
package_arch=$(dpkg --print-architecture)
pkg_config_sysroot_dir="/usr/lib/${package_arch}"
qemu_command=""
if [[ ${{ matrix.target }} == *"aarch64"* && $package_arch != "arm64" ]]; then
dependencies+=("crossbuild-essential-arm64")
cross_compile=true
package_arch="arm64"
pkg_config_sysroot_dir="/usr/lib/aarch64-linux-gnu"
qemu_command="qemu-aarch64-static"
elif [[ ${{ matrix.target }} == *"arm"* && $package_arch != "armhf" ]]; then
dependencies+=("crossbuild-essential-armhf")
cross_compile=true
package_arch="armhf"
pkg_config_sysroot_dir="/usr/lib/arm-linux-gnueabihf"
qemu_command="qemu-arm-static"
fi
if [[ $cross_compile == true ]]; then
dependencies+=(
"qemu-user"
"qemu-user-static"
)
fi
if [[ ${{ matrix.target }} == *"musl"* ]]; then
dependencies+=("musl-tools")
fi
echo "cross compiling: $cross_compile"
echo "package architecture: $package_arch"
dependencies+=(
"libayatana-appindicator3-dev:${package_arch}" # tray icon
"libglib2.0-dev:${package_arch}"
"libgtk-3-dev:${package_arch}"
"libxdo-dev:${package_arch}"
)
echo "::endgroup::"
echo "::group::apt sources"
extra_sources=$(cat <<- VAREOF
Types: deb
URIs: mirror+file:/etc/apt/apt-mirrors.txt
Suites: ${dist_name} ${dist_name}-updates ${dist_name}-backports ${dist_name}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: $(dpkg --print-architecture)
Types: deb
URIs: https://ports.ubuntu.com/ubuntu-ports
Suites: ${dist_name} ${dist_name}-updates ${dist_name}-backports ${dist_name}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: ${package_arch}
VAREOF
)
# source file changed in 24.04
if [[ $ubuntu_major_version -ge 24 ]]; then
source_file="/etc/apt/sources.list.d/ubuntu.sources"
else
source_file="/etc/apt/sources.list"
fi
if [[ ${cross_compile} == true ]]; then
# print original sources
echo "original sources:"
sudo cat ${source_file}
echo "----"
sudo dpkg --add-architecture ${package_arch}
echo "$extra_sources" | sudo tee ${source_file} > /dev/null
echo "----"
echo "new sources:"
sudo cat ${source_file}
echo "----"
fi
echo "::endgroup::"
echo "::group::output"
echo "CROSS_COMPILE=${cross_compile}"
echo "DEPENDENCIES=${dependencies[@]}"
echo "PKG_CONFIG_SYSROOT_DIR=${pkg_config_sysroot_dir}"
echo "PKG_CONFIG_PATH=${pkg_config_sysroot_dir}/pkgconfig"
echo "QEMU_COMMAND=${qemu_command}"
{
echo "CROSS_COMPILE=${cross_compile}"
echo "DEPENDENCIES=${dependencies[@]}"
echo "QEMU_COMMAND=${qemu_command}"
} >> "${GITHUB_OUTPUT}"
{
echo "PKG_CONFIG_SYSROOT_DIR=${pkg_config_sysroot_dir}"
echo "PKG_CONFIG_PATH=${pkg_config_sysroot_dir}/pkgconfig"
} >> "${GITHUB_ENV}"
echo "::endgroup::"
- name: Install system dependencies (Debian)
if: contains(matrix.os, 'ubuntu') && matrix.container == null
run: |
echo "::group::apt update"
sudo apt-get update
echo "::endgroup::"
echo "::group::install dependencies"
sudo aptitude install -y --without-recommends ${{ steps.cross_compile.outputs.DEPENDENCIES }}
echo "::endgroup::"
- name: Install system dependencies (Alpine)
if: contains(matrix.os, 'ubuntu') && contains(matrix.container, 'alpine')
run: |
echo "::group::apk update"
apk update
echo "::endgroup::"
echo "::group::install dependencies"
apk add --no-cache \
build-base \
cargo \
gcc \
g++ \
glib-dev \
gtk+3.0-dev \
libayatana-appindicator-dev \
musl-dev \
openssl-dev \
xdotool-dev \
pango-dev \
harfbuzz-dev \
cairo-dev \
gdk-pixbuf-dev \
wayland-dev \
zlib-dev \
gettext-dev
echo "::endgroup::"
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
with:
target: ${{ matrix.target }}
components: 'clippy'
cache: true
cache-on-failure: false
# TODO: it may be possible to use cargo-bin in the future to install cargo dependencies,
# but right now it doesn't work without a lock file
# https://github.com/dustinblackman/cargo-run-bin/issues/27
# cargo install cargo-run-bin
# cargo-bin --install
- name: Install cargo packages
run: |
cargo install \
cargo-edit \
cargo-tarpaulin
- name: Update Version
if: ${{ needs.setup_release.outputs.publish_release == 'true' }}
run: cargo set-version ${{ needs.setup_release.outputs.release_version }}
- name: Test
id: test
run: |
${{ matrix.cargo_env }}
cargo tarpaulin \
--color always \
--engine llvm \
--no-fail-fast \
--out Xml \
--target ${{ matrix.target }} \
--verbose
- name: Upload coverage
# any except canceled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
disable_search: true
fail_ci_if_error: true
files: cobertura.xml
flags: ${{ matrix.target }}
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Clippy
run: |
${{ matrix.cargo_env }}
cargo clippy -- -D warnings
- name: Build
run: |
${{ matrix.cargo_env }}
cargo build --target ${{ matrix.target }} --release
- name: Strip all debug symbols
# TODO: is this necessary
if: contains(matrix.os, 'ubuntu')
run: strip --strip-all target/${{ matrix.target }}/release/koko
- name: Enable reading of cache
# TODO: is this necessary
continue-on-error: true
run: chmod -R a+rwX $HOME/.cargo target
- name: Create 7z archive
run: |
mkdir -p artifacts
extension=""
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
extension=".exe"
fi
7z a "./artifacts/koko-${{ matrix.target }}.7z" \
"./assets" \
"./target/${{ matrix.target }}/release/koko${extension}"
- name: Upload Artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
if-no-files-found: 'error'
name: koko-${{ matrix.target }}
path: artifacts
- name: Create/Update GitHub Release
if: ${{ needs.setup_release.outputs.publish_release == 'true' }}
uses: LizardByte/actions/actions/release_create@4125866b7b655a6fe038b0e22a43a4c5d259af79 # v2026.417.35446
with:
allowUpdates: true
body: ${{ needs.setup_release.outputs.release_body }}
draft: true
generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }}
name: ${{ needs.setup_release.outputs.release_tag }}
prerelease: true
tag: ${{ needs.setup_release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}