Skip to content

Commit d7ddcd0

Browse files
authored
Merge pull request #352 from kdroidFilter/ci/restructure-native-build-workflow
Restructure CI workflows for native builds
2 parents 23182f5 + 1d5e5fb commit d7ddcd0

5 files changed

Lines changed: 190 additions & 43 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: PR Build Check
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
build-native-macos:
9+
runs-on: macos-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
with:
14+
submodules: recursive
15+
16+
- name: Build macOS native libraries
17+
working-directory: maclib
18+
run: bash build.sh
19+
20+
build-native-linux:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
submodules: recursive
27+
28+
- name: Setup Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: 'stable'
32+
33+
- name: Install dependencies
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y libgtk-3-dev libappindicator3-dev
37+
38+
- name: Build Linux native library
39+
working-directory: linuxlib
40+
run: bash build.sh
41+
42+
build-native-windows:
43+
runs-on: windows-latest
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
with:
48+
submodules: recursive
49+
50+
- name: Build Windows native libraries
51+
working-directory: winlib
52+
run: cmd /c build.bat

.github/workflows/publish-on-maven.yml

Lines changed: 133 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,166 @@
11
name: Publish to Maven Central
22

33
on:
4-
push:
5-
tags:
6-
- '**'
7-
8-
env:
9-
NATIVE_LIBS_DIR: ${{ github.workspace }}/build/nativeLibs
4+
release:
5+
types: [published]
106

117
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
2636

37+
build-native-linux:
38+
if: startsWith(github.event.release.tag_name, 'v')
39+
runs-on: ubuntu-latest
2740
steps:
28-
- uses: actions/checkout@v4
41+
- name: Checkout code
42+
uses: actions/checkout@v4
2943
with:
3044
submodules: recursive
3145

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
3459
env:
35-
NATIVE_LIBS_OUTPUT_DIR: ${{ env.NATIVE_LIBS_DIR }}
60+
NATIVE_LIBS_OUTPUT_DIR: ${{ github.workspace }}/build/nativeLibs
3661

37-
- name: Upload native binaries
62+
- name: Upload Linux x86_64 library
3863
uses: actions/upload-artifact@v4
3964
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
4297

4398
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
45104
runs-on: macos-latest
46-
47105
steps:
48106
- 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/
50141

51-
- name: Download all native binaries
142+
- name: Download Windows ARM64 library
52143
uses: actions/download-artifact@v4
53144
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/
57147

58-
- name: Copy native libs into src/commonMain/resources/
148+
- name: Verify native libraries
59149
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/
62156
63157
- name: Set up JDK
64-
uses: actions/setup-java@v3
158+
uses: actions/setup-java@v4
65159
with:
66160
java-version: '17'
67161
distribution: 'temurin'
68162

69-
- name: Set up Publish to Maven Central
163+
- name: Publish to Maven Central
70164
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
71165
env:
72166
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRALUSERNAME }}

linuxlib

Submodule linuxlib updated 1 file

maclib/build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ set -e
55

66
echo "Building MacTray library..."
77

8-
OUTPUT_DIR="${NATIVE_LIBS_OUTPUT_DIR}"
9-
echo "output dir for mac is: $OUTPUT_DIR"
8+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
9+
OUTPUT_DIR="${NATIVE_LIBS_OUTPUT_DIR:-$SCRIPT_DIR/../src/commonMain/resources}"
10+
echo "Output dir for mac is: $OUTPUT_DIR"
1011

1112
echo "Building for ARM64 (Apple Silicon)..."
1213

winlib

0 commit comments

Comments
 (0)