From 592b7fc4cde85ac4a6ccdf1171b4bc0adb85f1b2 Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 11:47:11 +0100 Subject: [PATCH 01/10] add native compilation and publish (#24) --- .github/workflows/native.yml | 68 ++++++++++++++++++++++++++++++++++++ pom.xml | 33 +++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/native.yml diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml new file mode 100644 index 0000000..26e284a --- /dev/null +++ b/.github/workflows/native.yml @@ -0,0 +1,68 @@ +name: Native + +on: + workflow_dispatch: + inputs: + releaseVersion: + description: 'Release version' + required: true + developmentVersion: + description: 'Next development version' + required: true + prerelease: + description: 'Is pre release' + required: false + default: 'true' + +jobs: + build: + name: WebApp on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + steps: + + - name: Show input parameters + run: | + echo "Release version: ${{ github.event.inputs.releaseVersion }}" + echo "Development version: ${{ github.event.inputs.developmentVersion }}" + echo "Is prerelease: ${{ github.event.inputs.prerelease == 'true' }}" + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '21' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: 'true' + + - name: compile + run: mvn -B native:compile -Pnative + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ github.event.inputs.releaseVersion }} + name: Release v${{ github.event.inputs.releaseVersion }} + generate_release_notes: true + body: | + ## Docker Image + + The Docker image for this release is available at: + `docker pull roomelephant/elephlink:${{ github.event.inputs.releaseVersion }}` + + You can also use the `latest` tag: + `docker pull roomelephant/elephlink:latest` + + # Additional Notes + files: | + build/native/nativeCompile/* + draft: false + prerelease: ${{ github.event.inputs.prerelease == 'true' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/pom.xml b/pom.xml index 877ae8a..6bb99de 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ 10.23.1 3.7.1 3.0.1 + 0.10.6 2.0.17 1.5.18 @@ -148,6 +149,38 @@ + + + native + + + + org.graalvm.buildtools + native-maven-plugin + ${native.maven.plugin.version} + true + + + build-native + + compile-no-fork + + package + + + test-native + + test + + test + + + + + + + + github From 5356387e17af1679e475ece639f77e47ea1f4a03 Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 12:02:17 +0100 Subject: [PATCH 02/10] Update native.yml --- .github/workflows/native.yml | 45 ++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 26e284a..c8cf026 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -42,7 +42,38 @@ jobs: native-image-job-reports: 'true' - name: compile - run: mvn -B native:compile -Pnative + run: mvn -B -Pnative package + + - name: Upload binary + run: | + ls ./build/native/nativeCompile/ + + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: elephlink-${{ matrix.os }} + path: ./build/native/nativeCompile/elephlink-app + + release: + runs-on: ubuntu-latest + steps: + - name: Download macOS binary + uses: actions/download-artifact@v4 + with: + name: elephlink-macos-latest + path: build/macos + + - name: Download Windows binary + uses: actions/download-artifact@v4 + with: + name: elephlink-windows-latest + path: build/windows + + - name: Download Linux binary + uses: actions/download-artifact@v4 + with: + name: elephlink-ubuntu-latest + path: build/linux - name: Create GitHub Release uses: softprops/action-gh-release@v1 @@ -50,18 +81,8 @@ jobs: tag_name: v${{ github.event.inputs.releaseVersion }} name: Release v${{ github.event.inputs.releaseVersion }} generate_release_notes: true - body: | - ## Docker Image - - The Docker image for this release is available at: - `docker pull roomelephant/elephlink:${{ github.event.inputs.releaseVersion }}` - - You can also use the `latest` tag: - `docker pull roomelephant/elephlink:latest` - - # Additional Notes files: | - build/native/nativeCompile/* + build/**/* draft: false prerelease: ${{ github.event.inputs.prerelease == 'true' }} env: From 94be4a415dbc7e5405ed6d2481c2a56fd771b5ed Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 12:04:31 +0100 Subject: [PATCH 03/10] Update native.yml --- .github/workflows/native.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index c8cf026..a73cb38 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -55,6 +55,7 @@ jobs: path: ./build/native/nativeCompile/elephlink-app release: + needs: build runs-on: ubuntu-latest steps: - name: Download macOS binary From ca31013235b085d0cbe02e6d41c6829f6555ebbf Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 12:11:49 +0100 Subject: [PATCH 04/10] Update native.yml --- .github/workflows/native.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index a73cb38..d779483 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -44,15 +44,11 @@ jobs: - name: compile run: mvn -B -Pnative package - - name: Upload binary - run: | - ls ./build/native/nativeCompile/ - - name: Upload binary uses: actions/upload-artifact@v4 with: name: elephlink-${{ matrix.os }} - path: ./build/native/nativeCompile/elephlink-app + path: ./build/native/nativeCompile/elephlink release: needs: build From 34fd50fbe4e8329ada19aad7c4e382672946089e Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 16:39:29 +0100 Subject: [PATCH 05/10] Update native.yml --- .github/workflows/native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index d779483..b0b589f 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -48,7 +48,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: elephlink-${{ matrix.os }} - path: ./build/native/nativeCompile/elephlink + path: target/elephlink release: needs: build From 9757c44142c2f949be2a0c53e35b940183ceeb4e Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 16:57:33 +0100 Subject: [PATCH 06/10] Update native.yml --- .github/workflows/native.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index b0b589f..1c2f5d9 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -44,12 +44,20 @@ jobs: - name: compile run: mvn -B -Pnative package - - name: Upload binary + - name: Upload non-Windows binary + if: matrix.os != 'windows-latest' uses: actions/upload-artifact@v4 with: name: elephlink-${{ matrix.os }} path: target/elephlink + - name: Upload Windows binary + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: elephlink-${{ matrix.os }} + path: target/elephlink.exe + release: needs: build runs-on: ubuntu-latest From db95fade07ac75fa5917a445e7c9f7af4eacfc72 Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 17:12:12 +0100 Subject: [PATCH 07/10] Update native.yml --- .github/workflows/native.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 1c2f5d9..6aaa059 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -62,24 +62,30 @@ jobs: needs: build runs-on: ubuntu-latest steps: + - name: Download Linux binary + uses: actions/download-artifact@v4 + with: + name: elephlink-ubuntu-latest + path: build/linux + - name: Download macOS binary uses: actions/download-artifact@v4 with: name: elephlink-macos-latest path: build/macos + - name: Rename binaries for release + run: | + mv build/linux/elephlink build/elephlink-linux-${{ github.event.inputs.releaseVersion }} + mv build/macos/elephlink build/elephlink-macos-${{ github.event.inputs.releaseVersion }} + mv build/windows/elephlink.exe build/elephlink-windows-${{ github.event.inputs.releaseVersion }}.exe + - name: Download Windows binary uses: actions/download-artifact@v4 with: name: elephlink-windows-latest path: build/windows - - name: Download Linux binary - uses: actions/download-artifact@v4 - with: - name: elephlink-ubuntu-latest - path: build/linux - - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: @@ -87,7 +93,7 @@ jobs: name: Release v${{ github.event.inputs.releaseVersion }} generate_release_notes: true files: | - build/**/* + build/elephlink-* draft: false prerelease: ${{ github.event.inputs.prerelease == 'true' }} env: From 39d82fb09cb4d0c84b147d6c12c3ccddddc89481 Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 17:20:57 +0100 Subject: [PATCH 08/10] Update native.yml --- .github/workflows/native.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 6aaa059..7976ced 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -74,18 +74,18 @@ jobs: name: elephlink-macos-latest path: build/macos - - name: Rename binaries for release - run: | - mv build/linux/elephlink build/elephlink-linux-${{ github.event.inputs.releaseVersion }} - mv build/macos/elephlink build/elephlink-macos-${{ github.event.inputs.releaseVersion }} - mv build/windows/elephlink.exe build/elephlink-windows-${{ github.event.inputs.releaseVersion }}.exe - - name: Download Windows binary uses: actions/download-artifact@v4 with: name: elephlink-windows-latest path: build/windows + - name: Rename binaries for release + run: | + mv build/linux/elephlink build/elephlink-linux-${{ github.event.inputs.releaseVersion }} + mv build/macos/elephlink build/elephlink-macos-${{ github.event.inputs.releaseVersion }} + mv build/windows/elephlink.exe build/elephlink-windows-${{ github.event.inputs.releaseVersion }}.exe + - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: From b9605e64e6d64f1e1f61f6209bcd95993cd36c84 Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 19:22:03 +0100 Subject: [PATCH 09/10] Update native.yml --- .github/workflows/native.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 7976ced..79cd8f5 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -82,9 +82,9 @@ jobs: - name: Rename binaries for release run: | - mv build/linux/elephlink build/elephlink-linux-${{ github.event.inputs.releaseVersion }} - mv build/macos/elephlink build/elephlink-macos-${{ github.event.inputs.releaseVersion }} - mv build/windows/elephlink.exe build/elephlink-windows-${{ github.event.inputs.releaseVersion }}.exe + mv build/linux/elephlink output/elephlink-linux-${{ github.event.inputs.releaseVersion }} + mv build/macos/elephlink output/elephlink-macos-${{ github.event.inputs.releaseVersion }} + mv build/windows/elephlink.exe output/elephlink-windows-${{ github.event.inputs.releaseVersion }}.exe - name: Create GitHub Release uses: softprops/action-gh-release@v1 @@ -93,7 +93,7 @@ jobs: name: Release v${{ github.event.inputs.releaseVersion }} generate_release_notes: true files: | - build/elephlink-* + output/elephlink-* draft: false prerelease: ${{ github.event.inputs.prerelease == 'true' }} env: From 19d9f3891037f41f3fa750a400071ee5c257e5de Mon Sep 17 00:00:00 2001 From: JPedroBorges Date: Sun, 22 Jun 2025 20:11:03 +0100 Subject: [PATCH 10/10] fix native utf8 encoding and reflexion issues --- .../com/roomelephant/elephlink/infra/config/YmlParser.java | 7 +++++-- .../resources/META-INF/native-image/reflect-config.json | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/META-INF/native-image/reflect-config.json diff --git a/src/main/java/com/roomelephant/elephlink/infra/config/YmlParser.java b/src/main/java/com/roomelephant/elephlink/infra/config/YmlParser.java index 8e1e9ae..2350dc7 100644 --- a/src/main/java/com/roomelephant/elephlink/infra/config/YmlParser.java +++ b/src/main/java/com/roomelephant/elephlink/infra/config/YmlParser.java @@ -3,6 +3,9 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.Map; import lombok.extern.slf4j.Slf4j; @@ -14,10 +17,10 @@ public class YmlParser { @SuppressWarnings("unchecked") public Map parse(String fileName) { - try (FileInputStream fis = new FileInputStream(Path.of(fileName).toFile())) { + try (FileInputStream fis = new FileInputStream(Path.of(fileName).toFile()); Reader reader = new InputStreamReader(fis, StandardCharsets.UTF_8)) { LoadSettings settings = LoadSettings.builder().build(); Load load = new Load(settings); - return (Map) load.loadFromInputStream(fis); + return (Map) load.loadFromReader(reader); } catch (FileNotFoundException e) { throw new IllegalArgumentException("file '" + fileName + "' not found", e); } catch (IOException e) { diff --git a/src/main/resources/META-INF/native-image/reflect-config.json b/src/main/resources/META-INF/native-image/reflect-config.json new file mode 100644 index 0000000..e322ac2 --- /dev/null +++ b/src/main/resources/META-INF/native-image/reflect-config.json @@ -0,0 +1,7 @@ +[ + { + "name": "com.roomelephant.elephlink.adapters.cloudflare.TokenVerifyResponse", + "allDeclaredConstructors": true, + "allDeclaredFields": true + } +] \ No newline at end of file