11# #####################################################################################
2- # JME CI/CD
2+ # JME CI/CD
33# #####################################################################################
44# Quick overview of what is going on in this script:
55# - Build natives for android
88# - (only when building a release) Deploy everything else to github releases, github packet registry, Bintray, and Sonatype
99# - (only when building a release) Update javadoc.jmonkeyengine.org
1010# Note:
11- # All the actions/upload-artifact and actions/download-artifact steps are used to pass
11+ # All the actions/upload-artifact and actions/download-artifact steps are used to pass
1212# stuff between jobs, github actions has some sort of storage that is local to the
1313# running workflow, we use it to store the result of each job since the filesystem
1414# is not maintained between jobs.
2929# SIGNING_KEY=XXXXXX
3030# SIGNING_PASSWORD=XXXXXX
3131# >> Configure PACKAGE REGISTRY RELEASE
32- # Nothing to do here, everything is autoconfigured to work with the account/org that
32+ # Nothing to do here, everything is autoconfigured to work with the account/org that
3333# is running the build.
3434# >> Configure JAVADOC
3535# JAVADOC_GHPAGES_REPO="riccardoblsandbox/javadoc.jmonkeyengine.org.git"
3636# Generate a deloy key
3737# ssh-keygen -t rsa -b 4096 -C "[email protected] " -f javadoc_deploy3838# Set
3939# JAVADOC_GHPAGES_DEPLOY_PRIVKEY="......."
40- # In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access
40+ # In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access
4141# #####################################################################################
4242# Resources:
4343# - Github actions docs: https://help.github.com/en/articles/about-github-actions
6161 pull_request :
6262 release :
6363 types : [published]
64-
64+
6565jobs :
66-
66+
6767 # Build the natives on android
6868 BuildAndroidNatives :
6969 name : Build natives for android
7070 runs-on : ubuntu-18.04
7171 container :
7272 image : jmonkeyengine/buildenv-jme3:android
73-
73+
7474 steps :
7575 - name : Clone the repo
76- uses : actions/checkout@v2
76+ uses : actions/checkout@v2
7777 with :
7878 fetch-depth : 1
7979 - name : Validate the Gradle wrapper
8080 uses : gradle/wrapper-validation-action@v1
8181 - name : Build
8282 run : |
8383 ./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \
84- :jme3-android-native:assemble
85-
84+ :jme3-android-native:assemble
85+
8686 - name : Upload natives
8787 uses : actions/upload-artifact@master
8888 with :
8989 name : android-natives
9090 path : build/native
9191
9292 # Build the engine, we only deploy from ubuntu-18.04 jdk8
93- BuildJMonkey :
93+ BuildJMonkey :
9494 needs : [BuildAndroidNatives]
9595 name : Build on ${{ matrix.osName }} jdk${{ matrix.jdk }}
96- runs-on : ${{ matrix.os }}
96+ runs-on : ${{ matrix.os }}
9797 strategy :
9898 fail-fast : false
9999 matrix :
@@ -108,16 +108,16 @@ jobs:
108108 - os : windows-2019
109109 osName : windows
110110 - os : macOS-latest
111- osName : mac
111+ osName : mac
112112 - jdk : 11.x.x
113- deploy : false
113+ deploy : false
114114
115- steps :
115+ steps :
116116 - name : Clone the repo
117117 uses : actions/checkout@v2
118118 with :
119119 fetch-depth : 1
120-
120+
121121 - name : Setup the java environment
122122 uses : actions/setup-java@v1
123123 with :
@@ -137,20 +137,20 @@ jobs:
137137 run : |
138138 # Build
139139 ./gradlew -i -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true build
140-
140+
141141 if [ "${{ matrix.deploy }}" = "true" ];
142- then
142+ then
143143 # We are going to need "zip"
144144 sudo apt-get update
145145 sudo apt-get install -y zip
146146
147147 # Create the zip release and the javadoc
148148 ./gradlew -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution
149-
149+
150150 # We prepare the release for deploy
151151 mkdir -p ./dist/release/
152152 mv build/distributions/*.zip dist/release/
153-
153+
154154 # Install maven artifacts to ./dist/maven and sign them if possible
155155 if [ "${{ secrets.SIGNING_PASSWORD }}" = "" ];
156156 then
@@ -172,10 +172,10 @@ jobs:
172172 echo "Create native zip"
173173 cdir="$PWD"
174174 cd "build/native"
175- zip -r "$cdir/dist/jme3-natives.zip" *
175+ zip -r "$cdir/dist/jme3-natives.zip" *
176176 cd "$cdir"
177177 echo "Done"
178- fi
178+ fi
179179
180180 # Used later by DeploySnapshot
181181 - name : Upload merged natives
@@ -184,29 +184,29 @@ jobs:
184184 with :
185185 name : natives
186186 path : dist/jme3-natives.zip
187-
187+
188188 # Upload maven artifacts to be used later by the deploy job
189189 - name : Upload maven artifacts
190190 if : matrix.deploy==true
191191 uses : actions/upload-artifact@master
192192 with :
193193 name : maven
194- path : dist/maven
194+ path : dist/maven
195195
196196 - name : Upload javadoc
197197 if : matrix.deploy==true
198198 uses : actions/upload-artifact@master
199199 with :
200200 name : javadoc
201- path : dist/javadoc
202-
203- # Upload release archive to be used later by the deploy job
201+ path : dist/javadoc
202+
203+ # Upload release archive to be used later by the deploy job
204204 - name : Upload release
205205 if : github.event_name == 'release' && matrix.deploy==true
206206 uses : actions/upload-artifact@master
207207 with :
208208 name : release
209- path : dist/release
209+ path : dist/release
210210
211211 # This job deploys the native snapshot.
212212 # The snapshot is downloaded when people build the engine without setting buildNativeProject
@@ -227,7 +227,7 @@ jobs:
227227 then
228228 git clone --single-branch --branch "$branch" https://github.com/${GITHUB_REPOSITORY}.git .
229229 fi
230-
230+
231231 - name : Download merged natives
232232 uses : actions/download-artifact@master
233233 with :
@@ -245,7 +245,7 @@ jobs:
245245 then
246246 nativeSnapshot=`cat "natives-snapshot.properties"`
247247 nativeSnapshot="${nativeSnapshot#*=}"
248-
248+
249249 # We deploy ONLY if GITHUB_SHA (the current commit hash) is newer than $nativeSnapshot
250250 if [ "`git rev-list --count $nativeSnapshot..$GITHUB_SHA`" = "0" ];
251251 then
@@ -273,17 +273,17 @@ jobs:
273273 jmonkeyengine \
274274 ${{ secrets.OBJECTS_KEY }}
275275
276- # We reference the snapshot by writing its commit hash in natives-snapshot.properties
276+ # We reference the snapshot by writing its commit hash in natives-snapshot.properties
277277 echo "natives.snapshot=$GITHUB_SHA" > natives-snapshot.properties
278-
278+
279279 # We commit the updated natives-snapshot.properties
280280 git config --global user.name "Github Actions"
281281 git config --global user.email "[email protected] " 282-
282+
283283 git add natives-snapshot.properties
284-
284+
285285 git commit -m "[skip ci] update natives snapshot"
286-
286+
287287 # Pull rebase from the remote repo, just in case there was a push in the meantime
288288 git pull -q --rebase
289289
@@ -292,32 +292,32 @@ jobs:
292292
293293 # Push
294294 (git -c http.extraheader="AUTHORIZATION: basic $header" push origin "$branch" || true)
295-
295+
296296 fi
297297 fi
298298 fi
299299
300300 # This job deploys the release
301- DeployRelease :
301+ DeployRelease :
302302 needs : [BuildJMonkey]
303303 name : Deploy Release
304304 runs-on : ubuntu-18.04
305305 if : github.event_name == 'release'
306- steps :
307-
306+ steps :
307+
308308 # We need to clone everything again for uploadToMaven.sh ...
309309 - name : Clone the repo
310310 uses : actions/checkout@v2
311311 with :
312312 fetch-depth : 1
313-
313+
314314 # Download all the stuff...
315315 - name : Download maven artifacts
316316 uses : actions/download-artifact@master
317317 with :
318318 name : maven
319319 path : dist/maven
320-
320+
321321 - name : Download release
322322 uses : actions/download-artifact@master
323323 with :
@@ -357,7 +357,7 @@ jobs:
357357 -H "Content-Type: application/zip" \
358358 --data-binary @"$filename" \
359359 "$url"
360-
360+
361361 - name : Deploy to bintray
362362 run : |
363363 source .github/actions/tools/uploadToMaven.sh
@@ -368,22 +368,22 @@ jobs:
368368 else
369369 uploadAllToMaven dist/maven/ https://api.bintray.com/maven/${{ secrets.BINTRAY_MAVEN_REPO }} ${{ secrets.BINTRAY_USER }} ${{ secrets.BINTRAY_APIKEY }} "https://github.com/${GITHUB_REPOSITORY}" "${{ secrets.BINTRAY_LICENSE }}"
370370 fi
371-
371+
372372 # - name: Deploy to github package registry
373373 # run: |
374374 # source .github/actions/tools/uploadToMaven.sh
375375 # registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY"
376376 # echo "Deploy to github package registry $registry"
377377 # uploadAllToMaven dist/maven/ $registry "token" ${{ secrets.GITHUB_TOKEN }}
378-
378+
379379 # Deploy the javadoc
380- DeployJavaDoc :
380+ DeployJavaDoc :
381381 needs : [BuildJMonkey]
382382 name : Deploy Javadoc
383383 runs-on : ubuntu-18.04
384384 if : github.event_name == 'release'
385- steps :
386-
385+ steps :
386+
387387 # We are going to need a deploy key for this, since we need
388388 # to push to a different repo
389389 - name : Set ssh key
@@ -398,16 +398,16 @@ jobs:
398398 branch="gh-pages"
399399 export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $HOME/.ssh/deploy.key"
400400 git clone --single-branch --branch "$branch" [email protected] :${{ secrets.JAVADOC_GHPAGES_REPO }} . 401-
401+
402402 # Download the javadoc in the new directory "newdoc"
403403 - name : Download javadoc
404404 uses : actions/download-artifact@master
405405 with :
406406 name : javadoc
407407 path : newdoc
408-
408+
409409 # The actual deploy
410- - name : Deploy to github pages
410+ - name : Deploy to github pages
411411 run : |
412412 set -f
413413 IFS=$'\n'
@@ -429,10 +429,10 @@ jobs:
429429 # if there isn't an index.txt we create one (we need this to list the versions)
430430 if [ ! -f "index.txt" ]; then echo "" > index.txt ; fi
431431 index="`cat index.txt`"
432-
432+
433433 # Check if this version is already in index.txt
434434 addNew=true
435- for v in $index;
435+ for v in $index;
436436 do
437437 if [ "$v" = "$version" ];
438438 then
@@ -459,11 +459,11 @@ jobs:
459459 # Commit the changes
460460 git config --global user.name "Github Actions"
461461 git config --global user.email "[email protected] " 462-
462+
463463 git add . || true
464464 git commit -m "$version" || true
465465
466- branch="gh-pages"
466+ branch="gh-pages"
467467 git push origin "$branch" --force || true
468468
469469 fi
0 commit comments