From 1d5e5fb96d36d6091062827a989ebab0be17dea6 Mon Sep 17 00:00:00 2001 From: Elie Gambache Date: Tue, 3 Feb 2026 08:48:23 +0200 Subject: [PATCH] Restructure CI workflows following ComposeNativeWebview pattern - Replace matrix strategy with individual jobs per platform - Switch trigger from tag push to release event with v* filter - Add version extraction from release tag - Use individual named artifacts per platform/arch - Add native library verification step in publish job - Add pr-build-check.yml for PR validation - Update build scripts to use NATIVE_LIBS_OUTPUT_DIR with fallback - Bump actions to v4 --- .github/workflows/pr-build-check.yml | 52 ++++++++ .github/workflows/publish-on-maven.yml | 172 +++++++++++++++++++------ linuxlib | 2 +- maclib/build.sh | 5 +- winlib | 2 +- 5 files changed, 190 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/pr-build-check.yml diff --git a/.github/workflows/pr-build-check.yml b/.github/workflows/pr-build-check.yml new file mode 100644 index 0000000..a18d2d3 --- /dev/null +++ b/.github/workflows/pr-build-check.yml @@ -0,0 +1,52 @@ +name: PR Build Check + +on: + pull_request: + branches: [master] + +jobs: + build-native-macos: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build macOS native libraries + working-directory: maclib + run: bash build.sh + + build-native-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libappindicator3-dev + + - name: Build Linux native library + working-directory: linuxlib + run: bash build.sh + + build-native-windows: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Windows native libraries + working-directory: winlib + run: cmd /c build.bat diff --git a/.github/workflows/publish-on-maven.yml b/.github/workflows/publish-on-maven.yml index 84e4d91..964ace0 100644 --- a/.github/workflows/publish-on-maven.yml +++ b/.github/workflows/publish-on-maven.yml @@ -1,72 +1,166 @@ name: Publish to Maven Central on: - push: - tags: - - '**' - -env: - NATIVE_LIBS_DIR: ${{ github.workspace }}/build/nativeLibs + release: + types: [published] jobs: - build-native: - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - command: | - cd linuxlib && bash build.sh - - os: macos-latest - command: | - cd maclib && bash build.sh - - os: windows-latest - command: | - cd winlib && cmd /c build.bat + build-native-macos: + if: startsWith(github.event.release.tag_name, 'v') + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build macOS native libraries + working-directory: maclib + run: bash build.sh + env: + NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs + + - name: Upload macOS ARM64 library + uses: actions/upload-artifact@v4 + with: + name: native-darwin-aarch64 + path: build/nativeLibs/darwin-aarch64/libMacTray.dylib + retention-days: 1 + + - name: Upload macOS x86_64 library + uses: actions/upload-artifact@v4 + with: + name: native-darwin-x86-64 + path: build/nativeLibs/darwin-x86-64/libMacTray.dylib + retention-days: 1 + build-native-linux: + if: startsWith(github.event.release.tag_name, 'v') + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 with: submodules: recursive - - name: Build native binary - run: ${{ matrix.command }} + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libappindicator3-dev + + - name: Build Linux native library + working-directory: linuxlib + run: bash build.sh env: - NATIVE_LIBS_OUTPUT_DIR: ${{ env.NATIVE_LIBS_DIR }} + NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs - - name: Upload native binaries + - name: Upload Linux x86_64 library uses: actions/upload-artifact@v4 with: - name: nativeLibs-${{ matrix.os }} - path: ${{ env.NATIVE_LIBS_DIR }}/** + name: native-linux-x86-64 + path: build/nativeLibs/linux-x86-64/libsystray.so + retention-days: 1 + + build-native-windows: + if: startsWith(github.event.release.tag_name, 'v') + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Windows native libraries + working-directory: winlib + run: cmd /c build.bat + env: + NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs + + - name: Upload Windows x64 library + uses: actions/upload-artifact@v4 + with: + name: native-win32-x86-64 + path: build/nativeLibs/win32-x86-64/tray.dll + retention-days: 1 + + - name: Upload Windows ARM64 library + uses: actions/upload-artifact@v4 + with: + name: native-win32-arm64 + path: build/nativeLibs/win32-arm64/tray.dll + retention-days: 1 publish: - needs: [ "build-native" ] + if: startsWith(github.event.release.tag_name, 'v') + needs: + - build-native-macos + - build-native-linux + - build-native-windows runs-on: macos-latest - steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set version from tag + shell: bash + run: | + TAG="${{ github.event.release.tag_name }}" + VERSION_NAME="${TAG#v}" + echo "VERSION_NAME=$VERSION_NAME" >> "$GITHUB_ENV" + sed -i.bak "s/^VERSION_NAME=.*/VERSION_NAME=$VERSION_NAME/" gradle.properties + rm -f gradle.properties.bak + + - name: Download macOS ARM64 library + uses: actions/download-artifact@v4 + with: + name: native-darwin-aarch64 + path: src/commonMain/resources/darwin-aarch64/ + + - name: Download macOS x86_64 library + uses: actions/download-artifact@v4 + with: + name: native-darwin-x86-64 + path: src/commonMain/resources/darwin-x86-64/ + + - name: Download Linux x86_64 library + uses: actions/download-artifact@v4 + with: + name: native-linux-x86-64 + path: src/commonMain/resources/linux-x86-64/ + + - name: Download Windows x64 library + uses: actions/download-artifact@v4 + with: + name: native-win32-x86-64 + path: src/commonMain/resources/win32-x86-64/ - - name: Download all native binaries + - name: Download Windows ARM64 library uses: actions/download-artifact@v4 with: - pattern: nativeLibs-* - path: ${{ env.NATIVE_LIBS_DIR }} - merge-multiple: true + name: native-win32-arm64 + path: src/commonMain/resources/win32-arm64/ - - name: Copy native libs into src/commonMain/resources/ + - name: Verify native libraries run: | - mkdir -p src/commonMain/resources/ - cp -r ${{ env.NATIVE_LIBS_DIR }}/* src/commonMain/resources/ + echo "=== Native libraries in resources ===" + ls -la src/commonMain/resources/darwin-aarch64/ + ls -la src/commonMain/resources/darwin-x86-64/ + ls -la src/commonMain/resources/linux-x86-64/ + ls -la src/commonMain/resources/win32-x86-64/ + ls -la src/commonMain/resources/win32-arm64/ - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - - name: Set up Publish to Maven Central + - name: Publish to Maven Central run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRALUSERNAME }} diff --git a/linuxlib b/linuxlib index f50e558..977c45e 160000 --- a/linuxlib +++ b/linuxlib @@ -1 +1 @@ -Subproject commit f50e55837e1ddfd2017c4ef4240b3db466a75a57 +Subproject commit 977c45eb0e77df68f07b62eaffc1195f8d829402 diff --git a/maclib/build.sh b/maclib/build.sh index 4834b61..e267df6 100755 --- a/maclib/build.sh +++ b/maclib/build.sh @@ -5,8 +5,9 @@ set -e echo "Building MacTray library..." -OUTPUT_DIR="${NATIVE_LIBS_OUTPUT_DIR}" -echo "output dir for mac is: $OUTPUT_DIR" +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +OUTPUT_DIR="${NATIVE_LIBS_OUTPUT_DIR:-$SCRIPT_DIR/../src/commonMain/resources}" +echo "Output dir for mac is: $OUTPUT_DIR" echo "Building for ARM64 (Apple Silicon)..." diff --git a/winlib b/winlib index 80c0643..b78cb80 160000 --- a/winlib +++ b/winlib @@ -1 +1 @@ -Subproject commit 80c0643b4965e4315a8e1d0360158f0a34a4a35b +Subproject commit b78cb8033cd1a2d7ed0a0fe2cd593dad59ba633e