Build and Publish #247
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modified from https://github.com/libgdx/libgdx/blob/master/.github/workflows/build-publish.yml | |
name: Build and Publish | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
paths-ignore: | |
- '.github/**' | |
- 'docs/**' | |
- 'README.md' | |
branches: | |
- main | |
env: | |
MACOSX_DEPLOYMENT_TARGET: "10.10" | |
jobs: | |
apple-natives: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build natives | |
run: | | |
./gradlew jniGen jnigenBuild | |
- name: Test | |
run: | | |
./gradlew :example:test :jsr223:test :jpms-example:run | |
- name: Upload macOS/iOS natives | |
uses: actions/upload-artifact@v3 | |
with: | |
name: apple-natives | |
path: ./*/libs | |
most-natives: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Install cross-compilation toolchains | |
run: | | |
sudo apt update | |
sudo apt install -y --force-yes gcc g++ linux-libc-dev libc6-dev | |
sudo apt install -y --force-yes libc6-dev-i386 lib32stdc++-9-dev | |
sudo apt install -y --force-yes linux-libc-dev linux-libc-dev-i386-cross | |
sudo apt install -y --force-yes linux-libc-dev-armhf-cross linux-libc-dev-arm64-cross linux-libc-dev-amd64-cross | |
sudo apt install -y --force-yes libstdc++-9-dev-i386-cross libstdc++-9-dev-arm64-cross libstdc++-9-dev-armhf-cross | |
sudo apt install -y --force-yes gcc-i686-linux-gnu g++-i686-linux-gnu libc6-dev-i386-cross | |
sudo apt install -y --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
sudo apt install -y --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross | |
sudo apt install -y --force-yes mingw-w64 lib32z1 | |
- name: Install PatchELF (verneed-fix) | |
run: | | |
git clone https://github.com/gudzpoz/patchelf.git | |
cd patchelf | |
git checkout 1684a4606be1fef189d04a465adc0c9d31421dac | |
./bootstrap.sh | |
./configure | |
make | |
make check | |
`pwd`/src/patchelf --version | |
echo "`pwd`/src" >> $GITHUB_PATH | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build natives | |
run: | | |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME | |
./gradlew jniGen jnigenBuild | |
- name: Test (Desktop) | |
run: | | |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME | |
./gradlew :example:test :jsr223:test | |
- name: Jacoco Test Report | |
run: | | |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME | |
./gradlew jacocoTestReport | |
- name: Upload test result | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./lua51/build/reports/jacoco/report.xml,./lua52/build/reports/jacoco/report.xml,./lua53/build/reports/jacoco/report.xml,./lua54/build/reports/jacoco/report.xml,./luajit/build/reports/jacoco/report.xml,./luajava/build/reports/jacoco/report.xml,./jsr223/build/reports/jacoco/report.xml | |
verbose: true | |
- name: Upload all output libs | |
uses: actions/upload-artifact@v3 | |
with: | |
name: most-natives | |
path: ./*/libs | |
- name: Cleanup Gradle Cache | |
run: | | |
rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
rm -f ~/.gradle/caches/modules-2/gc.properties | |
linux-testing: | |
runs-on: ubuntu-latest | |
needs: | |
- most-natives | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: most-natives | |
- name: Gradle cache | |
uses: gradle/[email protected] | |
- name: JniGen | |
run: | | |
./gradlew jniGen | |
- name: Build example | |
run: | | |
./gradlew :example:shadowJar | |
- name: Test on Ubuntu 14.04 | |
run: | | |
sudo docker build -t ljtest-glibc -f example/docker/glibc/Dockerfile example/build/libs | |
sudo docker run --rm ljtest-glibc | |
- name: Test on Alpine | |
run: | | |
sudo docker build -t ljtest-musl -f example/docker/musl/Dockerfile example/build/libs | |
sudo docker run --rm ljtest-musl | |
windows-testing: | |
runs-on: windows-latest | |
needs: | |
- most-natives | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: most-natives | |
- name: JniGen | |
run: | | |
./gradlew jniGen | |
- name: Test | |
run: | | |
./gradlew :example:test :jsr223:test | |
android-testing: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [ 21, 24 ] | |
android-arch: [ 'x86_64', 'x86' ] | |
include: | |
- api-level: 27 | |
android-arch: 'x86_64' | |
- api-level: 30 | |
android-arch: 'x86_64' | |
- api-level: 33 | |
android-arch: 'x86_64' | |
needs: | |
- most-natives | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: most-natives | |
- name: Gradle cache | |
uses: gradle/[email protected] | |
- name: JniGen | |
run: | | |
./gradlew jniGen | |
- name: Pack Android natives | |
run: | | |
./gradlew :android:assemble | |
- name: AVD cache | |
uses: actions/cache@v3 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }}-${{ matrix.android-arch }} | |
- name: Enable KVM for linux runners | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ matrix.android-arch }} | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
- name: Test on Android AVD | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ matrix.android-arch }} | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: ./gradlew :android:android-test:connectedAndroidTest | |
pack-natives: | |
environment: OSSRH | |
needs: | |
- apple-natives | |
- most-natives | |
- windows-testing | |
- android-testing | |
- linux-testing | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Download apple-natives artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: apple-natives | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: most-natives | |
- name: JniGen | |
run: | | |
./gradlew jniGen | |
- name: Pack desktop natives | |
run: | | |
ant -f lua51/jni/build.xml pack-natives | |
ant -f lua52/jni/build.xml pack-natives | |
ant -f lua53/jni/build.xml pack-natives | |
ant -f lua54/jni/build.xml pack-natives | |
ant -f luajit/jni/build.xml pack-natives | |
- name: Pack Android AAR | |
run: | | |
./gradlew :android:assemble | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: natives | |
path: ./*/libs | |
- name: Release? | |
if: | | |
startsWith(github.ref, 'refs/tags/') | |
run: echo "IS_RELEASE=true" >> $GITHUB_ENV | |
- name: Publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | |
GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} | |
GPG_SECKEY: ${{ secrets.SIGNING_SECRET_KEY }} | |
GITHUB_REF: ${{ github.ref }} | |
run: | | |
./gradlew build -x test | |
./gradlew publish -Dorg.gradle.parallel=false | |
- name: Build example | |
run: | | |
./gradlew :example:shadowJar | |
- name: Upload example | |
uses: actions/upload-artifact@v3 | |
with: | |
name: example | |
path: example/build/libs/example-all.jar | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
files: example/build/libs/example-all.jar | |
arm-tests: | |
environment: Bitrise | |
needs: | |
- pack-natives | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Trigger Bitrise tests for macOS on M1 | |
env: | |
BITRISE_TOKEN: ${{ secrets.BITRISE_TOKEN }} | |
run: | | |
curl -X POST -H "Authorization: $BITRISE_TOKEN" -d '{"hook_info":{"type":"bitrise"},"build_params":{"branch":"main","workflow_id":"primary"}}' https://app.bitrise.io/app/ace86394e12a32ad/build/start.json | |
- name: Trigger CircleCI tests for Linux on arm64 | |
env: | |
CIRCLECI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }} | |
run: | | |
curl -X POST -H "Circle-Token: $CIRCLECI_TOKEN" https://circleci.com/api/v2/project/github/gudzpoz/luajava/pipeline |