-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
455 lines (407 loc) · 15.5 KB
/
main.yml
File metadata and controls
455 lines (407 loc) · 15.5 KB
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
######################################################################################
# JME CI/CD
######################################################################################
# Quick overview of what is going on in this script:
# - Build the engine, create the zip release, maven artifacts and javadoc
# - (only when building a release) Deploy everything else to github releases and Sonatype
# - (only when building a release) Update javadoc.jmonkeyengine.org
# Note:
# All the actions/upload-artifact and actions/download-artifact steps are used to pass
# stuff between jobs, github actions has some sort of storage that is local to the
# running workflow, we use it to store the result of each job since the filesystem
# is not maintained between jobs.
################# CONFIGURATIONS #####################################################
# >> Configure SONATYPE RELEASE
# CENTRAL_PASSWORD=XXXXXX
# CENTRAL_USERNAME=XXXXXX
# >> Configure SIGNING
# SIGNING_KEY=XXXXXX
# SIGNING_PASSWORD=XXXXXX
# >> Configure PACKAGE REGISTRY RELEASE
# Nothing to do here, everything is autoconfigured to work with the account/org that
# is running the build.
# >> Configure JAVADOC
# JAVADOC_GHPAGES_REPO="riccardoblsandbox/javadoc.jmonkeyengine.org.git"
# Generate a deploy key
# ssh-keygen -t rsa -b 4096 -C "actions@users.noreply.github.com" -f javadoc_deploy
# Set
# JAVADOC_GHPAGES_DEPLOY_PRIVKEY="......."
# In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access
######################################################################################
# Resources:
# - Github actions docs: https://help.github.com/en/articles/about-github-actions
# - Package registry docs: https://help.github.com/en/articles/about-github-package-registry
# - Official actions: https://github.com/actions
# - Community actions: https://github.com/sdras/awesome-actions
######################################################################################
# - Riccardo Balbo
######################################################################################
name: Build jMonkeyEngine
on:
push:
branches:
- master
- v3.7
- v3.6
- v3.5
- v3.4
- v3.3
- ios-2024_2
pull_request:
release:
types: [published]
jobs:
Checkstyle:
name: Run Checkstyle
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup the java environment
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
- name: Validate the Gradle wrapper
uses: gradle/actions/wrapper-validation@v6.1.0
- name: Run Checkstyle
run: |
./gradlew checkstyleMain checkstyleTest --console=plain --stacktrace
- name: Upload Checkstyle Reports
uses: actions/upload-artifact@v7.0.1
if: always()
with:
name: checkstyle-report
retention-days: 30
path: |
**/build/reports/checkstyle/**
SpotBugs:
name: Run SpotBugs
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup the java environment
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
- name: Validate the Gradle wrapper
uses: gradle/actions/wrapper-validation@v6.1.0
- name: Run SpotBugs
run: |
./gradlew -PenableSpotBugs=true spotbugsMain spotbugsTest --console=plain --stacktrace
- name: Upload SpotBugs Reports
uses: actions/upload-artifact@v7.0.1
if: always()
with:
name: spotbugs-report
retention-days: 30
path: |
**/build/reports/spotbugs/**
ScreenshotTests:
name: Run Screenshot Tests
runs-on: ubuntu-latest
container:
image: ghcr.io/onemillionworlds/opengl-docker-image:v1
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup the java environment
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
- name: Start xvfb
run: |
Xvfb :99 -ac -screen 0 1024x768x16 &
export DISPLAY=:99
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Report GL/Vulkan
run: |
set -x
echo "DISPLAY=$DISPLAY"
glxinfo | grep -E "OpenGL version|OpenGL renderer|OpenGL vendor" || true
vulkaninfo --summary || true
echo "VK_ICD_FILENAMES=$VK_ICD_FILENAMES"
echo "MESA_LOADER_DRIVER_OVERRIDE=$MESA_LOADER_DRIVER_OVERRIDE"
echo "GALLIUM_DRIVER=$GALLIUM_DRIVER"
- name: Validate the Gradle wrapper
uses: gradle/actions/wrapper-validation@v6.1.0
- name: Test with Gradle Wrapper
run: |
./gradlew :jme3-screenshot-test:screenshotTest
- name: Upload Test Reports
uses: actions/upload-artifact@v7.0.1
if: always()
with:
name: screenshot-test-report
retention-days: 30
path: |
**/build/reports/**
**/build/changed-images/**
**/build/test-results/**
# Build the engine, we only deploy from ubuntu-latest jdk25
BuildJMonkey:
name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
jdk: [25]
include:
- os: ubuntu-latest
osName: linux
deploy: true
- os: windows-latest
osName: windows
deploy: false
- os: macOS-latest
osName: mac
deploy: false
steps:
- name: Clone the repo
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Setup the java environment
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ matrix.jdk }}
- name: Validate the Gradle wrapper
uses: gradle/actions/wrapper-validation@v6.1.0
- name: Build Engine
shell: bash
run: |
# Normal build plus ZIP distribution and merged javadoc
./gradlew -PuseCommitHashAsVersionName=true \
-x checkstyleMain -x checkstyleTest \
build createZipDistribution mergedJavadoc
if [ "${{ matrix.deploy }}" = "true" ];
then
# We are going to need "zip"
sudo apt-get update
sudo apt-get install -y zip
# We prepare the release for deploy
mkdir -p ./dist/release/
mv build/distributions/*.zip dist/release/
# Install maven artifacts to ./dist/maven and sign them if possible
if [ "${{ secrets.SIGNING_PASSWORD }}" = "" ];
then
echo "Configure the following secrets to enable signing:"
echo "SIGNING_KEY, SIGNING_PASSWORD"
./gradlew publishMavenPublicationToDistRepository \
-PuseCommitHashAsVersionName=true \
--console=plain --stacktrace
else
./gradlew publishMavenPublicationToDistRepository \
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
-PuseCommitHashAsVersionName=true \
--console=plain --stacktrace
fi
fi
# Upload maven artifacts to be used later by the deploy job
- name: Upload maven artifacts
if: matrix.deploy==true
uses: actions/upload-artifact@v7.0.1
with:
name: maven
path: dist/maven
- name: Upload javadoc
if: matrix.deploy==true
uses: actions/upload-artifact@v7.0.1
with:
name: javadoc
path: dist/javadoc
# Upload release archive to be used later by the deploy job
- name: Upload release
if: github.event_name == 'release' && matrix.deploy==true
uses: actions/upload-artifact@v7.0.1
with:
name: release
path: dist/release
# This job deploys snapshots on the master branch
DeployJavaSnapshot:
needs: [BuildJMonkey]
name: Deploy Java Snapshot
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_name == 'master'
permissions:
contents: read
steps:
# We need to clone everything again for uploadToMaven.sh ...
- name: Clone the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
# Setup jdk 25 used for building Maven-style artifacts
- name: Setup the java environment
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: 'temurin'
java-version: '25'
- name: Rebuild the maven artifacts and upload them to Sonatype's maven-snapshots repo
run: |
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
then
echo "Configure the following secrets to enable uploading to Sonatype:"
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
else
./gradlew publishMavenPublicationToSNAPSHOTRepository \
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
--console=plain --stacktrace
fi
# This job deploys the release
DeployRelease:
needs: [BuildJMonkey]
name: Deploy Release
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
# We need to clone everything again for uploadToCentral.sh ...
- name: Clone the repo
uses: actions/checkout@v6
with:
fetch-depth: 1
# Setup jdk 25 used for building Sonatype artifacts
- name: Setup the java environment
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
# Download all the stuff...
- name: Download maven artifacts
uses: actions/download-artifact@v8.0.1
with:
name: maven
path: dist/maven
- name: Download release
uses: actions/download-artifact@v8.0.1
with:
name: release
path: dist/release
- name: Rebuild the maven artifacts and upload them to Sonatype's Central Publisher Portal
run: |
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
then
echo "Configure the following secrets to enable uploading to Sonatype:"
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
else
./gradlew publishMavenPublicationToCentralRepository \
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
-PuseCommitHashAsVersionName=true \
--console=plain --stacktrace
.github/actions/tools/uploadToCentral.sh \
-p '${{ secrets.CENTRAL_PASSWORD }}' \
-u '${{ secrets.CENTRAL_USERNAME }}'
fi
- name: Deploy to GitHub Releases
run: |
# We need to get the release id (yeah, it's not the same as the tag)
echo "${GITHUB_EVENT_PATH}"
cat ${GITHUB_EVENT_PATH}
releaseId=$(jq --raw-output '.release.id' ${GITHUB_EVENT_PATH})
# Now that we have the id, we just upload the release zip from before
echo "Upload to release $releaseId"
filename="$(ls dist/release/*.zip)"
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)"
echo "Upload to $url"
curl -L \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary @"$filename" \
"$url"
- name: Deploy to github package registry
run: |
source .github/actions/tools/uploadToMaven.sh
registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY"
echo "Deploy to github package registry $registry"
uploadAllToMaven dist/maven/ $registry "token" ${{ secrets.GITHUB_TOKEN }}
# Deploy the javadoc
DeployJavaDoc:
needs: [BuildJMonkey]
name: Deploy Javadoc
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
# We are going to need a deploy key for this, since we need
# to push to a different repo
- name: Set ssh key
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.JAVADOC_GHPAGES_DEPLOY_PRIVKEY }}" > $HOME/.ssh/deploy.key
chmod 600 $HOME/.ssh/deploy.key
# We clone the javadoc repo
- name: Clone gh-pages
run: |
branch="gh-pages"
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $HOME/.ssh/deploy.key"
git clone --single-branch --branch "$branch" git@github.com:${{ secrets.JAVADOC_GHPAGES_REPO }} .
# Download the javadoc in the new directory "newdoc"
- name: Download javadoc
uses: actions/download-artifact@v8.0.1
with:
name: javadoc
path: newdoc
# The actual deploy
- name: Deploy to github pages
run: |
set -f
IFS=$'\n'
# Get the tag for this release
version="`if [[ $GITHUB_REF == refs\/tags* ]]; then echo ${GITHUB_REF//refs\/tags\//}; fi`"
# If there is no tag, then we do nothing.
if [ "$version" != "" ];
then
echo "Deploy as $version"
# Remove any older version of the javadoc for this tag
if [ -d "$version" ];then rm -Rf "$version"; fi
# Rename newdoc with the version name
mv newdoc "$version"
# if there isn't an index.txt we create one (we need this to list the versions)
if [ ! -f "index.txt" ]; then echo "" > index.txt ; fi
index="`cat index.txt`"
# Check if this version is already in index.txt
addNew=true
for v in $index;
do
if [ "$v" = "$version" ];
then
echo "$v" "$version"
addNew=false
break
fi
done
# If not, we add it to the beginning
if [ "$addNew" = "true" ];
then
echo -e "$version\n$index" > index.txt
index="`cat index.txt`"
fi
# Regenerate the pages
chmod +x make.sh
./make.sh
# Configure git to use the deploy key
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $HOME/.ssh/deploy.key"
# Commit the changes
git config --global user.name "Github Actions"
git config --global user.email "actions@users.noreply.github.com"
git add . || true
git commit -m "$version" || true
branch="gh-pages"
git push origin "$branch" --force || true
fi