main.yml: add Gradle-wrapper validation to several jobs

v3.3
Stephen Gold 5 years ago committed by Paul Speed
parent 1198908555
commit f0e09b2a9e
  1. 178
      .github/workflows/main.yml

@ -1,5 +1,5 @@
###################################################################################### ######################################################################################
# JME CI/CD # JME CI/CD
###################################################################################### ######################################################################################
# Quick overview of what is going on in this script: # Quick overview of what is going on in this script:
# - Build natives for android # - Build natives for android
@ -10,7 +10,7 @@
# - (only when building a release) Deploy everything else to github releases, github packet registry and bintray # - (only when building a release) Deploy everything else to github releases, github packet registry and bintray
# - (only when building a release) Update javadoc.jmonkeyengine.org # - (only when building a release) Update javadoc.jmonkeyengine.org
# Note: # Note:
# All the actions/upload-artifact and actions/download-artifact steps are used to pass # 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 # 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 # running workflow, we use it to store the result of each job since the filesystem
# is not maintained between jobs. # is not maintained between jobs.
@ -23,7 +23,7 @@
# BINTRAY_APIKEY=XXXXXX # BINTRAY_APIKEY=XXXXXX
# BINTRAY_LICENSE="BSD 3-Clause" # BINTRAY_LICENSE="BSD 3-Clause"
# >> Configure PACKAGE REGISTRY RELEASE # >> Configure PACKAGE REGISTRY RELEASE
# Nothing to do here, everything is autoconfigured to work with the account/org that # Nothing to do here, everything is autoconfigured to work with the account/org that
# is running the build. # is running the build.
# >> Configure JAVADOC # >> Configure JAVADOC
# JAVADOC_GHPAGES_REPO="riccardoblsandbox/javadoc.jmonkeyengine.org.git" # JAVADOC_GHPAGES_REPO="riccardoblsandbox/javadoc.jmonkeyengine.org.git"
@ -31,7 +31,7 @@
# ssh-keygen -t rsa -b 4096 -C "actions@users.noreply.github.com" -f javadoc_deploy # ssh-keygen -t rsa -b 4096 -C "actions@users.noreply.github.com" -f javadoc_deploy
# Set # Set
# JAVADOC_GHPAGES_DEPLOY_PRIVKEY="......." # JAVADOC_GHPAGES_DEPLOY_PRIVKEY="......."
# In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access # In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access
###################################################################################### ######################################################################################
# Resources: # Resources:
# - Github actions docs: https://help.github.com/en/articles/about-github-actions # - Github actions docs: https://help.github.com/en/articles/about-github-actions
@ -54,35 +54,36 @@ on:
pull_request: pull_request:
release: release:
types: [published] types: [published]
jobs: jobs:
# Builds the natives on linux arm # Builds the natives on linux arm
BuildLinuxArmNatives: BuildLinuxArmNatives:
name: Build natives for linux (arm) name: Build natives for linux (arm)
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: container:
image: riccardoblb/buildenv-jme3:linuxArm image: riccardoblb/buildenv-jme3:linuxArm
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Validate the Gradle wrapper
- name: Build uses: gradle/wrapper-validation-action@v1
- name: Build
run: | run: |
# Build # Build
# Note: since this is crossbuild we use the buildForPlatforms filter to tell # Note: since this is crossbuild we use the buildForPlatforms filter to tell
# the buildscript wich platforms it should build for. # the buildscript wich platforms it should build for.
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \ gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \
:jme3-bullet-native:assemble :jme3-bullet-native:assemble
- name: Upload natives - name: Upload natives
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: linuxarm-natives name: linuxarm-natives
path: build/native path: build/native
# Build the natives on android # Build the natives on android
BuildAndroidNatives: BuildAndroidNatives:
@ -90,19 +91,20 @@ jobs:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: container:
image: riccardoblb/buildenv-jme3:android image: riccardoblb/buildenv-jme3:android
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Validate the Gradle wrapper
- name: Build uses: gradle/wrapper-validation-action@v1
run: | - name: Build
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \ run: |
./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \
:jme3-android-native:assemble \ :jme3-android-native:assemble \
:jme3-bullet-native-android:assemble :jme3-bullet-native-android:assemble
- name: Upload natives - name: Upload natives
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
@ -114,7 +116,7 @@ jobs:
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
os: [ubuntu-18.04,windows-2019,macOS-latest] os: [ubuntu-18.04,windows-2019,macOS-latest]
jdk: [8.x.x] jdk: [8.x.x]
include: include:
- os: ubuntu-18.04 - os: ubuntu-18.04
@ -123,22 +125,23 @@ jobs:
osName: windows osName: windows
- os: macOS-latest - os: macOS-latest
osName: mac osName: mac
name: Build natives for ${{ matrix.osName }} name: Build natives for ${{ matrix.osName }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Prepare java environment - name: Prepare java environment
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: ${{ matrix.jdk }} java-version: ${{ matrix.jdk }}
architecture: x64 architecture: x64
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build Natives - name: Build Natives
shell: bash shell: bash
env: env:
@ -147,8 +150,8 @@ jobs:
# Install dependencies # Install dependencies
if [ "$OS_NAME" = "mac" ]; if [ "$OS_NAME" = "mac" ];
then then
echo "Prepare mac" echo "Prepare mac"
elif [ "$OS_NAME" = "linux" ]; elif [ "$OS_NAME" = "linux" ];
then then
echo "Prepare linux" echo "Prepare linux"
@ -157,25 +160,25 @@ jobs:
else else
echo "Prepare windows" echo "Prepare windows"
fi fi
# Build # Build
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \ gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \
build \ build \
:jme3-bullet-native:build :jme3-bullet-native:build
# Upload natives to be used later by the BuildJMonkey job # Upload natives to be used later by the BuildJMonkey job
- name: Upload natives - name: Upload natives
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: ${{ matrix.osName }}-natives name: ${{ matrix.osName }}-natives
path: build/native path: build/native
# Build the engine, we only deploy from ubuntu-18.04 jdk8 # Build the engine, we only deploy from ubuntu-18.04 jdk8
BuildJMonkey: BuildJMonkey:
needs: [BuildNatives,BuildAndroidNatives] needs: [BuildNatives,BuildAndroidNatives]
name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }} name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
@ -188,21 +191,21 @@ jobs:
- os: windows-2019 - os: windows-2019
osName: windows osName: windows
- os: macOS-latest - os: macOS-latest
osName: mac osName: mac
- jdk: 11.x.x - jdk: 11.x.x
deploy: false deploy: false
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Setup the java environment - name: Setup the java environment
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: ${{ matrix.jdk }} java-version: ${{ matrix.jdk }}
architecture: x64 architecture: x64
- name: Download natives for linux - name: Download natives for linux
uses: actions/download-artifact@master uses: actions/download-artifact@master
@ -215,7 +218,7 @@ jobs:
with: with:
name: windows-natives name: windows-natives
path: build/native path: build/native
- name: Download natives for mac - name: Download natives for mac
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
@ -233,26 +236,27 @@ jobs:
with: with:
name: linuxarm-natives name: linuxarm-natives
path: build/native path: build/native
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build Engine - name: Build Engine
shell: bash shell: bash
run: | run: |
# Build # Build
gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true build gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true build
if [ "${{ matrix.deploy }}" = "true" ]; if [ "${{ matrix.deploy }}" = "true" ];
then then
# We are going to need "zip" # We are going to need "zip"
sudo apt-get update sudo apt-get update
sudo apt-get install -y zip sudo apt-get install -y zip
# Create the zip release and the javadoc # Create the zip release and the javadoc
gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution
# We prepare the release for deploy # We prepare the release for deploy
mkdir -p ./dist/release/ mkdir -p ./dist/release/
mv build/distributions/*.zip dist/release/ mv build/distributions/*.zip dist/release/
# Create the maven artifacts # Create the maven artifacts
mkdir -p ./dist/maven/ mkdir -p ./dist/maven/
gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true install -Dmaven.repo.local="$PWD/dist/maven" gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true install -Dmaven.repo.local="$PWD/dist/maven"
@ -261,10 +265,10 @@ jobs:
echo "Create native zip" echo "Create native zip"
cdir="$PWD" cdir="$PWD"
cd "build/native" cd "build/native"
zip -r "$cdir/dist/jme3-natives.zip" * zip -r "$cdir/dist/jme3-natives.zip" *
cd "$cdir" cd "$cdir"
echo "Done" echo "Done"
fi fi
# Used later by DeploySnapshot # Used later by DeploySnapshot
- name: Upload merged natives - name: Upload merged natives
@ -273,29 +277,29 @@ jobs:
with: with:
name: natives name: natives
path: dist/jme3-natives.zip path: dist/jme3-natives.zip
# Upload maven artifacts to be used later by the deploy job # Upload maven artifacts to be used later by the deploy job
- name: Upload maven artifacts - name: Upload maven artifacts
if: matrix.deploy==true if: matrix.deploy==true
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: maven name: maven
path: dist/maven path: dist/maven
- name: Upload javadoc - name: Upload javadoc
if: matrix.deploy==true if: matrix.deploy==true
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: javadoc name: javadoc
path: dist/javadoc path: dist/javadoc
# Upload release archive to be used later by the deploy job # Upload release archive to be used later by the deploy job
- name: Upload release - name: Upload release
if: github.event_name == 'release' && matrix.deploy==true if: github.event_name == 'release' && matrix.deploy==true
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: release name: release
path: dist/release path: dist/release
# This job deploys the native snapshot. # This job deploys the native snapshot.
# The snapshot is downloaded when people build the engine without setting buildNativeProject # The snapshot is downloaded when people build the engine without setting buildNativeProject
@ -316,7 +320,7 @@ jobs:
then then
git clone --single-branch --branch "$branch" https://github.com/${GITHUB_REPOSITORY}.git . git clone --single-branch --branch "$branch" https://github.com/${GITHUB_REPOSITORY}.git .
fi fi
- name: Download merged natives - name: Download merged natives
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
@ -334,7 +338,7 @@ jobs:
then then
nativeSnapshot=`cat "natives-snapshot.properties"` nativeSnapshot=`cat "natives-snapshot.properties"`
nativeSnapshot="${nativeSnapshot#*=}" nativeSnapshot="${nativeSnapshot#*=}"
# We deploy ONLY if GITHUB_SHA (the current commit hash) is newer than $nativeSnapshot # We deploy ONLY if GITHUB_SHA (the current commit hash) is newer than $nativeSnapshot
if [ "`git rev-list --count $nativeSnapshot..$GITHUB_SHA`" = "0" ]; if [ "`git rev-list --count $nativeSnapshot..$GITHUB_SHA`" = "0" ];
then then
@ -355,9 +359,9 @@ jobs:
echo "No changes, skip." echo "No changes, skip."
else else
if [ "${{ secrets.BINTRAY_GENERIC_REPO }}" = "" ]; if [ "${{ secrets.BINTRAY_GENERIC_REPO }}" = "" ];
then then
echo "Configure the following secrets to enable native snapshot deployment" echo "Configure the following secrets to enable native snapshot deployment"
echo "BINTRAY_GENERIC_REPO, BINTRAY_USER, BINTRAY_APIKEY" echo "BINTRAY_GENERIC_REPO, BINTRAY_USER, BINTRAY_APIKEY"
else else
# Deploy snapshot # Deploy snapshot
bintray_uploadFile dist/jme3-natives.zip \ bintray_uploadFile dist/jme3-natives.zip \
@ -368,17 +372,17 @@ jobs:
"https://github.com/${GITHUB_REPOSITORY}" \ "https://github.com/${GITHUB_REPOSITORY}" \
"${{ secrets.BINTRAY_LICENSE }}" "true" "${{ secrets.BINTRAY_LICENSE }}" "true"
# We reference the snapshot by writing its commit hash in natives-snapshot.properties # We reference the snapshot by writing its commit hash in natives-snapshot.properties
echo "natives.snapshot=$GITHUB_SHA" > natives-snapshot.properties echo "natives.snapshot=$GITHUB_SHA" > natives-snapshot.properties
# We commit the updated natives-snapshot.properties # We commit the updated natives-snapshot.properties
git config --global user.name "Github Actions" git config --global user.name "Github Actions"
git config --global user.email "actions@users.noreply.github.com" git config --global user.email "actions@users.noreply.github.com"
git add natives-snapshot.properties git add natives-snapshot.properties
git commit -m "[skip ci] update natives snapshot" git commit -m "[skip ci] update natives snapshot"
# Pull rebase from the remote repo, just in case there was a push in the meantime # Pull rebase from the remote repo, just in case there was a push in the meantime
git pull -q --rebase git pull -q --rebase
@ -387,39 +391,39 @@ jobs:
# Push # Push
(git -c http.extraheader="AUTHORIZATION: basic $header" push origin "$branch" || true) (git -c http.extraheader="AUTHORIZATION: basic $header" push origin "$branch" || true)
fi fi
fi fi
fi fi
# This job deploys the release # This job deploys the release
DeployRelease: DeployRelease:
needs: [BuildJMonkey] needs: [BuildJMonkey]
name: Deploy Release name: Deploy Release
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
if: github.event_name == 'release' if: github.event_name == 'release'
steps: steps:
# We need to clone everything again for uploadToMaven.sh ... # We need to clone everything again for uploadToMaven.sh ...
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
# Download all the stuff... # Download all the stuff...
- name: Download maven artifacts - name: Download maven artifacts
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: maven name: maven
path: dist/maven path: dist/maven
- name: Download release - name: Download release
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: release name: release
path: dist/release path: dist/release
- name: Deploy to github releases - name: Deploy to github releases
run: | run: |
# We need to get the release id (yeah, it's not the same as the tag) # We need to get the release id (yeah, it's not the same as the tag)
echo "${GITHUB_EVENT_PATH}" echo "${GITHUB_EVENT_PATH}"
@ -436,7 +440,7 @@ jobs:
-H "Content-Type: application/zip" \ -H "Content-Type: application/zip" \
--data-binary @"$filename" \ --data-binary @"$filename" \
"$url" "$url"
- name: Deploy to bintray - name: Deploy to bintray
run: | run: |
source .github/actions/tools/uploadToMaven.sh source .github/actions/tools/uploadToMaven.sh
@ -447,22 +451,22 @@ jobs:
else else
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 }}" 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 }}"
fi fi
# - name: Deploy to github package registry # - name: Deploy to github package registry
# run: | # run: |
# source .github/actions/tools/uploadToMaven.sh # source .github/actions/tools/uploadToMaven.sh
# registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY" # registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY"
# echo "Deploy to github package registry $registry" # echo "Deploy to github package registry $registry"
# uploadAllToMaven dist/maven/ $registry "token" ${{ secrets.GITHUB_TOKEN }} # uploadAllToMaven dist/maven/ $registry "token" ${{ secrets.GITHUB_TOKEN }}
# Deploy the javadoc # Deploy the javadoc
DeployJavaDoc: DeployJavaDoc:
needs: [BuildJMonkey] needs: [BuildJMonkey]
name: Deploy Javadoc name: Deploy Javadoc
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
if: github.event_name == 'release' if: github.event_name == 'release'
steps: steps:
# We are going to need a deploy key for this, since we need # We are going to need a deploy key for this, since we need
# to push to a different repo # to push to a different repo
- name: Set ssh key - name: Set ssh key
@ -477,16 +481,16 @@ jobs:
branch="gh-pages" branch="gh-pages"
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $HOME/.ssh/deploy.key" 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 }} . git clone --single-branch --branch "$branch" git@github.com:${{ secrets.JAVADOC_GHPAGES_REPO }} .
# Download the javadoc in the new directory "newdoc" # Download the javadoc in the new directory "newdoc"
- name: Download javadoc - name: Download javadoc
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: javadoc name: javadoc
path: newdoc path: newdoc
# The actual deploy # The actual deploy
- name: Deploy to github pages - name: Deploy to github pages
run: | run: |
set -f set -f
IFS=$'\n' IFS=$'\n'
@ -508,10 +512,10 @@ jobs:
# if there isn't an index.txt we create one (we need this to list the versions) # 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 if [ ! -f "index.txt" ]; then echo "" > index.txt ; fi
index="`cat index.txt`" index="`cat index.txt`"
# Check if this version is already in index.txt # Check if this version is already in index.txt
addNew=true addNew=true
for v in $index; for v in $index;
do do
if [ "$v" = "$version" ]; if [ "$v" = "$version" ];
then then
@ -538,11 +542,11 @@ jobs:
# Commit the changes # Commit the changes
git config --global user.name "Github Actions" git config --global user.name "Github Actions"
git config --global user.email "actions@users.noreply.github.com" git config --global user.email "actions@users.noreply.github.com"
git add . git add .
git commit -m "$version" git commit -m "$version"
branch="gh-pages" branch="gh-pages"
git push origin "$branch" --force git push origin "$branch" --force
fi fi

Loading…
Cancel
Save