-
Notifications
You must be signed in to change notification settings - Fork 1
628 lines (521 loc) · 19.3 KB
/
go-build.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
name: Build and Package
on:
push:
branches:
- 'master'
- 'test/**'
permissions:
contents: write
defaults:
run:
shell: bash
env:
RELEASE: ${{ github.run_number }}
CGO_ENABLED: 0
jobs:
build_windows:
name: "Build Windows"
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Go
uses: WillAbides/setup-go-faster@a0ff5217a7d2567ed6ff1aa2b7d8f9d58173b2c9 # v1.14.0
with:
go-version-file: 'go.mod'
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Copy syso files
run: |
cp -r ci/pkg/windows/syso/* .
- name: Build AMD64
run: >-
env
GOARCH=amd64
GOOS=windows
go build -a -v -trimpath -mod=readonly -modcacherw
-ldflags="-H=windowsgui -s -w -X main.version=${VERSION}"
-o bin/pinnacle-windows-amd64.exe
.
- name: Build ARM64
run: >-
env
GOARCH=arm64
GOOS=windows
go build -a -v -trimpath -mod=readonly -modcacherw
-ldflags="-H=windowsgui -s -w -X main.version=${VERSION}"
-o bin/pinnacle-windows-arm64.exe
.
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@62cf5bd3e4211a0a0b51f2c6d6a37129d828611d # v2.1.5
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@f0990588f1e5b5af6827153b93673613abdc6ec7 # v2.1.1
- name: Download jsign
run: ./ci/scripts/download-jsign.sh
- name: Decode certificate
run: |
echo "${{ secrets.CERTFILE_BASE64 }}" | base64 --decode > pinnacle-certificate.pem
- name: Sign AMD64
env:
GCP_KEYSTORE: ${{ secrets.GCP_KEYSTORE }}
GCP_KEY_ALIAS: ${{ secrets.GCP_KEY_ALIAS }}
run: ./ci/scripts/sign.sh "bin/pinnacle-windows-amd64.exe"
- name: Sign ARM64
env:
GCP_KEYSTORE: ${{ secrets.GCP_KEYSTORE }}
GCP_KEY_ALIAS: ${{ secrets.GCP_KEY_ALIAS }}
run: ./ci/scripts/sign.sh "bin/pinnacle-windows-arm64.exe"
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: windows-binaries
path: bin
retention-days: 1
if-no-files-found: error
build_linux:
name: "Build Linux"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install dependencies
run: >-
sudo apt-get update
- name: Set up Go
uses: WillAbides/setup-go-faster@a0ff5217a7d2567ed6ff1aa2b7d8f9d58173b2c9 # v1.14.0
with:
go-version-file: 'go.mod'
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Build AMD64
run: >-
env
GOARCH=amd64
GOOS=linux
go build -a -v -trimpath -buildmode=pie -mod=readonly -modcacherw
-ldflags="-s -w -X main.version=${VERSION}"
-o bin/pinnacle-linux-amd64
.
- name: Build ARM64
run: >-
env
GOARCH=arm64
GOOS=linux
go build -a -v -trimpath -buildmode=pie -mod=readonly -modcacherw
-ldflags="-s -w -X main.version=${VERSION}"
-o bin/pinnacle-linux-arm64
.
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: linux-binaries
path: bin
retention-days: 1
if-no-files-found: error
build_macos:
name: "Build MacOS"
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Go
uses: WillAbides/setup-go-faster@a0ff5217a7d2567ed6ff1aa2b7d8f9d58173b2c9 # v1.14.0
with:
go-version-file: 'go.mod'
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Build AMD64
run: >-
env
GOARCH=amd64
GOOS=darwin
go build -a -v -trimpath -buildmode=pie -mod=readonly -modcacherw
-ldflags="-s -w -X main.version=${VERSION}"
-o bin/pinnacle-darwin-amd64
.
- name: Build ARM64
run: >-
env
GOARCH=arm64
GOOS=darwin
go build -a -v -trimpath -buildmode=pie -mod=readonly -modcacherw
-ldflags="-s -w -X main.version=${VERSION}"
-o bin/pinnacle-darwin-arm64
.
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: macos-binaries
path: bin
retention-days: 1
if-no-files-found: error
package_windows:
name: "Package Windows"
runs-on: windows-latest
needs: [ build_windows ]
steps:
- name: Checkout .iss files
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
sparse-checkout: |
ci/pkg/windows
ci/scripts
VERSION
- name: Download binaries
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: windows-binaries
path: bin
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Package AMD64 with InnoSetup
run: |
AMD_ISS=ci/pkg/windows/iss/PackagePinnacle-amd64.iss
sed -i "s/#define MyAppVersion \"1.0.0\"/#define MyAppVersion \"${VERSION}\"/" "$AMD_ISS"
iscc.exe "$AMD_ISS"
- name: Package ARM64 with InnoSetup
run: |
ARM_ISS=ci/pkg/windows/iss/PackagePinnacle-arm64.iss
sed -i "s/#define MyAppVersion \"1.0.0\"/#define MyAppVersion \"${VERSION}\"/" "$ARM_ISS"
iscc.exe "$ARM_ISS"
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@62cf5bd3e4211a0a0b51f2c6d6a37129d828611d # v2.1.5
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@f0990588f1e5b5af6827153b93673613abdc6ec7 # v2.1.1
- name: Download jsign
run: ./ci/scripts/download-jsign.sh
- name: Decode certificate
run: |
echo "${{ secrets.CERTFILE_BASE64 }}" | base64 --decode > pinnacle-certificate.pem
- name: Sign AMD64
env:
GCP_KEYSTORE: ${{ secrets.GCP_KEYSTORE }}
GCP_KEY_ALIAS: ${{ secrets.GCP_KEY_ALIAS }}
run: ./ci/scripts/sign.sh "build/out/AlpineClientSetup-${VERSION}-x86_64.exe"
- name: Sign ARM64
env:
GCP_KEYSTORE: ${{ secrets.GCP_KEYSTORE }}
GCP_KEY_ALIAS: ${{ secrets.GCP_KEY_ALIAS }}
run: ./ci/scripts/sign.sh "build/out/AlpineClientSetup-${VERSION}-ARM64.exe"
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: windows-installers
path: build/out
retention-days: 1
if-no-files-found: error
package_linux:
name: "Package Linux"
runs-on: ubuntu-latest
needs: [ build_linux ]
steps:
- name: Checkout ci/pkg files
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
sparse-checkout: |
ci/pkg/linux
ci/scripts
VERSION
- name: Download binaries
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: linux-binaries
path: bin
- name: Install dependencies
run: >-
sudo apt-get update &&
sudo apt-get install -y
rpm
debhelper
devscripts
dpkg-dev
libfuse2
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Download AppImageTool
run: ./ci/scripts/download-appimagetool.sh
- name: Prepare for packaging
run: |
# Edit version in spec/control files
sed -i "s/^Version:.*/Version: ${VERSION}/" ci/pkg/linux/rpm/SPECS/pinnacle.spec
sed -i "s/^Release:.*/Release: ${RELEASE}/" ci/pkg/linux/rpm/SPECS/pinnacle.spec
sed -i "s/^Version:.*/Version: ${VERSION}-${RELEASE}/" ci/pkg/linux/deb/DEBIAN/control
# Set up rpmbuild/debbuild/appimage file tree
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p ~/debbuild/alpine-client/{DEBIAN,usr/bin,usr/share/applications,usr/share/pixmaps}
mkdir -p ~/appbuild/AlpineClient.AppDir/usr/{bin,share/{icons/hicolor/scalable/apps,licenses/alpine-client}}
# Copy resources
cp -r ci/pkg/linux/rpm/* ~/rpmbuild/
cp -r ci/pkg/linux/deb/* ~/debbuild/alpine-client/
cp -r ci/pkg/linux/appimage/* ~/appbuild/AlpineClient.AppDir/
# Copy binaries
cp bin/pinnacle-linux-amd64 ~/rpmbuild/SOURCES/
cp bin/pinnacle-linux-amd64 ~/debbuild/alpine-client/usr/bin/alpine-client
cp bin/pinnacle-linux-amd64 ~/appbuild/AlpineClient.AppDir/usr/bin/alpine-client
# Make binaries executable
chmod +x ~/rpmbuild/SOURCES/pinnacle-linux-amd64
chmod +x ~/debbuild/alpine-client/usr/bin/alpine-client
chmod +x ~/appbuild/AlpineClient.AppDir/usr/bin/alpine-client
chmod +x ~/appbuild/AlpineClient.AppDir/AppRun
# Create output folder
mkdir -p build/out
- name: Package AMD64 RPM
run: >-
rpmbuild -bb
~/rpmbuild/SPECS/pinnacle.spec
--define "_rpmdir build/out"
--target=x86_64
- name: Package AMD64 DEB
run: >-
dpkg-deb -Zgzip
--build ~/debbuild/alpine-client
"build/out/alpine-client_${VERSION}-${RELEASE}_amd64.deb"
- name: Package AMD64 AppImage
run: >-
./appimagetool-x86_64.AppImage ~/appbuild/AlpineClient.AppDir
"build/out/Alpine_Client-${VERSION}-x86_64.AppImage"
- name: Swap AMD64 binary for ARM64
run: |
# Remove amd64 binaries
rm -f ~/rpmbuild/SOURCES/pinnacle-darwin-amd64
rm -f ~/debbuild/alpine-client/usr/bin/alpine-client
# Edit arch & binary name in spec/control files
sed -i -e 's/linux-amd64/linux-arm64/g' -e 's/x86_64/aarch64/g' ~/rpmbuild/SPECS/pinnacle.spec
sed -i 's/amd64/arm64/g' ~/debbuild/alpine-client/DEBIAN/control
# Copy arm64 binaries
cp bin/pinnacle-linux-arm64 ~/rpmbuild/SOURCES/
cp bin/pinnacle-linux-arm64 ~/debbuild/alpine-client/usr/bin/alpine-client
# Make binaries executable
chmod +x ~/rpmbuild/SOURCES/pinnacle-linux-arm64
chmod +x ~/debbuild/alpine-client/usr/bin/alpine-client
- name: Package ARM64 RPM
run: >-
rpmbuild -bb
~/rpmbuild/SPECS/pinnacle.spec
--define "_rpmdir build/out"
--target=aarch64
- name: Package ARM64 DEB
run: >-
dpkg-deb -Zgzip
--build ~/debbuild/alpine-client
"build/out/alpine-client_${VERSION}-${RELEASE}_arm64.deb"
- name: Tidy artifacts
run: |
if [ -d "build/out/x86_64" ]; then
cp -r build/out/x86_64/* build/out/
fi
if [ -d "build/out/aarch64" ]; then
cp -r build/out/aarch64/* build/out/
fi
rm -rf build/out/x86_64
rm -rf build/out/aarch64
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: linux-installers
path: build/out
retention-days: 1
if-no-files-found: error
package_macos:
name: "Package MacOS"
runs-on: macos-latest
needs: [ build_macos ]
steps:
- name: Checkout ci/pkg/darwin
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
sparse-checkout: |
ci/pkg/darwin
VERSION
- name: Download binaries
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: macos-binaries
path: bin
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Set up environment
run: |
# Set env variables for paths
APP="ci/pkg/darwin/Alpine Client.app/Contents"
# Create necessary folders
mkdir "${APP}/MacOS"
mkdir -p build/out/
mkdir {dmg_amd64,dmg_arm64}
# Replace version in Info.plist file
sed -i '' "s/<string>1.0.0<\/string>/<string>${VERSION}<\/string>/" "${APP}/Info.plist"
# Move compiled binary
cp bin/pinnacle-darwin-amd64 "${APP}/MacOS/pinnacle-darwin-amd64"
# Set permissions
chmod +x "${APP}/MacOS/pinnacle-darwin-amd64"
# Copy app contents to dmg folders
cp -R "ci/pkg/darwin/Alpine Client.app" dmg_amd64/
ln -s /Applications dmg_amd64/Applications
# Export APP env for later
echo "APP=${APP}" >> $GITHUB_ENV
- name: Package AMD64 PKG
run: >-
pkgbuild
--root ci/pkg/darwin
--identifier com.alpineclient.pinnacle
--version "${VERSION}"
--install-location /Applications
"build/out/AlpineClientSetup-${VERSION}-x86_64.pkg"
- name: Package AMD64 DMG
run: >-
hdiutil create
-volname "Alpine Client"
-srcfolder dmg_amd64
-ov -format UDZO
"build/out/AlpineClient-${VERSION}-x86_64.dmg"
- name: Swap AMD64 binary for ARM64
run: |
# pkg
rm -f "${APP}/MacOS/pinnacle-darwin-amd64"
cp bin/pinnacle-darwin-arm64 "${APP}/MacOS/pinnacle-darwin-arm64"
sed -i '' 's/amd64/arm64/g' "${APP}/Info.plist"
chmod +x "${APP}/MacOS/pinnacle-darwin-arm64"
# dmg
cp -R "ci/pkg/darwin/Alpine Client.app" dmg_arm64/
ln -s /Applications dmg_arm64/Applications
- name: Package ARM64 PKG
run: >-
pkgbuild
--root ci/pkg/darwin
--identifier com.alpineclient.pinnacle
--version "${VERSION}"
--install-location /Applications
"build/out/AlpineClientSetup-${VERSION}-ARM64.pkg"
- name: Package ARM64 DMG
run: >-
hdiutil create
-volname "Alpine Client"
-srcfolder dmg_arm64
-ov -format UDZO
"build/out/AlpineClient-${VERSION}-ARM64.dmg"
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: macos-installers
path: build/out
retention-days: 1
if-no-files-found: error
create_github_release:
name: "Create GitHub Release"
runs-on: ubuntu-latest
needs: [ package_windows, package_linux, package_macos ]
steps:
- name: Checkout version file
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
sparse-checkout: |
VERSION
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Download
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: all
- name: Reorganize artifacts
run: |
mkdir -p merged/{binaries,installers}
# Combine binaries
cp -r all/windows-binaries/* merged/binaries/
cp -r all/linux-binaries/* merged/binaries/
cp -r all/macos-binaries/* merged/binaries/
# Combine installers
cp -r all/windows-installers/* merged/installers/
cp -r all/macos-installers/* merged/installers/
cp -r all/linux-installers/* merged/installers/
- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: all-artifacts-${{ env.RELEASE }}
path: merged
compression-level: 9
retention-days: 90
if-no-files-found: error
- name: Create release
if: github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
files: |
merged/installers/*
merged/binaries/*
fail_on_unmatched_files: true
prerelease: false
make_latest: true
draft: false
publish_aur_package:
name: "Publish AUR Package"
runs-on: ubuntu-latest
needs: [ create_github_release ]
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout ci/pkg/linux/arch
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
sparse-checkout: |
ci/pkg/linux/arch
VERSION
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Generate tarball checksum
run: |
src_url="${{ github.server_url }}/${{ github.repository }}/archive/${VERSION}.tar.gz"
checksum=$(curl -sL ${src_url} | shasum -a 256 | cut -d " " -f 1)
if [ -z "$checksum" ]; then
echo "CHECKSUM is empty"
exit 1
fi
echo "CHECKSUM=${checksum}" >> $GITHUB_ENV
- name: Update PKGBUILD
run: |
sed -i "s/pkgver=1.0.0/pkgver=${VERSION}/" ci/pkg/linux/arch/PKGBUILD
sed -i "s/sha256sums=('SKIP')/sha256sums=('${CHECKSUM}')/" ci/pkg/linux/arch/PKGBUILD
- name: Publish to AUR
uses: KSXGitHub/github-actions-deploy-aur@a97f56a8425a7a7f3b8c58607f769c69b089cadb # v3.0.1
with:
force_push: true
pkgname: alpine-client
pkgbuild: ci/pkg/linux/arch/PKGBUILD
commit_message: ${{ env.VERSION }}
commit_email: ${{ secrets.AUR_EMAIL }}
commit_username: ${{ secrets.AUR_USERNAME }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
create_sentry_release:
name: "Create Sentry Release"
runs-on: ubuntu-latest
needs: [ create_github_release ]
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
- name: Read version
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Create sentry.io release
uses: getsentry/action-release@e769183448303de84c5a06aaaddf9da7be26d6c7 # v1.7.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: pinnacle
with:
environment: production
version: ${{ env.VERSION }}