-
Notifications
You must be signed in to change notification settings - Fork 2
436 lines (391 loc) · 14.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
name: Build Anon Packages
on:
push:
tags:
- '*'
branches:
- main
- development
pull_request:
branches:
- main
- development
env:
DEBIAN_FRONTEND: noninteractive
# tags, main: stage
# development: dev
# everything else (pr, etc.): unstable-dev
PKG_ENV: ${{ (github.ref == 'refs/heads/main' || github.ref_type == 'tag') && 'stage' || github.ref == 'refs/heads/development' && 'dev' || 'unstable-dev' }}
jobs:
#
# Debian Packages
#
build-debian-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
- 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: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-source-packages
path: source-packages/
build-debian-package:
runs-on: ${{ matrix.build.runner }}
needs: build-debian-source
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 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
container:
image: ${{ matrix.build.os }}:${{ matrix.build.suite }}
steps:
- name: Install Dependencies
run: |
apt-get -y update
apt-get -y dist-upgrade
apt-get -y install build-essential devscripts 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 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/
#
# 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 -j${{ env.ANON_JOBS }}
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/
#
# Release
#
release:
runs-on: ubuntu-latest
needs: [build-debian-package, build-macos-binary, build-windows-64-binary]
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
# Debian Bookworm Package
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-debian-bookworm-amd64
path: anon-${{ env.PKG_ENV }}-debian-bookworm-amd64/
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-debian-bookworm-arm64
path: anon-${{ env.PKG_ENV }}-debian-bookworm-arm64/
# Debian Bullseye Package
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-debian-bullseye-amd64
path: anon-${{ env.PKG_ENV }}-debian-bullseye-amd64/
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-debian-bullseye-arm64
path: anon-${{ env.PKG_ENV }}-debian-bullseye-arm64/
# Ubuntu Jammy Package
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-ubuntu-jammy-amd64
path: anon-${{ env.PKG_ENV }}-ubuntu-jammy-amd64/
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-ubuntu-jammy-arm64
path: anon-${{ env.PKG_ENV }}-ubuntu-jammy-arm64/
# Ubuntu Focal Package
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-ubuntu-focal-amd64
path: anon-${{ env.PKG_ENV }}-ubuntu-focal-amd64/
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-ubuntu-focal-arm64
path: anon-${{ env.PKG_ENV }}-ubuntu-focal-arm64/
# MacOS Binaries
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-macos-amd64
path: anon-${{ env.PKG_ENV }}-macos-amd64/
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-macos-arm64
path: anon-${{ env.PKG_ENV }}-macos-arm64/
# Windows Binaries
- uses: actions/download-artifact@v4
with:
name: anon-${{ env.PKG_ENV }}-windows-amd64
path: anon-${{ env.PKG_ENV }}-windows-amd64/
- name: Copy release artifacts
run: |
mkdir -p release-artifacts/
cp anon-*/anon_*.deb release-artifacts/
zip release-artifacts/anon-${{ env.PKG_ENV }}-macos-amd64.zip anon-${{ env.PKG_ENV }}-macos-amd64/*
zip release-artifacts/anon-${{ env.PKG_ENV }}-macos-arm64.zip anon-${{ env.PKG_ENV }}-macos-arm64/*
zip release-artifacts/anon-${{ env.PKG_ENV }}-windows-amd64.zip anon-${{ env.PKG_ENV }}-windows-amd64/*
ls -la release-artifacts/
- name: Publish release artifacts to GitHub releases
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: "release-artifacts/anon_*.deb"
bodyFile: "doc/RELEASE.md"
- name: Distribute 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 anon-*/anon_*.changes
echo "Processing incoming packages"
ssh reprepro@${{ secrets.DEBIAN_HOST }} "reprepro processincoming incoming || exit 1"