-
Notifications
You must be signed in to change notification settings - Fork 4
413 lines (331 loc) · 10.9 KB
/
ci.yml
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
name: CI
on:
push:
branches:
- master
- feature/ci
tags:
- v[0-9]+.*
- testing-ci.*
pull_request:
jobs:
lint:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install rust
run: |
rustup update stable && rustup default stable
rustup component add clippy
- name: Install dependencies
run: sudo apt-get install libdbus-1-dev
- name: Run clippy
run: cargo clippy --all --all-features -- -Dwarnings
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: [stable, nightly]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install rust
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- name: Install dependencies
run: sudo apt-get install libdbus-1-dev
- name: Build
run: cargo build --all
- name: Test
run: cargo test --all
build-bin:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
name: Build binary package
runs-on: ubuntu-20.04
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install rust
run: rustup update stable && rustup default stable
- name: Install dependencies
run: sudo apt-get install libdbus-1-dev
- name: Build package
run: ./pkg/bin/makebin
- name: Prepare release
run: mkdir release && mv pkg/bin/*.tar.xz release
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binary-latest
path: release
build-deb:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
name: Build deb package
runs-on: ubuntu-20.04
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install rust
run: rustup update stable && rustup default stable
- name: Install dependencies
run: sudo apt-get install debhelper fakeroot dpkg-sig libdbus-1-dev
- name: Build package
run: ./pkg/deb/makedeb
- name: Sign package
env:
GPG_KEY_ID: 56C464BAAC421453
GPG_KEY: ${{ secrets.LINUX_SURFACE_GPG_KEY }}
run: |
# import GPG key
echo "$GPG_KEY" | base64 -d | gpg --import --no-tty --batch --yes
export GPG_TTY=$(tty)
# sign package
cd pkg/deb && dpkg-sig -g "--batch --no-tty" --sign builder -k $GPG_KEY_ID ./*.deb
- name: Prepare release
run: mkdir release && mv pkg/deb/*.deb release
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: debian-latest
path: release
build-f39:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
name: Build Fedora 39 package
runs-on: ubuntu-latest
needs: [lint, test]
container:
image: registry.fedoraproject.org/fedora:39
options: --security-opt seccomp=unconfined
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install build dependencies
run: |
dnf distro-sync -y
dnf install -y rpmdevtools rpm-sign 'dnf-command(builddep)'
dnf builddep -y pkg/fedora/surface-dtx-daemon.spec
- name: Build package
run: |
cd pkg/fedora
# Build the .rpm packages
./makerpm
- name: Sign packages
env:
GPG_KEY_ID: 56C464BAAC421453
GPG_KEY: ${{ secrets.LINUX_SURFACE_GPG_KEY }}
run: |
cd pkg/fedora/out/x86_64
# import GPG key
echo "$GPG_KEY" | base64 -d | gpg --import --no-tty --batch --yes
# sign package
rpm --resign *.rpm --define "_gpg_name $GPG_KEY_ID"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: fedora-39-latest
path: pkg/fedora/out/x86_64
build-f38:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
name: Build Fedora 38 package
runs-on: ubuntu-latest
needs: [lint, test]
container:
image: registry.fedoraproject.org/fedora:38
options: --security-opt seccomp=unconfined
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install build dependencies
run: |
dnf distro-sync -y
dnf install -y rpmdevtools rpm-sign 'dnf-command(builddep)'
dnf builddep -y pkg/fedora/surface-dtx-daemon.spec
- name: Build package
run: |
cd pkg/fedora
# Build the .rpm packages
./makerpm
- name: Sign packages
env:
GPG_KEY_ID: 56C464BAAC421453
GPG_KEY: ${{ secrets.LINUX_SURFACE_GPG_KEY }}
run: |
cd pkg/fedora/out/x86_64
# import GPG key
echo "$GPG_KEY" | base64 -d | gpg --import --no-tty --batch --yes
# sign package
rpm --resign *.rpm --define "_gpg_name $GPG_KEY_ID"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: fedora-38-latest
path: pkg/fedora/out/x86_64
release:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
name: Publish release
needs: [build-bin, build-deb, build-f39, build-f38]
runs-on: ubuntu-latest
steps:
- name: Download binary artifacts
uses: actions/download-artifact@v4
with:
name: binary-latest
path: binary-latest
- name: Download Debian artifacts
uses: actions/download-artifact@v4
with:
name: debian-latest
path: debian-latest
- name: Download Fedora 39 artifacts
uses: actions/download-artifact@v4
with:
name: fedora-39-latest
path: fedora-39-latest
- name: Download Fedora 38 artifacts
uses: actions/download-artifact@v4
with:
name: fedora-38-latest
path: fedora-38-latest
- name: Upload assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./*-latest/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
repo-deb:
name: Update Debian package repository
needs: [release]
runs-on: ubuntu-latest
container: debian:sid
steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y git
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: debian-latest
path: debian-latest
- name: Update repository
env:
SURFACEBOT_TOKEN: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
BRANCH_STAGING: u/staging
GIT_REF: ${{ github.ref }}
run: |
repo="https://surfacebot:${SURFACEBOT_TOKEN}@github.com/linux-surface/repo.git"
# clone package repository
git clone -b "${BRANCH_STAGING}" "${repo}" repo
# copy packages
cp debian-latest/* repo/debian/
cd repo/debian
# parse git tag from ref
GIT_TAG=$(echo $GIT_REF | sed 's|^refs/tags/||g')
# convert packages into references
for pkg in $(find . -name '*.deb'); do
echo "surface-dtx-daemon:$GIT_TAG/$(basename $pkg)" > $pkg.blob
rm $pkg
done
# set git identity
git config --global user.email "[email protected]"
git config --global user.name "surfacebot"
# commit and push
update_branch="${BRANCH_STAGING}-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
git switch -c "${update_branch}"
git add .
git commit -m "Update Debian DTX daemon"
git push --set-upstream origin "${update_branch}"
repo-f39:
name: Update Fedora 39 package repository
needs: [release]
runs-on: ubuntu-latest
container:
image: registry.fedoraproject.org/fedora:39
options: --security-opt seccomp=unconfined
steps:
- name: Install dependencies
run: |
dnf install -y git findutils
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: fedora-39-latest
path: fedora-39-latest
- name: Update repository
env:
SURFACEBOT_TOKEN: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
BRANCH_STAGING: u/staging
GIT_REF: ${{ github.ref }}
run: |
repo="https://surfacebot:${SURFACEBOT_TOKEN}@github.com/linux-surface/repo.git"
# clone package repository
git clone -b "${BRANCH_STAGING}" "${repo}" repo
# copy packages
cp fedora-39-latest/* repo/fedora/f39
cd repo/fedora/f39
# parse git tag from ref
GIT_TAG=$(echo $GIT_REF | sed 's|^refs/tags/||g')
# convert packages into references
for pkg in $(find . -name '*.rpm'); do
echo "surface-dtx-daemon:$GIT_TAG/$(basename $pkg)" > $pkg.blob
rm $pkg
done
# set git identity
git config --global user.email "[email protected]"
git config --global user.name "surfacebot"
# commit and push
update_branch="${BRANCH_STAGING}-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
git checkout -b "${update_branch}"
git add .
git commit -m "Update Fedora 39 DTX daemon"
git push --set-upstream origin "${update_branch}"
repo-f38:
name: Update Fedora 38 package repository
needs: [release]
runs-on: ubuntu-latest
container:
image: registry.fedoraproject.org/fedora:38
options: --security-opt seccomp=unconfined
steps:
- name: Install dependencies
run: |
dnf install -y git findutils
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: fedora-38-latest
path: fedora-38-latest
- name: Update repository
env:
SURFACEBOT_TOKEN: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
BRANCH_STAGING: u/staging
GIT_REF: ${{ github.ref }}
run: |
repo="https://surfacebot:${SURFACEBOT_TOKEN}@github.com/linux-surface/repo.git"
# clone package repository
git clone -b "${BRANCH_STAGING}" "${repo}" repo
# copy packages
cp fedora-38-latest/* repo/fedora/f38
cd repo/fedora/f38
# parse git tag from ref
GIT_TAG=$(echo $GIT_REF | sed 's|^refs/tags/||g')
# convert packages into references
for pkg in $(find . -name '*.rpm'); do
echo "surface-dtx-daemon:$GIT_TAG/$(basename $pkg)" > $pkg.blob
rm $pkg
done
# set git identity
git config --global user.email "[email protected]"
git config --global user.name "surfacebot"
# commit and push
update_branch="${BRANCH_STAGING}-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
git checkout -b "${update_branch}"
git add .
git commit -m "Update Fedora 38 DTX daemon"
git push --set-upstream origin "${update_branch}"