-
Notifications
You must be signed in to change notification settings - Fork 282
477 lines (427 loc) · 15.1 KB
/
maven-and-native.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
name: CI with CMake and Maven
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
# Java version to use for the release
RELEASE_JAVA_VERSION: 11
concurrency:
group: $GITHUB_REF
cancel-in-progress: true
jobs:
version:
name: Prepare version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
create_tag: ${{ steps.version.outputs.create_tag }}
tag_name: ${{ steps.version.outputs.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.RELEASE_JAVA_VERSION }}
distribution: temurin
# don't use the setup-java cache option as this only caches what is
# necessary for the version, not the other jobs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-version-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-version-
- name: Parse and set version
id: version
run: |
MVNVER=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
TAG_NAME="v${MVNVER/-SNAPSHOT/}"
if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1
then
echo "Creating tag $TAG_NAME"
git config --local user.name "$GITHUB_ACTOR via GitHub Actions"
git config --local user.email "actions@github.com"
git tag -a "$TAG_NAME" -m "Tagged automatically by GitHub Actions ${{ github.workflow }}"
echo "create_tag=true" >> $GITHUB_OUTPUT
else
echo "Tag: $TAG_NAME already exists"
echo "create_tag=false" >> $GITHUB_OUTPUT
fi
VERSION=`git describe --match "v[0-9\.]*" --long --always`
VERSION=${VERSION:1}
else
echo "Not on master"
echo "create_tag=false" >> $GITHUB_OUTPUT
VERSION=${MVNVER}
fi
echo "Version: $VERSION"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
javatest:
name: Java ${{ matrix.java }} Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 11, 17 ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- name: Install Java ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: Verify Java
run: mvn -B verify -DperformRelease=true
- name: Upload JNI headers
if: matrix.java == env.RELEASE_JAVA_VERSION
uses: actions/upload-artifact@v3
with:
name: jni_headers
path: target/native
ubuntu:
name: Linux Static Natives ${{ matrix.arch }}
runs-on: ubuntu-20.04
needs: javatest
strategy:
fail-fast: false
matrix:
arch:
- "x86"
- "x86-64"
- "arm64"
- "ppc64el"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Get JNI headers
uses: actions/download-artifact@v3
with:
name: jni_headers
path: target/native
- name: Install packages for native build
env:
DEBIAN_FRONTEND: noninteractive
run: |
# Remove broken packages from pre-installed php in Actions image
# No longer needed in ubuntu-22.04
sudo apt-get remove -y libpcre2-dev libicu-dev icu-devtools
sudo apt-add-repository ppa:ondrej/php -y
sudo apt-get install -y aptitude
echo "Get::allow-downgrades \"true\";" | sudo tee /etc/apt/apt.conf.d/99-downgrades
echo "Get::Assume-Yes \"true\";" | sudo tee -a /etc/apt/apt.conf.d/99-downgrades
sudo ./resources/ubuntu-build-image/ppa-purge.sh ppa:ondrej/php -y true
if [ "${{ matrix.arch }}" != "x86" ] && [ "${{ matrix.arch }}" != "x86-64" ]; then
sudo cp -f resources/ubuntu-build-image/ports-sources.list /etc/apt/sources.list
fi
sudo ./resources/ubuntu-build-image/packages.sh ${{ matrix.arch }} ${{ env.RELEASE_JAVA_VERSION }}
- name: Build natives ${{ matrix.arch }}
run: ./resources/ubuntu-build-image/build-static.sh ${{ matrix.arch }} ${{ env.RELEASE_JAVA_VERSION }} "$(pwd)"
- name: Upload Linux ${{ matrix.arch }} natives
uses: actions/upload-artifact@v3
with:
name: linux-${{ matrix.arch }}
path: src/main/resources/linux-*/*
deb:
name: ${{ matrix.dist.dist }} ${{ matrix.arch }}
runs-on: ubuntu-latest
needs:
- version
- javatest
strategy:
fail-fast: false
matrix:
dist:
- { vendor: ubuntu, dist: focal }
- { vendor: ubuntu, dist: jammy }
- { vendor: ubuntu, dist: lunar }
- { vendor: debian, dist: bullseye }
- { vendor: debian, dist: bookworm }
arch:
- amd64
- arm64
- ppc64el
include: [
{ dist: { vendor: debian, dist: buster }, arch: i386 },
{ dist: { vendor: debian, dist: bullseye }, arch: i386 },
{ dist: { vendor: debian, dist: bookworm }, arch: i386 },
]
env:
UBUNTUTOOLS_UBUNTU_MIRROR: http://azure.archive.ubuntu.com/ubuntu
UBUNTUTOOLS_DEBIAN_MIRROR: http://debian-archive.trafficmanager.net/debian/
UBUNTUTOOLS_DEBSEC_MIRROR: http://debian-archive.trafficmanager.net/debian-security
DEBIAN_FRONTEND: noninteractive
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Get JNI headers
uses: actions/download-artifact@v3
with:
name: jni_headers
path: target/native
# don't use the setup-java cache option as this only caches what is
# necessary for the version, not the other jobs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-version-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-version-
- name: Install tools
run: resources/deb-prepare.sh
- name: Import GPG key
env:
GPG_PASSPHRASE: "${{ secrets.GPG_PW }}"
run: |
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Build deb package
# the user executing sbuild needs to be in the group sbuild, a relogin is not possible here
# bionic doesn't have /bin and /usr/bin merged, thus /bin/bash
shell: /usr/bin/sg sbuild -c "/bin/bash -e {0}"
env:
GPG_PASSPHRASE: "${{ secrets.GPG_PW }}"
run: |
resources/deb-build.sh \
"${{ needs.version.outputs.version }}" \
"${{ matrix.dist.dist }}" \
"${{ matrix.arch }}"
- name: Upload package as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.dist.vendor }}-${{ matrix.dist.dist }}-${{ matrix.arch }}
path: target/debian/${{ matrix.dist.dist }}/*
windows:
name: Windows Natives ${{ matrix.arch.actions }}
runs-on: windows-latest
needs: javatest
strategy:
fail-fast: false
matrix:
arch:
#- { actions: x86, cmake: Win32, java: "x86" }
- { actions: x64, cmake: x64, java: "x86-64" }
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Get JNI headers
uses: actions/download-artifact@v3
with:
name: jni_headers
path: target/native
- name: Install Java ${{ env.RELEASE_JAVA_VERSION }}
id: install_java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ env.RELEASE_JAVA_VERSION }}
architecture: ${{ matrix.arch.actions }}
- name: Build natives
run: |
git config --global user.email "jitsi-jenkins@jitsi.org"
git config --global user.name "Jitsi GitHub Action"
cd $Env:GITHUB_WORKSPACE/src/native/
$java_home = "${{ steps.install_java.outputs.path }}".Replace("\\", "/")
cmake -B cmake-build-${{ matrix.arch.actions }} -DVCPKG_TARGET_TRIPLET=${{ matrix.arch.cmake }}-windows-static -A ${{ matrix.arch.cmake }} -DJAVA_HOME=$java_home
cmake --build cmake-build-${{ matrix.arch.actions }} --config Release --target install --parallel
- name: Gather logs on failure
if: ${{ failure() }}
run: |
Compress-Archive -Path $Env:GITHUB_WORKSPACE/src/native/cmake-build-${{ matrix.arch.actions }} -DestinationPath $Env:GITHUB_WORKSPACE/target/debug-logs.zip
Compress-Archive -Path $Env:GITHUB_WORKSPACE/src/native/vcpkg/buildtrees -DestinationPath $Env:GITHUB_WORKSPACE/target/debug-vcpkg.zip
- name: Upload Debug logs
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: win32-debug-${{ matrix.arch.java }}
path: target/debug*
- name: Upload Windows ${{ matrix.arch.actions }} natives
uses: actions/upload-artifact@v3
with:
name: win32-${{ matrix.arch.java }}
path: src/main/resources/win32-*/*
mac:
name: Mac Natives ${{ matrix.arch }}
runs-on: macos-latest
needs: javatest
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- arm64
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Get JNI headers
uses: actions/download-artifact@v3
with:
name: jni_headers
path: target/native
- name: Install Java
id: install_java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: ${{ env.RELEASE_JAVA_VERSION }}
architecture: ${{ matrix.arch }}
- name: Build natives
run: |
git config --global user.email "dev@jitsi.org"
git config --global user.name "Jitsi GitHub Action"
brew install nasm autoconf automake libtool
resources/mac-cmake.sh ${{ steps.install_java.outputs.path }} ${{ matrix.arch }}
- name: The job has failed
if: ${{ failure() }}
run: tar --exclude *.o -cvJf target/debug-logs.tar.xz src/native/cmake-build-${{ matrix.arch }}
- name: Upload Debug logs
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: darwin-debug-${{ matrix.arch }}
path: target/debug*
- name: Upload Mac natives
uses: actions/upload-artifact@v3
with:
name: darwin-${{ matrix.arch }}
path: src/main/resources/darwin-*/*
multiplatform:
name: Multiplatform Jar
runs-on: ubuntu-latest
needs:
- javatest
- version
- ubuntu
- windows
- mac
- deb
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: false
- name: Install Java ${{ env.RELEASE_JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.RELEASE_JAVA_VERSION }}
distribution: temurin
cache: maven
server-id: ossrh
server-username: SONATYPE_USER
server-password: SONATYPE_PW
- name: Download binaries
uses: actions/download-artifact@v3
with:
path: target
- name: Copy natives for Maven
run: |
BASEDIR=$(pwd)/src/main/resources
mkdir -p $BASEDIR
cd target
for dist in */*/ ; do
last_dir=$(basename $dist)
if [[ "$last_dir" =~ ^(linux|darwin|win32) ]]; then
mkdir -p "$BASEDIR/$last_dir" || true
cp "$dist"/*.{so,dylib,dll} "$BASEDIR/$last_dir" || true
fi;
done;
- name: Release to Maven Central
if: github.ref == 'refs/heads/master'
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PW: ${{ secrets.SONATYPE_PW }}
run: |
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
mvn -B versions:set -DnewVersion=${{ needs.version.outputs.version }} -DgenerateBackupPoms=false
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase="${{ secrets.GPG_PW }}" \
-DperformRelease=true \
-Drelease=true \
-Dosgi-native=true \
-DskipTests \
deploy
- name: Package on PR
if: github.ref != 'refs/heads/master'
run: |
mvn -B versions:set -DnewVersion=${{ needs.version.outputs.version }} -DgenerateBackupPoms=false
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.skip \
-DperformRelease=true \
-Drelease=true \
-Dosgi-native=true \
-DskipTests \
package
- name: Upload Multi-Platform Jar
uses: actions/upload-artifact@v3
with:
name: jar
path: target/*.jar
if-no-files-found: error
- name: Pack all debs to avoid Github filename mangling
run: |
tar -cvf debian-releases.tar target/{debian-*,ubuntu-*}/*
- name: Create release
if: github.ref == 'refs/heads/master'
uses: ncipollo/release-action@37c87f6b53fb46d40450c3cac428aa83c8d0055f
with:
artifacts: "target/*.jar,debian-releases.tar"
allowUpdates: true
prerelease: true
draft: false
tag: r${{ needs.version.outputs.version }}
omitBody: true
removeArtifacts: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
artifactErrorsFailBuild: true
- name: Tag
if: needs.version.outputs.create_tag == 'true'
run: |
git config --local user.name "$GITHUB_ACTOR via GitHub Actions"
git config --local user.email "actions@github.com"
git tag -a "${{ needs.version.outputs.tag_name }}" -m "Tagged automatically by GitHub Actions ${{ github.workflow }}"
git push origin "${{ needs.version.outputs.tag_name }}"
deploy:
name: Deploy Debian packages
if: github.ref == 'refs/heads/master'
needs:
- version
- multiplatform
- deb
uses: ./.github/workflows/deploy-debian.yml
with:
release_type: unstable
tag: r${{ needs.version.outputs.version }}
secrets: inherit