-
Notifications
You must be signed in to change notification settings - Fork 2
510 lines (472 loc) · 17.2 KB
/
build-packages.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
name: Build Anon Packages
on:
push:
tags:
- 'v*'
- '*beta*'
branches:
- main
- development
pull_request:
branches:
- main
- development
env:
DEBIAN_FRONTEND: noninteractive
# tags (v*): live
# tags (*beta*): beta
# main: stage
# development: dev
# everything else (pull request, etc.): unstable-dev
PKG_ENV: ${{ github.ref_type == 'tag' && (contains(github.ref, 'beta') && 'beta' || 'live') || github.ref == 'refs/heads/main' && 'stage' || github.ref == 'refs/heads/development' && 'dev' || 'unstable-dev' }}
jobs:
#
# Debian Packages
#
build-deb-source:
runs-on: ubuntu-latest
container:
image: debian:bookworm
steps:
- name: Install Dependencies
run: |
apt-get -y update
apt-get -y dist-upgrade
apt-get -y install sudo git build-essential devscripts gpg
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup
run: |
apt-get -y install $(cat debian/.debian-ci/build_source/build-depends)
git config --global --add safe.directory $(realpath .)
- name: Build Source
run: |
$(pwd)/debian/.debian-ci/build_source/build-script
- name: Sign Source Package
run: |
echo "${{ secrets.DEBIAN_PRIVATE_KEY }}" | base64 -d > debian-private.gpg
gpg --allow-secret-key-import --import debian-private.gpg
debsign -k ${{ secrets.DEBIAN_FINGERPRINT }} source-packages/anon_*.changes
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-source-packages
path: source-packages/
build-deb-package:
runs-on: ${{ matrix.build.runner }}
needs: build-deb-source
container:
image: ${{ matrix.build.os }}:${{ matrix.build.suite }}
strategy:
fail-fast: false
matrix:
build:
# Debian Bookworm
- os: debian
suite: bookworm
arch: amd64
runner: ubuntu-latest
- os: debian
suite: bookworm
arch: arm64
runner: arm64
# Debian Bullseye
- os: debian
suite: bullseye
arch: amd64
runner: ubuntu-latest
- os: debian
suite: bullseye
arch: arm64
runner: arm64
# Ubuntu Noble
- os: ubuntu
suite: noble
arch: amd64
runner: ubuntu-latest
- os: ubuntu
suite: noble
arch: arm64
runner: arm64
# Ubuntu Lunar
- os: ubuntu
suite: lunar
arch: amd64
runner: ubuntu-latest
- os: ubuntu
suite: lunar
arch: arm64
runner: arm64
# Ubuntu Jammy
- os: ubuntu
suite: jammy
arch: amd64
runner: ubuntu-latest
- os: ubuntu
suite: jammy
arch: arm64
runner: arm64
# Ubuntu Focal
- os: ubuntu
suite: focal
arch: amd64
runner: ubuntu-latest
- os: ubuntu
suite: focal
arch: arm64
runner: arm64
steps:
- name: Install Dependencies
run: |
apt-get -y update
apt-get -y dist-upgrade
apt-get -y install build-essential devscripts gpg reprepro fakeroot
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-source-packages
path: source-packages/
- name: Build Package
run: |
set -x
find source-packages
upstream_version="$(head -n1 source-packages/version.txt)"
if [ -z "$upstream_version" ]; then echo >&2 "Did not get package version from artifact."; exit 1; fi
echo $upstream_version
srcchanges="$(ls -1 source-packages/anon_"$upstream_version"*${{ matrix.build.suite }}+*_src.changes)"
echo "srcchanges: $srcchanges"
if [ "$(echo "$srcchanges" | wc -l)" != 1 ] || [ -z "$srcchanges" ] ; then echo >&2 "Weird number of changes files found."; exit 1; fi
case "${{ matrix.build.arch }}" in
amd64) build_selector="-b";;
*) build_selector="-B";;
esac
echo "source changes file:"
cat "$srcchanges"
dsc="$(dcmd --dsc "$srcchanges")"
echo "dsc file is ${dsc}"
cat "$dsc"
mkdir build-tree
cd build-tree
dpkg-source -x ../${dsc}
cd anon-${upstream_version}
apt-get -y build-dep .
debuild -rfakeroot -uc -us -j4 "$build_selector"
cd ..
binchanges="$(ls -1 *.changes)"
if [ "$(echo "$binchanges" | wc -l)" != 1 ] || [ -z "$binchanges" ] ; then echo >&2 "Weird number of changes files produced."; exit 1; fi
cd ..
mkdir RESULT
dcmd ln -v "build-tree/${binchanges}" RESULT
mv -v --no-target-directory RESULT binary-packages/
- name: Sign Binary Package
run: |
echo "${{ secrets.DEBIAN_PRIVATE_KEY }}" | base64 -d > debian-private.gpg
gpg --allow-secret-key-import --import debian-private.gpg
debsign -k ${{ secrets.DEBIAN_FINGERPRINT }} binary-packages/anon_*.changes
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-${{ matrix.build.os }}-${{ matrix.build.suite }}-${{ matrix.build.arch }}
path: binary-packages/
#
# Linux Build
#
build-linux-binary:
runs-on: ${{ matrix.build.runner }}
container:
image: debian:bookworm
env:
OPENSSL_VERSION: "1.1.1w"
strategy:
fail-fast: false
matrix:
build:
# Linux amd64
- runner: ubuntu-latest
arch: amd64
libarch: x86_64
# Linux arm64
- runner: arm64
arch: arm64
libarch: aarch64
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
path: ator-protocol
fetch-depth: 1
- name: Install dependencies
run: |
apt-get update && \
apt_build_deps="libssl-dev zlib1g-dev libevent-dev ca-certificates dh-apparmor libseccomp-dev debhelper" && \
apt_runtime_deps="iputils-ping curl pwgen" && \
apt_temps="build-essential automake git wget" && \
apt-get -y --no-install-recommends install $apt_build_deps $apt_runtime_deps $apt_temps
- name: Build anon
run: |
cd ator-protocol
./scripts/ci/update-env.sh ${{ env.PKG_ENV }}
./autogen.sh
./configure \
--disable-asciidoc \
--disable-zstd \
--disable-lzma \
--enable-static-zlib \
--enable-static-libevent \
--enable-static-openssl \
--enable-static-tor \
--with-libevent-dir=/usr/lib/${{ matrix.build.libarch }}-linux-gnu/ \
--with-openssl-dir=/usr/lib/${{ matrix.build.libarch }}-linux-gnu/ \
--with-zlib-dir=/usr/lib/${{ matrix.build.libarch }}-linux-gnu/ \
--disable-tool-name-check \
--disable-gcc-hardening
make
- name: Copy executables to artifact directory
run: |
mkdir -p package
cp ator-protocol/src/app/anon package
cp ator-protocol/src/tools/anon-gencert package
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-linux-${{ matrix.build.arch }}
path: package/
#
# MacOS Build
#
build-macos-binary:
runs-on: ${{ matrix.build.runner }}
strategy:
fail-fast: false
matrix:
build:
# MacOS Intel
- runner: macos-13
arch: amd64
# MacOS Apple Silicon
- runner: macos-14
arch: arm64
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
path: ator-protocol
fetch-depth: 1
- name: Set variables
run: |
echo "ANON_BREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
- name: Install dependencies
run: |
brew install gsed automake docbook docbook-xsl zlib libevent openssl@3
- name: Build anon
run: |
cd ator-protocol
./scripts/ci/update-env.sh ${{ env.PKG_ENV }}
./autogen.sh
./configure --prefix=/usr/local \
--disable-asciidoc \
--disable-zstd \
--disable-lzma \
--with-zlib-dir=${{ env.ANON_BREW_PREFIX }}/opt/zlib \
--with-libevent-dir=${{ env.ANON_BREW_PREFIX }}/opt/libevent \
--with-openssl-dir=${{ env.ANON_BREW_PREFIX }}/opt/openssl@3 \
--enable-static-zlib \
--enable-static-libevent \
--enable-static-openssl \
--disable-tool-name-check \
--disable-gcc-hardening
make
- name: Copy executables to artifact directory
run: |
mkdir -p package
cp ator-protocol/src/app/anon package
cp ator-protocol/src/tools/anon-gencert package
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-macos-${{ matrix.build.arch }}
path: package/
#
# Windows Build
#
build-windows-64-binary:
runs-on: ubuntu-latest
container:
image: ubuntu:latest
env:
OPENSSL_VERSION: "1.1.1w"
LIBEVENT_VERSION: "2.1.12-stable"
ZLIB_VERSION: "1.3.1"
BUILD_TYPE: "64"
CROSS_HOST: "x86_64-w64-mingw32"
MINGW: "mingw64"
MINGW_DEB: "gcc-mingw-w64-x86-64"
steps:
- name: Set variables
run: |
echo "ANON_JOBS=$((`nproc`+1))"
- name: Checkout Repository
uses: actions/checkout@v4
with:
path: ator-protocol
fetch-depth: 1
- name: Install dependencies
run: |
apt-get update -qq
apt-get upgrade -qy
apt-get install -qy autoconf automake libtool make wget git
apt-get install -qy ${MINGW_DEB}
- name: Build openssl
run: |
wget --quiet https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
tar zxf openssl-${OPENSSL_VERSION}.tar.gz
rm openssl-${OPENSSL_VERSION}.tar.gz
cd openssl-${OPENSSL_VERSION}
./Configure ${MINGW} shared --cross-compile-prefix=${CROSS_HOST}- --prefix="/build/openssl-${BUILD_TYPE}-prefix/"
make -j${{ env.ANON_JOBS }}
make install
cd ..
rm -rf openssl-${OPENSSL_VERSION}
- name: Build libevent
run: |
wget --quiet https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz
tar zxf libevent-${LIBEVENT_VERSION}.tar.gz
rm libevent-${LIBEVENT_VERSION}.tar.gz
cd libevent-${LIBEVENT_VERSION}
./configure --host=${CROSS_HOST} --disable-openssl --disable-shared --disable-samples --disable-libevent-regress --enable-static --prefix="/build/libevent-${BUILD_TYPE}-prefix/"
make -j${{ env.ANON_JOBS }}
make install
cd ..
rm -rf libevent-${LIBEVENT_VERSION}
- name: Build zlib
run: |
wget --quiet https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
tar zxf zlib-${ZLIB_VERSION}.tar.gz
rm zlib-${ZLIB_VERSION}.tar.gz
cd zlib-${ZLIB_VERSION}
CHOST=${CROSS_HOST} ./configure --static --prefix="/build/zlib-${BUILD_TYPE}-prefix/"
make -j${{ env.ANON_JOBS }}
make install
cd ..
rm -rf zlib-${ZLIB_VERSION}
- name: Build anon
run: |
cd ator-protocol
./scripts/ci/update-env.sh ${{ env.PKG_ENV }}
./autogen.sh
./configure --host=${CROSS_HOST} \
--disable-asciidoc \
--disable-zstd \
--disable-lzma \
--enable-static-libevent --with-libevent-dir="/build/libevent-${BUILD_TYPE}-prefix/" \
--enable-static-openssl --with-openssl-dir="/build/openssl-${BUILD_TYPE}-prefix/" \
--enable-static-zlib --with-zlib-dir="/build/zlib-${BUILD_TYPE}-prefix/" \
--disable-tool-name-check \
--disable-gcc-hardening \
--enable-static-tor \
--prefix="/build/anon-prefix"
make -j1
make install
- name: Copy executables to artifact directory
run: |
mkdir -p package
cp ator-protocol/src/app/anon.exe package
cp ator-protocol/src/tools/anon-gencert.exe package
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-windows-amd64
path: package/
sign-windows-64-binary:
runs-on: windows-latest
needs: build-windows-64-binary
steps:
- name: Download raw artifacts
uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-windows-amd64
path: build/
- name: Sign
run: |
dotnet tool install --global AzureSignTool
AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v "build/anon.exe"
AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v "build/anon-gencert.exe"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-windows-signed-amd64
path: build/
#
# Release
#
release-deb:
runs-on: ubuntu-latest
needs: build-deb-package
container:
image: debian:bookworm
steps:
- name: Install Dependencies
run: |
apt-get -y update
apt-get -y dist-upgrade
apt-get -y install devscripts zip gpg dput openssh-client
- name: Download raw artifacts
uses: actions/download-artifact@v4
with:
path: raw-artifacts/
- name: Distribute signed .deb packages
run: |
mkdir -p /root/.ssh
ssh-keyscan ${{ secrets.DEBIAN_HOST }} > /root/.ssh/known_hosts
echo "${{ secrets.DEBIAN_ID_RSA }}" | base64 -d > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
echo "${{ secrets.DEBIAN_PRIVATE_KEY }}" | base64 -d > debian-private.gpg
gpg --allow-secret-key-import --import debian-private.gpg
cat << EOF > ~/.dput.cf
[anon]
fqdn = ${{ secrets.DEBIAN_HOST }}
incoming = /data/debian/incoming
method = scp
login = reprepro
allow_unsigned_uploads = 0
post_upload_command = ssh %(login)s@%(fqdn)s reprepro processincoming incoming
EOF
echo "Uploading packages"
dput anon raw-artifacts/anon-*/anon_*.changes
echo "Processing incoming packages"
ssh reprepro@${{ secrets.DEBIAN_HOST }} "reprepro processincoming incoming || exit 1"
release-github:
runs-on: ubuntu-latest
needs: [build-deb-package, build-macos-binary, sign-windows-64-binary]
if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'beta') }}
steps:
- name: Download raw artifacts
uses: actions/download-artifact@v4
with:
path: raw-artifacts/
- name: Copy release artifacts
run: |
mkdir -p release-artifacts/
cp raw-artifacts/anon-*/anon_*.deb release-artifacts/
chmod +x raw-artifacts/anon-${{ env.PKG_ENV }}-linux-amd64/*
chmod +x raw-artifacts/anon-${{ env.PKG_ENV }}-linux-arm64/*
chmod +x raw-artifacts/anon-${{ env.PKG_ENV }}-macos-amd64/*
chmod +x raw-artifacts/anon-${{ env.PKG_ENV }}-macos-arm64/*
zip -j release-artifacts/anon-${{ env.PKG_ENV }}-linux-amd64.zip raw-artifacts/anon-${{ env.PKG_ENV }}-linux-amd64/*
zip -j release-artifacts/anon-${{ env.PKG_ENV }}-linux-arm64.zip raw-artifacts/anon-${{ env.PKG_ENV }}-linux-arm64/*
zip -j release-artifacts/anon-${{ env.PKG_ENV }}-macos-amd64.zip raw-artifacts/anon-${{ env.PKG_ENV }}-macos-amd64/*
zip -j release-artifacts/anon-${{ env.PKG_ENV }}-macos-arm64.zip raw-artifacts/anon-${{ env.PKG_ENV }}-macos-arm64/*
zip -j release-artifacts/anon-${{ env.PKG_ENV }}-windows-signed-amd64.zip raw-artifacts/anon-${{ env.PKG_ENV }}-windows-signed-amd64/*
ls -la -R release-artifacts/
- name: Checkout Repository
uses: actions/checkout@v4
with:
path: ator-protocol
fetch-depth: 1
- name: Publish release artifacts
uses: ncipollo/release-action@v1
with:
artifacts: "release-artifacts/anon*"
bodyFile: "ator-protocol/doc/RELEASE.md"