-
Notifications
You must be signed in to change notification settings - Fork 8
652 lines (596 loc) · 19.6 KB
/
builds.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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
name: Builds
#
#
# this workflow:
# - runs tests
# - builds artifacts
# - signs executables
# - builds msi, rpm and deb packages
# - creates the release draft for git tags
#
# help: https://github.github.io/actions-cheat-sheet/actions-cheat-sheet.html
on:
push:
pull_request:
# set go version for all steps
env:
GOVERSION: 1.22.x
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
minor: ${{ steps.get-minor-version.outputs.minor }}
major: ${{ steps.get-major-version.outputs.major }}
revision: ${{ steps.get-total-revision.outputs.revision }}
sha: ${{ steps.get-short-sha.outputs.sha }}
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: get-major-version
run: echo "major=$(./buildtools/get_version | cut -d . -f 1 | sed -e 's/[^0-9]*//g')" >> $GITHUB_OUTPUT
- id: get-minor-version
run: echo "minor=$(./buildtools/get_version | cut -d . -f 2 | sed -e 's/[^0-9]*//g')" >> $GITHUB_OUTPUT
- id: get-total-revision
run: REV=$(./buildtools/get_version | cut -d . -f 3 | sed -e 's/[^0-9]*//g'); echo "revision=${REV:-0}" >> $GITHUB_OUTPUT
- id: get-short-sha
run: echo "sha=$( git rev-parse --short HEAD )" >> $GITHUB_OUTPUT
- id: get-version
run: echo "version=$(./buildtools/get_version)" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: make citest
test-win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: |
echo "Testing with ${{ env.GOVERSION }}"
go work init
go work use .
$Env:GOWORK = "off"
go mod vendor
$Env:GOWORK = ""
go test -v ./pkg/... ; if ($LASTEXITCODE -ne 0) { exit 1 }
test-osx:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: make test
build:
strategy:
fail-fast: false
matrix:
go-os: [linux, freebsd]
go-arch: [i386, x86_64, aarch64]
needs: [get-version]
runs-on: ubuntu-latest
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: |
echo "Building ${{ env.BIN }}"
GOOS=${{ matrix.go-os }} GOARCH=${{ matrix.go-arch }} make build
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}"
path: "snclient"
if-no-files-found: error
build-osx:
strategy:
fail-fast: false
matrix:
go-os: [darwin]
go-arch: [x86_64, aarch64]
needs: [get-version]
runs-on: macos-latest
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: |
echo "Building ${{ env.BIN }}"
GOOS=${{ matrix.go-os }} GOARCH=${{ matrix.go-arch }} make build
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}"
path: "snclient"
if-no-files-found: error
build-win:
strategy:
fail-fast: false
matrix:
go-os: [windows]
go-arch: [i386, x86_64, aarch64]
needs: [get-version]
runs-on: ubuntu-latest
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: |
echo "Building ${{ env.BIN }}.exe"
make tools
rm -rf winres
cp -rp packaging/windows/winres .
./tools/go-winres make --arch 386,amd64,arm64
cp rsrc_windows*.syso cmd/snclient/
GOOS=${{ matrix.go-os }} GOARCH=${{ matrix.go-arch }} make build
mv snclient snclient.exe
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}"
path: "snclient.exe"
if-no-files-found: error
sign-win:
strategy:
fail-fast: false
matrix:
go-os: [windows]
go-arch: [i386, x86_64, aarch64]
needs: [get-version, build-win]
runs-on: windows-latest
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
certhash: ${{ secrets.WIN_SIGN_CERTHASH }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
path: "."
- name: "Sign snclient.exe"
if: ${{ env.certhash != '' }}
uses: sni/[email protected]
with:
certificate: '${{ secrets.WIN_SIGN_CERTIFICATE }}'
cert-password: '${{ secrets.WIN_SIGN_PASSWORD }}'
cert-sha1: '${{ secrets.WIN_SIGN_CERTHASH }}'
cert-description: 'SNClient+ Agent (https://omd.consol.de/docs/snclient/)'
timestamp-server: 'http://timestamp.digicert.com'
folder: "./"
- name: "Verify snclient.exe"
if: ${{ env.certhash != '' }}
run: |
Write-Host "Verify snclient.exe"
& "C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe" verify /pa snclient.exe
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}"
path: "snclient.exe"
if-no-files-found: error
overwrite: true
dist-linux-osx:
needs: [get-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: sudo apt-get update
- run: sudo apt-get install help2man tofrodos
- run: |
echo "Creating dist folder for linux/osx"
make dist
rm dist/snclient
- uses: actions/[email protected]
with:
name: "dist"
path: "dist"
if-no-files-found: error
dist-win:
needs: [get-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- run: sudo apt-get update
- run: sudo apt-get install help2man tofrodos
- run: |
echo "Creating dist folder for windows"
make windist
rm dist/snclient
- uses: actions/[email protected]
with:
name: "windist"
path: "windist"
if-no-files-found: error
pkg-msi:
strategy:
matrix:
go-os: [windows]
go-arch: [i386, x86_64, aarch64]
needs: [get-version, build-win, dist-win, sign-win]
runs-on: windows-latest
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
certhash: ${{ secrets.WIN_SIGN_CERTHASH }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
path: "windist"
- uses: actions/download-artifact@v4
with:
name: "windist"
path: "windist"
- run: |
Write-Host "Building ${{ env.BIN }}.msi"
# Set-PSDebug -Trace 2
& .\packaging\windows\build_msi.ps1 `
-out "${{ env.BIN }}.msi" `
-arch "${{ matrix.go-arch }}" `
-major "${{needs.get-version.outputs.major}}" `
-minor "${{needs.get-version.outputs.minor}}" `
-rev "${{needs.get-version.outputs.revision}}" `
-sha "${{ needs.get-version.outputs.sha }}"
- name: "Sign snclient.msi"
if: ${{ env.certhash != '' }}
uses: sni/[email protected]
with:
certificate: '${{ secrets.WIN_SIGN_CERTIFICATE }}'
cert-password: '${{ secrets.WIN_SIGN_PASSWORD }}'
cert-sha1: '${{ secrets.WIN_SIGN_CERTHASH }}'
cert-description: 'SNClient+ Agent (https://omd.consol.de/docs/snclient/)'
timestamp-server: 'http://timestamp.digicert.com'
folder: "./"
- name: "Verify snclient.msi"
if: ${{ env.certhash != '' }}
run: |
Write-Host "Verify snclient.msi"
& "C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe" verify /pa ${{ env.BIN }}.msi
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}.msi"
path: "${{ env.BIN }}.msi"
if-no-files-found: error
pkg-deb:
strategy:
matrix:
go-os: [linux]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version, build, dist-linux-osx]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
path: "dist"
- uses: actions/download-artifact@v4
with:
name: "dist"
path: "dist"
- run: sudo apt-get update
- run: sudo apt-get install devscripts
- run: |
echo "Building ${{ env.BIN }}.deb"
export DEBEMAIL="Sven Nierlein <[email protected]>"
export DEBFULLNAME="Sven Nierlein"
GOOS=${{ matrix.go-os }} GOARCH=${{ matrix.go-arch }} VERSION=${{needs.get-version.outputs.version}} make deb
mv snclient*.deb ${{ env.BIN }}.deb
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}.deb"
path: "${{ env.BIN }}.deb"
if-no-files-found: error
pkg-rpm:
strategy:
matrix:
go-os: [linux]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version, build, dist-linux-osx]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
path: "dist"
- uses: actions/download-artifact@v4
with:
name: "dist"
path: "dist"
- run: |
echo "Building ${{ env.BIN }}.rpm"
GOOS=${{ matrix.go-os }} GOARCH=${{ matrix.go-arch }} VERSION=${{needs.get-version.outputs.version}} make rpm
mv snclient*.rpm ${{ env.BIN }}.rpm
- uses: actions/[email protected]
with:
name: "${{ env.BIN }}.rpm"
path: "${{ env.BIN }}.rpm"
if-no-files-found: error
pkg-osx:
strategy:
matrix:
go-os: [darwin]
go-arch: [x86_64, aarch64]
runs-on: macos-latest
needs: [get-version, build-osx, dist-linux-osx]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
DIST: "snclient-${{needs.get-version.outputs.version}}-osx-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
path: "dist"
- uses: actions/download-artifact@v4
with:
name: "dist"
path: "dist"
- run: |
echo "Building ${{ env.DIST }}.pkg"
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
make osx
mv snclient*.pkg ${{ env.DIST }}.pkg
- uses: actions/[email protected]
with:
name: "${{ env.DIST }}.pkg"
path: "${{ env.DIST }}.pkg"
if-no-files-found: error
- uses: geekyeggo/delete-artifact@v5
with:
name: "${{ env.BIN }}"
# remove those artifacts which have been converted to .deb or .rpm files
clean-tmp-files:
strategy:
matrix:
go-os: [linux]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version,pkg-rpm,pkg-deb]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: "${{ env.BIN }}"
integration-test-linux:
strategy:
matrix:
go-os: [linux]
go-arch: [x86_64]
runs-on: ubuntu-latest
needs: [get-version,pkg-deb]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.deb"
- name: "Linux Integration Tests"
run: |
mv ${{ env.BIN }}.deb t/snclient.deb
cd t
SNCLIENT_INSTALL_TEST=1 go test -v
integration-test-osx:
strategy:
matrix:
go-os: [darwin]
go-arch: [x86_64]
runs-on: macos-latest
needs: [get-version,pkg-osx]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-osx-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.pkg"
- name: "OSX Integration Tests"
run: |
mv ${{ env.BIN }}.pkg t/snclient.pkg
cd t
SNCLIENT_INSTALL_TEST=1 go test -v
integration-test-windows:
strategy:
matrix:
go-os: [windows]
go-arch: [x86_64]
runs-on: windows-latest
needs: [get-version,pkg-msi]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- uses: actions/download-artifact@v4
with:
name: "windist"
path: "windist"
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
path: "windist"
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.msi"
- name: "Windows Integration Tests"
run: |
Move-Item -Path ${{ env.BIN }}.msi -Destination .\t\snclient.msi
Copy-Item .\windist\windows_exporter-amd64.exe .\windist\windows_exporter.exe
cd t
$env:SNCLIENT_INSTALL_TEST = 1
go test -v ; if ($LASTEXITCODE -ne 0) { exit 1 }
shell: powershell
# remove tmp artifacts
clean-tmp-dist:
runs-on: ubuntu-latest
needs: [integration-test-linux, integration-test-osx, integration-test-windows]
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: |
dist
windist
clean-tmp-winbin:
strategy:
matrix:
go-os: [windows]
go-arch: [i386, x86_64, aarch64]
needs: [get-version, integration-test-windows]
runs-on: windows-latest
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.BIN }}
make-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [get-version,pkg-msi,pkg-deb,pkg-rpm,pkg-osx,integration-test-linux,integration-test-windows, integration-test-osx, test, test-win, test-osx]
outputs:
release-upload-url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- run: make release_notes.txt
- id: create-release
uses: softprops/action-gh-release@v2
with:
name: "v${{needs.get-version.outputs.version}}"
tag_name: "v${{needs.get-version.outputs.version}}"
draft: true
body_path: "release_notes.txt"
upload-windows-release-assets:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
go-os: [windows]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version,make-release]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.msi"
- run: gh release upload v${{needs.get-version.outputs.version}} ${{ env.BIN }}.msi
upload-linux-deb-assets:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
go-os: [linux]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version,make-release]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.deb"
- run: gh release upload v${{needs.get-version.outputs.version}} ${{ env.BIN }}.deb
upload-linux-rpm-assets:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
go-os: [linux]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version,make-release]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.rpm"
- run: gh release upload v${{needs.get-version.outputs.version}} ${{ env.BIN }}.rpm
upload-osx-pkg-assets:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
go-os: [darwin]
go-arch: [x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version,make-release]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-osx-${{ matrix.go-arch }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}.pkg"
- run: gh release upload v${{needs.get-version.outputs.version}} ${{ env.BIN }}.pkg
upload-binary-release-assets:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
go-os: [freebsd]
go-arch: [i386, x86_64, aarch64]
runs-on: ubuntu-latest
needs: [get-version,make-release]
env:
BIN: "snclient-${{needs.get-version.outputs.version}}-${{ matrix.go-os }}-${{ matrix.go-arch }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: "${{ env.BIN }}"
- run: tar cvzf ./${{ env.BIN }}.tar.gz ./*
- run: gh release upload v${{needs.get-version.outputs.version}} ${{ env.BIN }}.tar.gz