From 306c0d2027fd0e2dc517a00ae1579319a5c901eb Mon Sep 17 00:00:00 2001 From: LostLuma Date: Wed, 25 Sep 2024 10:32:08 +0200 Subject: [PATCH] Add CI workflows to build the project for all target platforms --- .github/workflows/build-java.yaml | 41 ++++++++++++++++++++++++++++ .github/workflows/build-natives.yaml | 41 ++++++++++++++++++++++++++++ build.gradle.kts | 4 +-- 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-java.yaml create mode 100644 .github/workflows/build-natives.yaml diff --git a/.github/workflows/build-java.yaml b/.github/workflows/build-java.yaml new file mode 100644 index 0000000..0dc515e --- /dev/null +++ b/.github/workflows/build-java.yaml @@ -0,0 +1,41 @@ +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + java: [ + 21, + ] + os: [ + macos-14, + ubuntu-24.04, + windows-2022, + ] + runs-on: ${{ matrix.os }} + steps: + - name: checkout repository + uses: actions/checkout@v4 + - name: validate gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ matrix.java }} + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: setup gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: ${{ github.ref != 'refs/heads/stardust' }} + - name: build + run: ./gradlew build --warning-mode=all + - name: capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '21' }} + uses: actions/upload-artifact@v4 + with: + name: battery-artifacts + path: build/libs + if-no-files-found: error diff --git a/.github/workflows/build-natives.yaml b/.github/workflows/build-natives.yaml new file mode 100644 index 0000000..fc83eea --- /dev/null +++ b/.github/workflows/build-natives.yaml @@ -0,0 +1,41 @@ +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + platform: + - os: macos-14 + extension: dylib + target: x86_64-apple-darwin + - os: macos-14 + extension: dylib + target: aarch64-apple-darwin + - os: ubuntu-24.04 + extension: so + target: x86_64-unknown-linux-gnu + - os: ubuntu-24.04 + extension: so + target: aarch64-unknown-linux-gnu + - os: windows-2022 + extension: dll + target: x86_64-pc-windows-msvc + - os: windows-2022 + extension: dll + target: aarch64-pc-windows-msvc + runs-on: ${{ matrix.platform.os }} + steps: + - name: checkout repository + uses: actions/checkout@v4 + - name: build + uses: houseabsolute/actions-rust-cross@v0 + with: + command: build + args: "--release" + target: ${{ matrix.platform.target }} + - name: capture build artifacts + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + name: battery-jni-${{ matrix.platform.os }}-${{ matrix.platform.target }} + path: target/${{ matrix.platform.target }}/release/*.${{ matrix.platform.extension }} diff --git a/build.gradle.kts b/build.gradle.kts index f1b8784..2a010d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,8 +72,8 @@ publishing { url = uri("https://maven.lostluma.net/releases") credentials { - username = project.property("maven.username").toString() - password = project.property("maven.password").toString() + username = project.properties["maven.username"].toString() + password = project.properties["maven.password"].toString() } } }