@@ -9,9 +9,29 @@ permissions:
99 contents : read
1010
1111jobs :
12- build-and-publish :
13- name : Build and Publish to Maven Central
14- runs-on : ubuntu-latest
12+ build-natives :
13+ name : Build natives for ${{ matrix.platform }}-${{ matrix.arch }}
14+ strategy :
15+ matrix :
16+ include :
17+ - os : ubuntu-latest
18+ platform : linux
19+ arch : x64
20+ lib : libflecs.so
21+ - os : windows-latest
22+ platform : windows
23+ arch : x64
24+ lib : flecs.dll
25+ - os : macos-13
26+ platform : macos
27+ arch : x64
28+ lib : libflecs.dylib
29+ - os : macos-latest
30+ platform : macos
31+ arch : aarch64
32+ lib : libflecs.dylib
33+
34+ runs-on : ${{ matrix.os }}
1535
1636 steps :
1737 - name : Checkout code
@@ -23,28 +43,109 @@ jobs:
2343 java-version : ' 25'
2444 distribution : ' temurin'
2545
26- - name : Install GCC
46+ - name : Install GCC (Linux)
47+ if : runner.os == 'Linux'
2748 run : |
2849 sudo apt-get update
2950 sudo apt-get install -y gcc build-essential
3051
52+ - name : Install GCC (Windows)
53+ if : runner.os == 'Windows'
54+ run : choco install mingw -y
55+
56+ - name : Grant execute permission for gradlew
57+ if : runner.os != 'Windows'
58+ run : chmod +x gradlew
59+
60+ - name : Build natives
61+ run : ./gradlew copyFlecsNative -PNATIVE_ARCH=${{ matrix.platform }}-${{ matrix.arch }}
62+ shell : bash
63+
64+ - name : Verify native library was built
65+ run : |
66+ echo "Checking for native library..."
67+ ls -la build/natives/${{ matrix.platform }}-${{ matrix.arch }}/
68+ shell : bash
69+
70+ - name : Upload natives artifact
71+ uses : actions/upload-artifact@v4
72+ with :
73+ name : natives-${{ matrix.platform }}-${{ matrix.arch }}
74+ path : build/natives/${{ matrix.platform }}-${{ matrix.arch }}/${{ matrix.lib }}
75+ retention-days : 1
76+
77+ publish :
78+ name : Publish to Maven Central
79+ needs : build-natives
80+ runs-on : ubuntu-latest
81+
82+ steps :
83+ - name : Checkout code
84+ uses : actions/checkout@v4
85+
86+ - name : Set up JDK 25
87+ uses : actions/setup-java@v4
88+ with :
89+ java-version : ' 25'
90+ distribution : ' temurin'
91+
92+ - name : Download all natives
93+ uses : actions/download-artifact@v4
94+ with :
95+ path : downloaded-natives
96+
97+ - name : Debug downloaded artifacts
98+ run : |
99+ echo "Downloaded artifacts structure:"
100+ find downloaded-natives -type f
101+
102+ - name : Organize natives
103+ run : |
104+ mkdir -p build/natives
105+
106+ # Copy each artifact to the correct structure
107+ for artifact_dir in downloaded-natives/natives-*/; do
108+ # Extract platform-arch from folder name (e.g. natives-linux-x64 -> linux-x64)
109+ platform_arch=$(basename "$artifact_dir" | sed 's/^natives-//')
110+
111+ echo "Processing $platform_arch..."
112+ mkdir -p "build/natives/$platform_arch"
113+
114+ # Copy library file from artifact
115+ cp "$artifact_dir"/* "build/natives/$platform_arch/" 2>/dev/null || {
116+ echo "Warning: No files found in $artifact_dir"
117+ }
118+ done
119+
120+ echo ""
121+ echo "Final native libraries structure:"
122+ find build/natives -type f
123+
31124 - name : Grant execute permission for gradlew
32125 run : chmod +x gradlew
33126
34- - name : Build project with natives
35- run : ./gradlew build -PNATIVE_ARCH=linux-x64 -x test
127+ - name : Build final JAR with all natives
128+ run : ./gradlew jar -x compileFlecsNative -x copyFlecsNative
36129
37130 - name : Verify JAR contents
38131 run : |
39132 VERSION=${GITHUB_REF_NAME#v}
40133 echo "Verifying JAR for version $VERSION..."
41- jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/linux-x64/libflecs.so" && echo "✓ Native library found" || echo "✗ Native NOT found"
42- jar tf build/libs/flecs-java-$VERSION.jar | grep "META-INF/services/javax.annotation.processing.Processor" && echo "✓ Processor found" || echo "✗ Processor NOT found"
134+ echo ""
135+ echo "All natives in JAR:"
136+ jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/" | sort
137+ echo ""
138+
139+ # Check each platform
140+ jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/linux-x64/libflecs.so" && echo "✓ Linux x64" || echo "✗ Linux x64 MISSING"
141+ jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/windows-x64/flecs.dll" && echo "✓ Windows x64" || echo "✗ Windows x64 MISSING"
142+ jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-x64/libflecs.dylib" && echo "✓ macOS x64" || echo "✗ macOS x64 MISSING"
143+ jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-aarch64/libflecs.dylib" && echo "✓ macOS ARM64" || echo "✗ macOS ARM64 MISSING"
43144
44145 - name : Publish to Maven Central
45146 env :
46147 OSSRH_USERNAME : ${{ secrets.OSSRH_USERNAME }}
47148 OSSRH_PASSWORD : ${{ secrets.OSSRH_PASSWORD }}
48149 SIGNING_KEY : ${{ secrets.SIGNING_KEY }}
49150 SIGNING_PASSWORD : ${{ secrets.SIGNING_PASSWORD }}
50- run : ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -PNATIVE_ARCH=linux-x64
151+ run : ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
0 commit comments