-
Notifications
You must be signed in to change notification settings - Fork 62
914 lines (868 loc) · 36.1 KB
/
glpi-agent-packaging.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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
name: GLPI Agent Packaging
# Set publish_development_build to "yes" to publish development builds as pre-release
# Set number_of_development_build_to_keep to the number of development build to keep
# Set number_of_nightly_build_to_keep to the number of nightly release to keep
# Set number_of_nightly_build_to_keep to 0 to not publish nightly builds
env:
publish_development_build: no
number_of_development_build_to_keep: 3
number_of_nightly_build_to_keep: 3
macosx_notarize_support: yes
on:
push:
pull_request:
branches:
- develop
schedule:
- cron: '10 1 * * *'
workflow_dispatch:
inputs:
nightly:
description: 'Nightly publishing'
required: true
default: true
type: boolean
jobs:
setup-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
upload_url: ${{ steps.create-tagged-release.outputs.upload_url }}
create-release: ${{ steps.set-version.outputs.create-release }}
tag_name: ${{ steps.set-version.outputs.tag_name }}
build: ${{ steps.set-version.outputs.build }}
releaseid: ${{ steps.create-tagged-release.outputs.id }}
user-name: ${{ steps.set-version.outputs.user-name }}
user-email: ${{ steps.set-version.outputs.user-email }}
win32-signing: ${{ steps.set-version.outputs.win32-signing }}
macosx-signing: ${{ steps.set-version.outputs.macosx-signing }}
macosx-notarization: ${{ steps.set-version.outputs.macosx-notarization }}
steps:
- uses: actions/checkout@v3
- name: Set version
id: set-version
run: |
if [ "${{ vars.WIN32_SIGNING }}" == "no" ]; then
echo "win32-signing=no" >>$GITHUB_OUTPUT
elif [ -n "$CODESIGN_COMMAND" ]; then
echo "win32-signing=alt" >>$GITHUB_OUTPUT
elif [ -n "$CST_USERNAME" ]; then
echo "win32-signing=cst" >>$GITHUB_OUTPUT
else
echo "win32-signing=no" >>$GITHUB_OUTPUT
fi
if [ -n "$APPSIGNID" -a -n "$INSTSIGNID" ]; then
echo "macosx-signing=yes" >>$GITHUB_OUTPUT
if [ "${{ env.macosx_notarize_support }}" == "yes" -a "${{ vars.MACOSX_NOTARIZE }}" != "no" ]; then
NOTARIZE="yes"
else
NOTARIZE="no"
fi
else
echo "macosx-signing=no" >>$GITHUB_OUTPUT
NOTARIZE="no"
fi
if [ -z "${GITHUB_REF##*refs/tags/*}" ]; then
# Abort publishing if MACOSX_SIGNING variable was set to "no"
if [ "${{ vars.MACOSX_SIGNING }}" == "no" -a -n "$APPSIGNID" -a -n "$INSTSIGNID" ]; then
echo "MACOSX_SIGNING has been disabled in GH variables. Fix it before publishing." >&2
exit 1
fi
# Abort publishing if MACOSX_NOTARIZE variable was set to "no"
if [ "${{ vars.MACOSX_NOTARIZE }}" == "no" -a "$NOTARIZE" == "yes" ]; then
echo "MACOSX_NOTARIZE has been disabled in GH variables. Fix it before publishing." >&2
exit 1
fi
VERSION="${GITHUB_REF#*refs/tags/}"
echo "New release on $VERSION $tag"
echo "create-release=yes" >>$GITHUB_OUTPUT
echo "build=yes" >>$GITHUB_OUTPUT
echo "tag_name=$VERSION" >>$GITHUB_OUTPUT
else
VERSION=$(perl -Ilib -MGLPI::Agent::Version -e 'print $GLPI::Agent::Version::VERSION')
VERSION=${VERSION%-dev}-git${GITHUB_SHA:0:8}
if [ "${{ github.event_name }}" = "schedule" -o "${{ inputs.nightly }}" = "true" -o "${{ env.publish_development_build }}" = "yes" ]; then
if [ "${{ github.event_name }}" = "schedule" -o "${{ inputs.nightly }}" = "true" ]; then
TYPE=nightly
if [ -z "$PUBLISHING_TOKEN" ]; then
echo "No PUBLISHING_TOKEN defined to publish GLPI-Agent nightly builds"
echo "create-release=no" >>$GITHUB_OUTPUT
echo "build=no" >>$GITHUB_OUTPUT
exit 0
elif gh api /repos/{owner}/glpi-project.github.io/git/refs/tags/glpi-agent-development-$VERSION --silent 2>/dev/null; then
echo "GLPI-Agent v$VERSION still published as development build"
echo "create-release=no" >>$GITHUB_OUTPUT
echo "build=no" >>$GITHUB_OUTPUT
exit 0
fi
else
TYPE=development
fi
SKIP_NIGHTLY="${{ env.number_of_nightly_build_to_keep }} $TYPE"
# For nightly, we also check if we had any commit during the last 24 hours unless it is a manually forced run for which INPUT_NIGHTLY should be set
if [ -z "$INPUT_NIGHTLY" -a "$SKIP_NIGHTLY" = "0 nightly" -o -z "$( git rev-list -n 1 --after="24 hours" ${{ github.sha }} )" ]; then
echo "No nightly release needed"
echo "create-release=no" >>$GITHUB_OUTPUT
echo "build=no" >>$GITHUB_OUTPUT
else
echo "New $TYPE release as $VERSION version"
echo "create-release=${{ env.publish_development_build }}" >>$GITHUB_OUTPUT
echo "build=yes" >>$GITHUB_OUTPUT
echo "tag_name=$TYPE-$VERSION" >>$GITHUB_OUTPUT
fi
else
echo "Just building $VERSION version"
echo "create-release=no" >>$GITHUB_OUTPUT
echo "build=yes" >>$GITHUB_OUTPUT
echo "tag_name=development-$VERSION" >>$GITHUB_OUTPUT
NOTARIZE="no"
fi
fi
echo "version=$VERSION" >>$GITHUB_OUTPUT
case "${VERSION#*-}" in
$VERSION)
echo "revname=v$VERSION" >>$GITHUB_OUTPUT
echo "prerelease=false" >>$GITHUB_OUTPUT
;;
test*)
echo "revname=v${VERSION%-test*} Test release ${VERSION#*-test}" >>$GITHUB_OUTPUT
echo "prerelease=true" >>$GITHUB_OUTPUT
;;
beta*)
echo "revname=v${VERSION%-beta*} Beta release ${VERSION#*-beta}" >>$GITHUB_OUTPUT
echo "prerelease=true" >>$GITHUB_OUTPUT
;;
*)
echo "revname=v$VERSION Development release" >>$GITHUB_OUTPUT
echo "prerelease=true" >>$GITHUB_OUTPUT
;;
esac
# Check if MacOSX packaging notarization is required
echo "macosx-notarization=$NOTARIZE" >>$GITHUB_OUTPUT
# Set user and mail for nightly release
echo "user-name=$(git log --format='%an' HEAD^!)" >>$GITHUB_OUTPUT
echo "user-email=$(git log --format='%ae' HEAD^!)" >>$GITHUB_OUTPUT
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISHING_TOKEN: ${{ secrets.PUBLISHING_TOKEN }}
CODESIGN_COMMAND: ${{ secrets.CODESIGN_COMMAND }}
CST_USERNAME: ${{ secrets.CST_USERNAME }}
APPSIGNID: ${{ vars.MACOSX_APPSIGNID }}
INSTSIGNID: ${{ vars.MACOSX_INSTSIGNID }}
- name: Generate release description
id: github-release-body
if: ${{ steps.set-version.outputs.create-release == 'yes' }}
run: |
tools/github-release-description.sh --version ${{ steps.set-version.outputs.version }} --tag ${{ steps.set-version.outputs.tag_name }}
shell: bash
- name: Create Tagged Release
id: create-tagged-release
uses: actions/create-release@v1
if: ${{ steps.set-version.outputs.create-release == 'yes' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.set-version.outputs.tag_name }}
release_name: GLPI Agent ${{ steps.set-version.outputs.revname }}
body_path: release-description.md
draft: true
prerelease: ${{ steps.set-version.outputs.prerelease }}
windows-packaging:
runs-on: windows-latest
strategy:
matrix:
arch: [ x64, x86 ]
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: setup-release
steps:
- uses: actions/checkout@v3
- name: Create folders for cached datas
run: |
mkdir C:\Strawberry-perl-for-GLPI-Agent_build\restore
mkdir C:\Strawberry-perl-for-GLPI-Agent_build\tools
shell: cmd
- name: Restore points cache
uses: actions/cache@v3
with:
path: |
C:/Strawberry-perl-for-GLPI-Agent_build/tools
C:/Strawberry-perl-for-GLPI-Agent_build/restore
key: windows-packaging-cache-${{ matrix.arch }}-${{ hashFiles('contrib\windows\glpi-agent-packaging.pl', 'contrib\windows\packaging\*') }}
- name: List files in cached paths
if: success() || failure()
run: |
dir C:\Strawberry-perl-for-GLPI-Agent_build\restore
dir C:\Strawberry-perl-for-GLPI-Agent_build\tools
shell: cmd
- name: Update environment
run: |
echo 'C:\Strawberry\perl\bin' >> $GITHUB_PATH
echo 'C:\Strawberry\perl\site\bin' >> $GITHUB_PATH
echo 'C:\Strawberry\c\bin' >> $GITHUB_PATH
shell: bash
- name: Show environment
run: |
echo "PATH=%PATH%"
perl --version
perl -V
shell: cmd
- name: Install Module::Install
run: cpan -T Module::Install
shell: cmd
- name: Prepare Makefile
run: perl Makefile.PL
shell: cmd
- name: Install Perl::Dist::Strawberry
run: |
cpanm --notest --verbose Perl::Dist::Strawberry
shell: cmd
- name: Fix Perl::Dist::Strawberry for perl 5.34
run: |
perl -i -pe "s/makefile.mk/Makefile/" C:\Strawberry\perl\site\lib\Perl\Dist\Strawberry\Step\InstallPerlCore.pm
shell: cmd
- name: Fix Perl::Dist::Strawberry to support patching perl 5.34
run: |
perl -i -pe "s/use Text::Diff;/use Text::Diff;use Text::Patch;/" C:\Strawberry\perl\site\lib\Perl\Dist\Strawberry\Step.pm
shell: cmd
- name: Build package
run: |
perl contrib\windows\glpi-agent-packaging.pl --arch ${{ matrix.arch }}
shell: cmd
- name: MSI Signing (CST)
if: ${{ needs.setup-release.outputs.win32-signing == 'cst' }}
run: |
perl tools\msi-signing.pl "C:\Strawberry-perl-for-GLPI-Agent_build" "GLPI-Agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.msi"
shell: cmd
env:
CST_USERNAME: ${{ secrets.CST_USERNAME }}
CST_PASSWORD: ${{ secrets.CST_PASSWORD }}
CST_SECRET: ${{ secrets.CST_SECRET }}
CST_CREDENTIALID: ${{ secrets.CST_CREDENTIALID }}
- name: MSI Signing (ALT)
if: ${{ needs.setup-release.outputs.win32-signing == 'alt' }}
run: |
cd "C:\\Strawberry-perl-for-GLPI-Agent_build"
umask 0077
mkdir ~/.ssh
echo "$CODESIGN_KNOWNHOST" > ~/.ssh/known_hosts
echo "$CODESIGN_PRIVATE" > private.key
umask 0002
MSI="GLPI-Agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.msi"
cat "output\\$MSI" | $CODESIGN_COMMAND codesign "$MSI" > "$MSI"
rm -f private.key ~/.ssh/known_hosts "output\\$MSI"
mv -vf "$MSI" "output\\$MSI"
shell: bash
env:
CODESIGN_KNOWNHOST: ${{ secrets.CODESIGN_KNOWNHOST }}
CODESIGN_COMMAND: ${{ secrets.CODESIGN_COMMAND }}
CODESIGN_PRIVATE: ${{ secrets.CODESIGN_PRIVATE }}
- name: List generated files
if: success() || failure()
run: |
dir C:\Strawberry-perl-for-GLPI-Agent_build\output
shell: cmd
- name: Upload windows built artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: Windows-Build
path: C:\Strawberry-perl-for-GLPI-Agent_build\output
- name: Upload debug MSI-Build artifacts
if: failure() #success() || failure() # Only enable on failure or when debugging is required
uses: actions/upload-artifact@v3
with:
name: MSI-Build-Debug
path: C:\Strawberry-perl-for-GLPI-Agent_build\build\msi
- name: VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v3
if: ${{ needs.setup-release.outputs.create-release == 'yes' || startsWith(needs.setup-release.outputs.tag_name, 'nightly') }}
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
files: |
C:\Strawberry-perl-for-GLPI-Agent_build\output\GLPI-Agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.msi
C:\Strawberry-perl-for-GLPI-Agent_build\output\glpi-agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.zip
- name: VirusTotal Report Analysis
if: ${{ vars.VT_SKIP_REPORT_ANALYSIS != 'yes' && ( needs.setup-release.outputs.create-release == 'yes' || startsWith(needs.setup-release.outputs.tag_name, 'nightly') ) }}
run: |
perl tools\virustotal-report-analysis.pl --path C:\Strawberry-perl-for-GLPI-Agent_build\output GLPI-Agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.msi glpi-agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.zip
shell: cmd
env:
VT_API_KEY: ${{ secrets.VT_API_KEY }}
- name: Upload VirusTotal Report
if: ${{ vars.VT_SKIP_REPORT_ANALYSIS != 'yes' && ( needs.setup-release.outputs.create-release == 'yes' || startsWith(needs.setup-release.outputs.tag_name, 'nightly') ) }}
uses: actions/upload-artifact@v3
with:
name: VirusTotal-Report
path: C:\Strawberry-perl-for-GLPI-Agent_build\output\*.json
- name: Upload Portable Archive Asset
id: upload-portable-archive-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup-release.outputs.upload_url }}
asset_path: C:\Strawberry-perl-for-GLPI-Agent_build\output\glpi-agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.zip
asset_name: glpi-agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.zip
asset_content_type: application/zip
- name: Upload MSI Installer Asset
id: upload-msi-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup-release.outputs.upload_url }}
asset_path: C:\Strawberry-perl-for-GLPI-Agent_build\output\GLPI-Agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.msi
asset_name: GLPI-Agent-${{ needs.setup-release.outputs.version }}-${{ matrix.arch }}.msi
asset_content_type: application/x-msi
macosx-packaging:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
arch: x86_64
- os: macos-latest
arch: arm64
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: setup-release
steps:
- uses: actions/checkout@v3
- name: Restore points cache
uses: actions/cache@v3
with:
path: |
contrib/macosx/*.gz
contrib/macosx/*.sha1
contrib/macosx/*.sha1.txt
contrib/macosx/munkipkg
contrib/macosx/build/perl*
contrib/macosx/build/openssl*
contrib/macosx/build/zlib*
contrib/macosx/build/Applications
key: macosx-packaging-restore-points-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('contrib/macosx/glpi-agent-packaging.sh') }}
- name: Import Application Signing Cert
id: application-signing-cert
uses: apple-actions/import-codesign-certs@v2
if: ${{ needs.setup-release.outputs.macosx-signing == 'yes' && vars.MACOSX_SIGNING != 'no' }}
with:
p12-file-base64: ${{ secrets.MACOSX_APPLICATION_P12 }}
p12-password: ${{ secrets.MACOSX_P12_PASSWORD }}
- name: Import Installer Signing Cert
id: installer-signing-cert
uses: apple-actions/import-codesign-certs@v2
if: ${{ needs.setup-release.outputs.macosx-signing == 'yes' && vars.MACOSX_SIGNING != 'no' }}
with:
p12-file-base64: ${{ secrets.MACOSX_INSTALLER_P12 }}
p12-password: ${{ secrets.MACOSX_P12_PASSWORD }}
create-keychain: false
keychain-password: ${{ steps.application-signing-cert.outputs.keychain-password }}
- name: Build package
run: |
# Handle repository variables to eventually disable code signing and notarization
if [ -n "${{ vars.MACOSX_SIGNING }}" -o -n "${{ vars.MACOSX_NOTARIZE }}" ]; then
echo "GH Variables:"
if [ -n "${{ vars.MACOSX_SIGNING }}" ]; then
echo " - MACOSX_SIGNING : ${{ vars.MACOSX_SIGNING }}"
if [ "${{ vars.MACOSX_SIGNING }}" == "no" ]; then
MACOSX_NOTARIZE="no"
unset APPSIGNID INSTSIGNID
fi
fi
if [ -n "${{ vars.MACOSX_NOTARIZE }}" ]; then
echo " - MACOSX_NOTARIZE: ${{ vars.MACOSX_NOTARIZE }}"
if [ "${{ vars.MACOSX_NOTARIZE }}" == "no" ]; then
MACOSX_NOTARIZE="no"
unset NOTARIZE_USER NOTARIZE_PASSWORD
fi
fi
fi
./contrib/macosx/glpi-agent-packaging.sh --arch ${{ matrix.arch }} --notarize $MACOSX_NOTARIZE
env:
APPSIGNID: ${{ vars.MACOSX_APPSIGNID }}
INSTSIGNID: ${{ vars.MACOSX_INSTSIGNID }}
NOTARIZE_USER: ${{ secrets.MACOSX_NOTARIZE_USER }}
NOTARIZE_PASSWORD: ${{ secrets.MACOSX_NOTARIZE_PASSWORD }}
MACOSX_NOTARIZE: ${{ needs.setup-release.outputs.macosx-notarization }}
shell: bash
- name: List generated files
if: success() || failure()
run: |
ls contrib/macosx/build
shell: bash
- name: Upload MacOSX built artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: MacOSX-Build
path: |
contrib/macosx/build/*.pkg
contrib/macosx/build/*.dmg
- name: Upload MacOSX Perl building debug artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: MacOSX-Perl-Config-${{ matrix.arch }}
path: |
contrib/macosx/build/perl-*/config.h
contrib/macosx/build/perl-*/config.sh
contrib/macosx/build/perl-*/cflags
contrib/macosx/build/perl-*/myconfig
contrib/macosx/build/perl-*/Makefile
contrib/macosx/build/perl-*/Policy.sh
contrib/macosx/build/perl-*/hints/darwin.sh
- name: Upload MacOSX PKG installer
id: upload-macosx-pkg-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup-release.outputs.upload_url }}
asset_path: contrib/macosx/build/GLPI-Agent-${{ needs.setup-release.outputs.version }}_${{ matrix.arch }}.pkg
asset_name: GLPI-Agent-${{ needs.setup-release.outputs.version }}_${{ matrix.arch }}.pkg
asset_content_type: application/octet-stream
- name: Upload MacOSX DMG installer image
id: upload-macosx-dmg-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup-release.outputs.upload_url }}
asset_path: contrib/macosx/build/GLPI-Agent-${{ needs.setup-release.outputs.version }}_${{ matrix.arch }}.dmg
asset_name: GLPI-Agent-${{ needs.setup-release.outputs.version }}_${{ matrix.arch }}.dmg
asset_content_type: application/octet-stream
linux-snap-packaging:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: setup-release
steps:
- uses: actions/checkout@v3
- uses: snapcore/action-build@v1
id: snapcraft
env:
TERM: ${{ env.TERM }}:${{ needs.setup-release.outputs.version }}
- name: Upload Snap built artifacts
uses: actions/upload-artifact@v3
with:
name: Snap-Build
path: ${{ steps.snapcraft.outputs.snap }}
- name: Upload Snap Package
id: upload-linux-snap-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup-release.outputs.upload_url }}
asset_path: ${{ steps.snapcraft.outputs.snap }}
asset_name: ${{ steps.snapcraft.outputs.snap }}
asset_content_type: application/octet-stream
linux-debian-packaging:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: setup-release
steps:
- uses: actions/checkout@v3
- name: Install build dependencies packages
run: |
sudo apt update
sudo apt -y install dpkg-dev debhelper libmodule-install-perl \
libclone-perl libdigest-sha-perl libfile-copy-recursive-perl \
libfile-which-perl libhttp-cookies-perl libhttp-daemon-perl \
libhttp-proxy-perl libhttp-server-simple-perl libdatetime-perl \
libhttp-server-simple-authen-perl libio-capture-perl \
libipc-run-perl libjson-pp-perl libnet-ip-perl \
libnet-snmp-perl libio-socket-ssl-perl libparse-edid-perl \
libproc-daemon-perl libparallel-forkmanager-perl \
libtest-compile-perl libtest-deep-perl libtest-nowarnings-perl \
libtest-exception-perl libtest-mockmodule-perl \
libtest-mockobject-perl libtext-template-perl \
libsocket-getaddrinfo-perl libuniversal-require-perl liburi-perl \
libwww-perl libxml-libxml-perl libyaml-perl \
libossp-uuid-perl libcpanel-json-xs-perl devscripts
shell: bash
- name: Build debian packages
id: debbuild
run: |
echo "debpath=$(dirname $PWD)" >>$GITHUB_OUTPUT
# make -gitXXXXXXXX release when not tagged
if [ -z "${VERSION##*-*}" ]; then
tools/make-release.sh --no-git $VERSION
fi
dpkg-buildpackage -d -b --no-sign
shell: bash
env:
VERSION: ${{ needs.setup-release.outputs.version }}
- name: Run lintian
run: |
sudo apt -y install lintian
lintian --profile debian --show-overrides -L ">=pedantic"
shell: bash
- name: Upload built deb artifacts
uses: actions/upload-artifact@v3
with:
name: Debian-Build
path: |
${{ steps.debbuild.outputs.debpath }}/*.deb
${{ steps.debbuild.outputs.debpath }}/*.buildinfo
${{ steps.debbuild.outputs.debpath }}/*.changes
- name: Upload Deb Packages
id: upload-linux-deb-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
run: |
gh release upload ${{ needs.setup-release.outputs.tag_name }} ../*.deb
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-rpm-packaging:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: setup-release
steps:
- uses: actions/checkout@v3
- name: Install build dependencies packages
run: |
sudo apt update
sudo apt -y install rpm devscripts \
libfile-which-perl libuniversal-require-perl libmodule-install-perl
shell: bash
- name: Build rpm packages
id: rpmbuild
run: |
contrib/unix/glpi-agent-rpm-build.sh --nodeps
shell: bash
- name: Test rpm local install & uninstall
run: |
sudo rpm -ivh --nodeps ${{ steps.rpmbuild.outputs.glpi-agent-rpm }} \
${{ steps.rpmbuild.outputs.glpi-agent-task-network-rpm }} \
${{ steps.rpmbuild.outputs.glpi-agent-task-collect-rpm }} \
${{ steps.rpmbuild.outputs.glpi-agent-task-deploy-rpm }} \
${{ steps.rpmbuild.outputs.glpi-agent-task-wakeonlan-rpm }} \
${{ steps.rpmbuild.outputs.glpi-agent-task-esx-rpm }} \
${{ steps.rpmbuild.outputs.glpi-agent-cron-rpm }}
sudo rpm -e glpi-agent glpi-agent-task-network glpi-agent-task-collect \
glpi-agent-task-deploy glpi-agent-task-wakeonlan \
glpi-agent-task-esx glpi-agent-cron
shell: bash
- name: Upload built rpm artifacts
uses: actions/upload-artifact@v3
with:
name: RPM-Build
path: |
${{ steps.rpmbuild.outputs.rpmdir }}/noarch/*.rpm
- name: Upload rpm sources artifacts
uses: actions/upload-artifact@v3
with:
name: RPM-Sources
path: |
${{ steps.rpmbuild.outputs.srpmdir }}/*.rpm
${{ steps.rpmbuild.outputs.srcdir }}/glpi-agent-*.tar.gz
- name: Upload RPM Packages
id: upload-linux-rpm-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
run: |
RPMDIR=`rpm --eval "%{_rpmdir}"`
gh release upload ${{ needs.setup-release.outputs.tag_name }} $RPMDIR/*/*.rpm
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-installer:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: [ setup-release, linux-snap-packaging, linux-debian-packaging, linux-rpm-packaging ]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: RPM-Build
- uses: actions/download-artifact@v3
with:
name: Debian-Build
- uses: actions/download-artifact@v3
with:
name: Snap-Build
- name: Build installer
id: installer-build
run: |
contrib/unix/make-linux-installer.sh --version $VERSION --rpm *.rpm \
contrib/unix/glpi-agent.init.redhat \
--deb *.deb --snap *.snap
mv glpi-agent-$VERSION-linux-installer.pl glpi-agent-$VERSION-with-snap-linux-installer.pl
contrib/unix/make-linux-installer.sh --version $VERSION --rpm *.rpm \
contrib/unix/glpi-agent.init.redhat \
--deb *.deb
ls -l
sha1sum *.rpm *.deb *.snap *.pl
sha256sum *.rpm *.deb *.snap *.pl
shell: bash
env:
VERSION: ${{ needs.setup-release.outputs.version }}
- name: Upload built installer artifacts
uses: actions/upload-artifact@v3
with:
name: Linux-Installer-Build
path: |
glpi-agent-*-linux-installer.pl
- name: Upload linux installers
id: upload-linux-installer-assets
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
run: |
gh release upload ${{ needs.setup-release.outputs.tag_name }} glpi-agent-*-linux-installer.pl
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-appimage:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: [ setup-release, linux-debian-packaging ]
steps:
- uses: actions/checkout@v3
# We use AppImage Builder development version as 1.1 is failing
- name: Install AppImage Builder development version
id: install-appimage-builder
run: |
pip3 install git+https://github.com/AppImageCrafters/appimage-builder.git
shell: bash
- uses: actions/download-artifact@v3
with:
name: Debian-Build
- name: Make AppImage
id: make-appimage
run: |
contrib/unix/make-linux-appimage.sh --version $VERSION
shell: bash
env:
VERSION: ${{ needs.setup-release.outputs.version }}
- name: Quick tests
run: |
echo ====
echo Install libfuse2 as required by AppImage
sudo apt update
sudo apt -y install libfuse2
echo ====
echo Installer version:
./glpi-agent-$VERSION-x86_64.AppImage --version
echo ====
echo Embedded perl version:
./glpi-agent-$VERSION-x86_64.AppImage --perl --version
echo ====
echo Embedded GLPI Agent version:
./glpi-agent-$VERSION-x86_64.AppImage --script=glpi-agent --version
echo ====
env:
VERSION: ${{ needs.setup-release.outputs.version }}
- name: Upload built installer artifacts
uses: actions/upload-artifact@v3
with:
name: Linux-AppImage-Build
path: |
*.AppImage
*.AppImage.zsync
- name: Upload linux AppImage
id: upload-linux-appimage-assets
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
run: |
unset FILES
for file in *.AppImage{,.zsync}
do
[ -e "$file" ] && FILES="$FILES $file"
done
gh release upload ${{ needs.setup-release.outputs.tag_name }} $FILES
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sources:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.build == 'yes' }}
needs: setup-release
steps:
- uses: actions/checkout@v3
- name: Install build dependencies packages
run: |
sudo apt update
sudo apt -y install libmodule-install-perl libuniversal-require-perl \
libwww-perl libdigest-sha-perl
shell: bash
- name: Build sources archive
id: srcbuild
run: |
# make -gitXXXXXXXX release when not tagged
if [ -z "${VERSION##*-*}" ]; then
tools/make-release.sh --no-git --no-deb-changelog $VERSION
fi
perl Makefile.PL
make manifest
make
make dist DISTVNAME=GLPI-Agent-$VERSION
shell: bash
env:
VERSION: ${{ needs.setup-release.outputs.version }}
- name: Upload built archive artifacts
uses: actions/upload-artifact@v3
with:
name: Sources
path: |
GLPI-Agent-*.tar.gz
- name: Upload Sources Archive
id: upload-sources-asset
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
run: |
gh release upload ${{ needs.setup-release.outputs.tag_name }} GLPI-Agent-*.tar.gz
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-release:
runs-on: ubuntu-latest
if: ${{ needs.setup-release.outputs.create-release == 'yes' }}
needs: [ setup-release, windows-packaging, macosx-packaging, linux-snap-packaging, linux-debian-packaging, linux-rpm-packaging, linux-installer, sources ]
steps:
- uses: actions/checkout@v3
- name: Publish release
id: publish-release
run: |
gh api /repos/{owner}/{repo}/releases/${{ needs.setup-release.outputs.releaseid }} \
--method PATCH --field draft=false --jq '{id: .id, name: .name, tag_name: .tag_name, target_commitish: .target_commitish, draft: .draft, prerelease: .prerelease, body: .body}'
# Only keep a given number of development or nightly releases
case "${{ needs.setup-release.outputs.tag_name }}" in
development-release-*)
let COUNT=${{ env.number_of_development_build_to_keep }}
TYPE=development
;;
nightly-release-*)
let COUNT=${{ env.number_of_nightly_build_to_keep }}
TYPE=nightly
;;
*)
exit 0
;;
esac
gh api /repos/{owner}/{repo}/releases --jq '.[].id' | \
while read id
do
set x $(gh api /repos/{owner}/{repo}/releases/$id --jq '.draft,.tag_name,.name')
shift
DRAFT="$1"
shift
TAG="$1"
[ -n "$TAG" -a -z "${TAG%$TYPE-release*}" ] || continue
shift
if (( COUNT-- > 0 )); then
echo "Keeping $* $TYPE release ($TAG)"
else
echo "Removing $* $TYPE release ($TAG)"
gh api /repos/{owner}/{repo}/releases/$id --method DELETE
if [ "$DRAFT" != "true" ]; then
echo "Removing $TAG tag"
gh api /repos/{owner}/{repo}/git/refs/tags/$TAG --method DELETE
fi
fi
done
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-nightly:
runs-on: ubuntu-latest
#if: ${{ needs.setup-release.outputs.create-release == 'no' && needs.setup-release.outputs.build == 'yes' }}
if: ${{ needs.setup-release.outputs.create-release == 'no' && needs.setup-release.outputs.build == 'yes' && startsWith(needs.setup-release.outputs.tag_name, 'nightly') }}
needs: [ setup-release, windows-packaging, macosx-packaging, linux-snap-packaging, linux-debian-packaging, linux-rpm-packaging, linux-installer, sources ]
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/glpi-project.github.io
token: ${{ secrets.PUBLISHING_TOKEN }}
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: Linux-Installer-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: RPM-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: Debian-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: Snap-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: Linux-AppImage-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: MacOSX-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: Windows-Build
path: glpi-agent
- uses: actions/download-artifact@v3
with:
name: Sources
path: glpi-agent
- name: Cleanup nightly
run: |
# Clean up Debian-Build
rm -f glpi-agent/*.buildinfo glpi-agent/*.changes
# Clean up Windows-Build
rm -f glpi-agent/*_debug_dir.zip
ls -lt glpi-agent
shell: bash
- name: Publish nightly
id: publish-nightly
run: |
# Only keep a given number of nightly releases
TAGNAME="${{ needs.setup-release.outputs.tag_name }}"
[ -z "$TAGNAME" ] && TAGNAME="development-${{ needs.setup-release.outputs.version }}"
case "$TAGNAME" in
development-*)
let COUNT=${{ env.number_of_development_build_to_keep }}
;;
nightly-*)
let COUNT=${{ env.number_of_nightly_build_to_keep }}
;;
*)
let COUNT=1
;;
esac
# Get script to prepare page
curl -L -s -o github-nightly-description.sh https://github.com/glpi-project/glpi-agent/raw/develop/tools/github-nightly-description.sh
chmod +x github-nightly-description.sh
./github-nightly-description.sh --header --version ${{ needs.setup-release.outputs.version }} >index.md.new
git config --local user.email "${{ needs.setup-release.outputs.user-email }}"
git config --local user.name "${{ needs.setup-release.outputs.user-name }}"
egrep '^# ' glpi-agent/index.md | \
while read dash agent version x
do
VERSION="${version#v}"
if (( --COUNT > 0 )); then
echo "Keeping glpi-agent $VERSION build"
read date time tz <<<$(git log -n1 --pretty=%ci -- glpi-agent/glpi-agent_${VERSION}_all.deb)
./github-nightly-description.sh --version $VERSION --date "$date $time UTC" >>index.md.new
else
echo "Removing glpi-agent $VERSION build"
git filter-branch --prune-empty -f --index-filter "git rm --cached --ignore-unmatch glpi-agent/*$VERSION*" HEAD
fi
done
mv -vf index.md.new glpi-agent/index.md
rm -f github-nightly-description.sh
echo "Repository status:"
git status
ls -lt glpi-agent
# Prepare commit
echo "Adding GLPI-Agent ${{ needs.setup-release.outputs.version }} build"
git add glpi-agent/*
git commit -m "Add GLPI-Agent ${{ needs.setup-release.outputs.version }} build"
# Force commit
git push --force
git status
shell: bash
env:
FILTER_BRANCH_SQUELCH_WARNING: 1