|
1 | 1 | name: Publish to Maven Central |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - '**' |
7 | | - |
8 | | -env: |
9 | | - NATIVE_LIBS_DIR: ${{ github.workspace }}/build/nativeLibs |
| 4 | + release: |
| 5 | + types: [published] |
10 | 6 |
|
11 | 7 | jobs: |
12 | | - build-native: |
13 | | - runs-on: ${{ matrix.os }} |
14 | | - strategy: |
15 | | - matrix: |
16 | | - include: |
17 | | - - os: ubuntu-latest |
18 | | - command: | |
19 | | - cd linuxlib && bash build.sh |
20 | | - - os: macos-latest |
21 | | - command: | |
22 | | - cd maclib && bash build.sh |
23 | | - - os: windows-latest |
24 | | - command: | |
25 | | - cd winlib && cmd /c build.bat |
| 8 | + build-native-macos: |
| 9 | + if: startsWith(github.event.release.tag_name, 'v') |
| 10 | + runs-on: macos-latest |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + submodules: recursive |
| 16 | + |
| 17 | + - name: Build macOS native libraries |
| 18 | + working-directory: maclib |
| 19 | + run: bash build.sh |
| 20 | + env: |
| 21 | + NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs |
| 22 | + |
| 23 | + - name: Upload macOS ARM64 library |
| 24 | + uses: actions/upload-artifact@v4 |
| 25 | + with: |
| 26 | + name: native-darwin-aarch64 |
| 27 | + path: build/nativeLibs/darwin-aarch64/libMacTray.dylib |
| 28 | + retention-days: 1 |
| 29 | + |
| 30 | + - name: Upload macOS x86_64 library |
| 31 | + uses: actions/upload-artifact@v4 |
| 32 | + with: |
| 33 | + name: native-darwin-x86-64 |
| 34 | + path: build/nativeLibs/darwin-x86-64/libMacTray.dylib |
| 35 | + retention-days: 1 |
26 | 36 |
|
| 37 | + build-native-linux: |
| 38 | + if: startsWith(github.event.release.tag_name, 'v') |
| 39 | + runs-on: ubuntu-latest |
27 | 40 | steps: |
28 | | - - uses: actions/checkout@v4 |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v4 |
29 | 43 | with: |
30 | 44 | submodules: recursive |
31 | 45 |
|
32 | | - - name: Build native binary |
33 | | - run: ${{ matrix.command }} |
| 46 | + - name: Setup Go |
| 47 | + uses: actions/setup-go@v5 |
| 48 | + with: |
| 49 | + go-version: 'stable' |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: | |
| 53 | + sudo apt-get update |
| 54 | + sudo apt-get install -y libgtk-3-dev libappindicator3-dev |
| 55 | +
|
| 56 | + - name: Build Linux native library |
| 57 | + working-directory: linuxlib |
| 58 | + run: bash build.sh |
34 | 59 | env: |
35 | | - NATIVE_LIBS_OUTPUT_DIR: ${{ env.NATIVE_LIBS_DIR }} |
| 60 | + NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs |
36 | 61 |
|
37 | | - - name: Upload native binaries |
| 62 | + - name: Upload Linux x86_64 library |
38 | 63 | uses: actions/upload-artifact@v4 |
39 | 64 | with: |
40 | | - name: nativeLibs-${{ matrix.os }} |
41 | | - path: ${{ env.NATIVE_LIBS_DIR }}/** |
| 65 | + name: native-linux-x86-64 |
| 66 | + path: build/nativeLibs/linux-x86-64/libsystray.so |
| 67 | + retention-days: 1 |
| 68 | + |
| 69 | + build-native-windows: |
| 70 | + if: startsWith(github.event.release.tag_name, 'v') |
| 71 | + runs-on: windows-latest |
| 72 | + steps: |
| 73 | + - name: Checkout code |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + submodules: recursive |
| 77 | + |
| 78 | + - name: Build Windows native libraries |
| 79 | + working-directory: winlib |
| 80 | + run: cmd /c build.bat |
| 81 | + env: |
| 82 | + NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs |
| 83 | + |
| 84 | + - name: Upload Windows x64 library |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: native-win32-x86-64 |
| 88 | + path: build/nativeLibs/win32-x86-64/tray.dll |
| 89 | + retention-days: 1 |
| 90 | + |
| 91 | + - name: Upload Windows ARM64 library |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + name: native-win32-arm64 |
| 95 | + path: build/nativeLibs/win32-arm64/tray.dll |
| 96 | + retention-days: 1 |
42 | 97 |
|
43 | 98 | publish: |
44 | | - needs: [ "build-native" ] |
| 99 | + if: startsWith(github.event.release.tag_name, 'v') |
| 100 | + needs: |
| 101 | + - build-native-macos |
| 102 | + - build-native-linux |
| 103 | + - build-native-windows |
45 | 104 | runs-on: macos-latest |
46 | | - |
47 | 105 | steps: |
48 | 106 | - name: Checkout code |
49 | | - uses: actions/checkout@v3 |
| 107 | + uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - name: Set version from tag |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + TAG="${{ github.event.release.tag_name }}" |
| 113 | + VERSION_NAME="${TAG#v}" |
| 114 | + echo "VERSION_NAME=$VERSION_NAME" >> "$GITHUB_ENV" |
| 115 | + sed -i.bak "s/^VERSION_NAME=.*/VERSION_NAME=$VERSION_NAME/" gradle.properties |
| 116 | + rm -f gradle.properties.bak |
| 117 | +
|
| 118 | + - name: Download macOS ARM64 library |
| 119 | + uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + name: native-darwin-aarch64 |
| 122 | + path: src/commonMain/resources/darwin-aarch64/ |
| 123 | + |
| 124 | + - name: Download macOS x86_64 library |
| 125 | + uses: actions/download-artifact@v4 |
| 126 | + with: |
| 127 | + name: native-darwin-x86-64 |
| 128 | + path: src/commonMain/resources/darwin-x86-64/ |
| 129 | + |
| 130 | + - name: Download Linux x86_64 library |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + name: native-linux-x86-64 |
| 134 | + path: src/commonMain/resources/linux-x86-64/ |
| 135 | + |
| 136 | + - name: Download Windows x64 library |
| 137 | + uses: actions/download-artifact@v4 |
| 138 | + with: |
| 139 | + name: native-win32-x86-64 |
| 140 | + path: src/commonMain/resources/win32-x86-64/ |
50 | 141 |
|
51 | | - - name: Download all native binaries |
| 142 | + - name: Download Windows ARM64 library |
52 | 143 | uses: actions/download-artifact@v4 |
53 | 144 | with: |
54 | | - pattern: nativeLibs-* |
55 | | - path: ${{ env.NATIVE_LIBS_DIR }} |
56 | | - merge-multiple: true |
| 145 | + name: native-win32-arm64 |
| 146 | + path: src/commonMain/resources/win32-arm64/ |
57 | 147 |
|
58 | | - - name: Copy native libs into src/commonMain/resources/ |
| 148 | + - name: Verify native libraries |
59 | 149 | run: | |
60 | | - mkdir -p src/commonMain/resources/ |
61 | | - cp -r ${{ env.NATIVE_LIBS_DIR }}/* src/commonMain/resources/ |
| 150 | + echo "=== Native libraries in resources ===" |
| 151 | + ls -la src/commonMain/resources/darwin-aarch64/ |
| 152 | + ls -la src/commonMain/resources/darwin-x86-64/ |
| 153 | + ls -la src/commonMain/resources/linux-x86-64/ |
| 154 | + ls -la src/commonMain/resources/win32-x86-64/ |
| 155 | + ls -la src/commonMain/resources/win32-arm64/ |
62 | 156 |
|
63 | 157 | - name: Set up JDK |
64 | | - uses: actions/setup-java@v3 |
| 158 | + uses: actions/setup-java@v4 |
65 | 159 | with: |
66 | 160 | java-version: '17' |
67 | 161 | distribution: 'temurin' |
68 | 162 |
|
69 | | - - name: Set up Publish to Maven Central |
| 163 | + - name: Publish to Maven Central |
70 | 164 | run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache |
71 | 165 | env: |
72 | 166 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRALUSERNAME }} |
|
0 commit comments