-
Notifications
You must be signed in to change notification settings - Fork 2
170 lines (138 loc) · 5.39 KB
/
Copy pathbuild-and-publish.yml
File metadata and controls
170 lines (138 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Build and Publish
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
build-natives:
name: Build natives for ${{ matrix.platform }}-${{ matrix.arch }}
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
lib: libflecs.so
- os: windows-latest
platform: windows
arch: x64
lib: flecs.dll
- os: macos-15
platform: macos
arch: x64
lib: libflecs.dylib
- os: macos-latest
platform: macos
arch: aarch64
lib: libflecs.dylib
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
- name: Install GCC (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc build-essential
- name: Install GCC (Windows)
if: runner.os == 'Windows'
run: choco install mingw -y
- name: Grant execute permission for gradlew
if: runner.os != 'Windows'
run: chmod +x gradlew
- name: Build natives
run: ./gradlew copyFlecsNative -PNATIVE_ARCH=${{ matrix.platform }}-${{ matrix.arch }}
shell: bash
- name: Verify native library was built
run: |
FILE_PATH="build/natives/${{ matrix.platform }}-${{ matrix.arch }}/${{ matrix.lib }}"
echo "Checking for native library at $FILE_PATH..."
if [ ! -f "$FILE_PATH" ]; then
echo "Error: Native library not found!"
exit 1
fi
# Vérification de la taille (102400 octets = 100ko)
FILE_SIZE=$(wc -c < "$FILE_PATH")
MIN_SIZE=102400
echo "File size: $FILE_SIZE bytes"
if [ "$FILE_SIZE" -lt "$MIN_SIZE" ]; then
echo "Error: File size is too small ($FILE_SIZE bytes). Expected at least $MIN_SIZE bytes."
exit 1
fi
echo "✓ File exists and size is valid."
ls -la "$FILE_PATH"
shell: bash
- name: Upload natives artifact
uses: actions/upload-artifact@v4
with:
name: natives-${{ matrix.platform }}-${{ matrix.arch }}
path: build/natives/${{ matrix.platform }}-${{ matrix.arch }}/${{ matrix.lib }}
retention-days: 1
publish:
name: Publish to Maven Central
needs: build-natives
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
- name: Download all natives
uses: actions/download-artifact@v4
with:
path: downloaded-natives
- name: Debug downloaded artifacts
run: |
echo "Downloaded artifacts structure:"
find downloaded-natives -type f
- name: Organize natives
run: |
mkdir -p build/natives
# Copy each artifact to the correct structure
for artifact_dir in downloaded-natives/natives-*/; do
# Extract platform-arch from folder name (e.g. natives-linux-x64 -> linux-x64)
platform_arch=$(basename "$artifact_dir" | sed 's/^natives-//')
echo "Processing $platform_arch..."
mkdir -p "build/natives/$platform_arch"
# Copy library file from artifact
cp "$artifact_dir"/* "build/natives/$platform_arch/" 2>/dev/null || {
echo "Warning: No files found in $artifact_dir"
}
done
echo ""
echo "Final native libraries structure:"
find build/natives -type f
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build final JAR with all natives
run: ./gradlew jar -x compileFlecsNative -x copyFlecsNative
- name: Verify JAR contents
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "Verifying JAR for version $VERSION..."
echo ""
echo "All natives in JAR:"
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/" | sort
echo ""
# Check each platform
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/linux-x64/libflecs.so" && echo "✓ Linux x64" || echo "✗ Linux x64 MISSING"
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/windows-x64/flecs.dll" && echo "✓ Windows x64" || echo "✗ Windows x64 MISSING"
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-x64/libflecs.dylib" && echo "✓ macOS x64" || echo "✗ macOS x64 MISSING"
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-aarch64/libflecs.dylib" && echo "✓ macOS ARM64" || echo "✗ macOS ARM64 MISSING"
- name: Publish to Maven Central
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository