Better content loading API (and docs) #367
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: | |
pull_request: | |
branches: [main] | |
push: | |
tags: | |
- '*' | |
paths-ignore: | |
- '.github/**' | |
- 'docs/**' | |
- 'README.md' | |
branches: | |
- main | |
env: | |
MACOSX_DEPLOYMENT_TARGET: "10.10" | |
jobs: | |
apple-natives: | |
runs-on: macos-13 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- run: echo "JAVA_17=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Build natives | |
run: | | |
./gradlew jniGen jnigenBuildMacOsX64 jnigenBuildMacOsXARM64 jnigenBuildIOS | |
- name: Test | |
run: | | |
./gradlew :example:test :jsr223:test :jpms-example:run | |
- name: Upload macOS natives | |
uses: actions/upload-artifact@v4 | |
with: | |
name: apple-natives | |
path: ./*/libs | |
retention-days: 5 | |
most-natives: | |
environment: Codecov | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Download llvm-mingw | |
uses: robinraju/[email protected] | |
with: | |
repository: 'mstorsjo/llvm-mingw' | |
tag: 20240619 | |
fileName: llvm-mingw-20240619-ucrt-ubuntu-20.04-x86_64.tar.xz | |
tarBall: false | |
zipBall: false | |
- name: Set up llvm-mingw | |
run: | | |
sudo mkdir -p /usr/local | |
sudo tar -Jxf llvm-mingw-20240619-ucrt-ubuntu-20.04-x86_64.tar.xz -C /usr/local | |
echo "PATH=/usr/local/llvm-mingw-20240619-ucrt-ubuntu-20.04-x86_64/bin:$PATH" >> $GITHUB_ENV | |
- name: Install cross-compilation toolchains | |
run: | | |
sudo apt update | |
# x86_64 | |
sudo apt install -y --force-yes gcc g++ | |
sudo apt install -y --force-yes libc6-dev linux-libc-dev linux-libc-dev-amd64-cross | |
# x86 | |
sudo apt install -y --force-yes gcc-i686-linux-gnu g++-i686-linux-gnu | |
sudo apt install -y --force-yes lib32stdc++-9-dev libstdc++-9-dev-i386-cross | |
sudo apt install -y --force-yes libc6-dev-i386 libc6-dev-i386-cross linux-libc-dev-i386-cross | |
# arm64 | |
sudo apt install -y --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
sudo apt install -y --force-yes libstdc++-9-dev-arm64-cross linux-libc-dev-arm64-cross | |
# armhf | |
sudo apt install -y --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross | |
sudo apt install -y --force-yes libstdc++-9-dev-armhf-cross linux-libc-dev-armhf-cross | |
# TODO: riscv64 | |
# Windows | |
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: Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Build natives | |
run: | | |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME | |
./gradlew jniGen jnigenBuildLinux jnigenBuildLinux64 | |
./gradlew jniGen jnigenBuildLinuxARM jnigenBuildLinuxARM64 | |
# TODO: ./gradlew jniGen jnigenBuildLinuxRISCV64 | |
./gradlew jniGen jnigenBuildAndroid jnigenBuildWindows jnigenBuildWindows64 jnigenBuildWindowsARM64 | |
- name: Test (Desktop) | |
run: | | |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME | |
./gradlew --info --stacktrace :example:test :jsr223:test :jpms-example:run | |
- name: Jacoco Test Report | |
run: | | |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME | |
./gradlew jacocoTestReport | |
- name: Upload test result | |
uses: codecov/codecov-action@v4 | |
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, | |
./luaj/build/reports/jacoco/report.xml, | |
./luajava/build/reports/jacoco/report.xml, | |
./jsr223/build/reports/jacoco/report.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
- name: Upload all output libs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: most-natives | |
path: ./*/libs | |
retention-days: 5 | |
linux-testing: | |
runs-on: ubuntu-latest | |
needs: | |
- most-natives | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: most-natives | |
- 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@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: most-natives | |
- name: JniGen | |
run: | | |
./gradlew jniGen | |
- name: Test | |
run: | | |
./gradlew --info --stacktrace :example:test :jsr223:test :jpms-example:run | |
android-testing: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [ 21 ] | |
android-arch: [ 'x86_64', 'x86' ] | |
include: | |
- api-level: 24 | |
android-arch: 'x86' | |
- api-level: 33 | |
android-arch: 'x86_64' | |
needs: | |
- most-natives | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: most-natives | |
- name: JniGen | |
run: | | |
./gradlew jniGen | |
- name: Pack Android natives | |
run: | | |
./gradlew :android:assemble | |
- name: AVD cache | |
uses: actions/cache@v4 | |
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 --info --stacktrace :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@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Download apple-natives artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: apple-natives | |
- name: Download most-natives artifact | |
uses: actions/download-artifact@v4 | |
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@v4 | |
with: | |
name: natives | |
path: ./*/libs | |
- name: Release? | |
if: | | |
startsWith(github.ref, 'refs/tags/') | |
run: echo "IS_RELEASE=true" >> $GITHUB_ENV | |
- name: Publish | |
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | |
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@v4 | |
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 | |
mac-arm-test: | |
needs: | |
- pack-natives | |
runs-on: macos-14 | |
steps: | |
- name: Download example tests | |
uses: actions/download-artifact@v4 | |
with: | |
name: example | |
- name: Run example tests | |
run: | | |
java -jar example-all.jar --test | |
linux-arm-test: | |
environment: Bitrise | |
needs: | |
- pack-natives | |
runs-on: ubuntu-20.04 | |
steps: | |
- 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 |