forked from CurvineIO/curvine
-
Notifications
You must be signed in to change notification settings - Fork 0
356 lines (305 loc) · 11.9 KB
/
Copy pathbuild-java-sdk.yml
File metadata and controls
356 lines (305 loc) · 11.9 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
name: Build Java SDK
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 0.1.0), defaults to 0.1.0 if empty'
required: false
type: string
permissions:
contents: write
packages: write
env:
CARGO_TERM_COLOR: always
jobs:
# Build native libraries for each OS and architecture
# NOTE: alinux3 uses amzn2 compiled .so for glibc compatibility
# Rocky 9 requires glibc 2.33/2.34, but StarRocks alinux3 image only has glibc 2.32
# Amazon Linux 2 (glibc 2.26) is forward compatible with glibc 2.32
build-native:
strategy:
fail-fast: false
matrix:
include:
# Rocky Linux 9 - x86_64
- os: rocky9
arch: x86
runner: ubuntu-latest
image: ghcr.io/curvineio/curvine-compile:rocky9
also_alinux3: false
# Rocky Linux 9 - aarch64
- os: rocky9
arch: aarch
runner: ubuntu-24.04-arm
image: ghcr.io/curvineio/curvine-compile:rocky9
also_alinux3: false
# Ubuntu 22.04 - x86_64
- os: ubuntu22
arch: x86
runner: ubuntu-latest
image: ghcr.io/curvineio/curvine-compile:ubuntu22.04
also_alinux3: false
# Ubuntu 22.04 - aarch64
- os: ubuntu22
arch: aarch
runner: ubuntu-24.04-arm
image: ghcr.io/curvineio/curvine-compile:ubuntu22.04
also_alinux3: false
# Ubuntu 24.04 - x86_64
- os: ubuntu24
arch: x86
runner: ubuntu-latest
image: ghcr.io/curvineio/curvine-compile:ubuntu24.04
also_alinux3: false
# Ubuntu 24.04 - aarch64
- os: ubuntu24
arch: aarch
runner: ubuntu-24.04-arm
image: ghcr.io/curvineio/curvine-compile:ubuntu24.04
also_alinux3: false
# Amazon Linux 2 - x86_64 (also creates alinux3 for glibc 2.32 compatibility)
- os: amzn2
arch: x86
runner: ubuntu-latest
image: ghcr.io/curvineio/curvine-compile:amzn2
also_alinux3: true
# Amazon Linux 2 - aarch64 (also creates alinux3 for glibc 2.32 compatibility)
- os: amzn2
arch: aarch
runner: ubuntu-24.04-arm
image: ghcr.io/curvineio/curvine-compile:amzn2
also_alinux3: true
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.image }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust toolchain
run: |
export PATH="/root/.cargo/bin:$PATH"
unset RUSTUP_UPDATE_ROOT
unset RUSTUP_DIST_SERVER
rustup default stable
rustc --version
cargo --version
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "curvine-java-sdk-${{ matrix.os }}-${{ matrix.arch }}"
cache-all-crates: false
cache-targets: false
- name: Build native library
run: |
echo "Building native library for ${{ matrix.os }} ${{ matrix.arch }}_64"
cargo build --release -p curvine-libsdk --jobs 2
# Create output directory
mkdir -p native-output
# Copy the built library with proper naming
cp target/release/libcurvine_libsdk.so \
native-output/libcurvine_libsdk_${{ matrix.os }}_${{ matrix.arch }}_64.so
# Also copy for alinux3 if amzn2 (glibc 2.26 forward compatible with glibc 2.32)
# NOTE: Rocky 9 requires glibc 2.33/2.34, but StarRocks alinux3 image only has glibc 2.32
# Amazon Linux 2 (glibc 2.26) is the best choice for alinux3 compatibility
if [ "${{ matrix.also_alinux3 }}" = "true" ]; then
echo "Creating alinux3 compatible .so from amzn2 build (glibc 2.26 -> 2.32)"
cp target/release/libcurvine_libsdk.so \
native-output/libcurvine_libsdk_alinux3_${{ matrix.arch }}_64.so
fi
ls -la native-output/
- name: Upload native library artifact
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.os }}-${{ matrix.arch }}
path: native-output/*.so
retention-days: 7
# Package all native libraries into JAR
package-jar:
needs: build-native
runs-on: ubuntu-latest
container:
image: ghcr.io/curvineio/curvine-compile:rocky9
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all native library artifacts
uses: actions/download-artifact@v4
with:
path: native-artifacts
pattern: native-*
merge-multiple: true
- name: Prepare native libraries
run: |
echo "Downloaded native libraries:"
ls -la native-artifacts/
# Copy all .so files to java native directory
mkdir -p curvine-libsdk/java/native
cp native-artifacts/*.so curvine-libsdk/java/native/
echo "Native libraries in java/native:"
ls -la curvine-libsdk/java/native/
- name: Set version
id: version
run: |
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
else
VERSION="${{ inputs.version || '0.1.0' }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Build JAR with Maven
run: |
cd curvine-libsdk/java
# Update version in pom.xml if needed
VERSION="${{ steps.version.outputs.version }}"
sed -i "s/<version>0.1.0<\/version>/<version>${VERSION}<\/version>/" pom.xml
# Generate protobuf code and package
mvn protobuf:compile package -DskipTests -B
echo "Built JAR files:"
ls -la target/*.jar
- name: Upload JAR artifacts
uses: actions/upload-artifact@v4
with:
name: curvine-hadoop-jars
path: |
curvine-libsdk/java/target/curvine-hadoop-*.jar
retention-days: 30
outputs:
version: ${{ steps.version.outputs.version }}
# Publish to GitHub Release and GitHub Packages
publish:
needs: package-jar
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download JAR artifacts
uses: actions/download-artifact@v4
with:
name: curvine-hadoop-jars
path: jars
- name: List JAR files
run: |
echo "JAR files to publish:"
ls -la jars/
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: jars/*.jar
generate_release_notes: false
append_body: true
body: |
## Java SDK
### JAR Downloads
- **curvine-hadoop-${{ needs.package-jar.outputs.version }}.jar** - Base JAR
- **curvine-hadoop-${{ needs.package-jar.outputs.version }}-client.jar** - Client JAR (with shaded protobuf, recommended for big data environments)
- **curvine-hadoop-${{ needs.package-jar.outputs.version }}-shade.jar** - Fully shaded JAR
### Supported Platforms
| OS | x86_64 | aarch64 |
|----|--------|---------|
| Rocky Linux 9 | ✅ | ✅ |
| Alibaba Cloud Linux 3 | ✅ | ✅ |
| Ubuntu 22.04 | ✅ | ✅ |
| Ubuntu 24.04 | ✅ | ✅ |
| Amazon Linux 2 | ✅ | ✅ |
### Usage
```xml
<dependency>
<groupId>io.curvine</groupId>
<artifactId>curvine-hadoop</artifactId>
<version>${{ needs.package-jar.outputs.version }}</version>
<classifier>client</classifier>
</dependency>
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK for Maven
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Publish to GitHub Packages
run: |
cd curvine-libsdk/java
# Download all native libraries again for the publish
mkdir -p native
# We need to rebuild with the native libs for publishing
# First download the artifacts
echo "Downloading native artifacts for publishing..."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download native artifacts for publish
uses: actions/download-artifact@v4
with:
path: native-artifacts
pattern: native-*
merge-multiple: true
- name: Publish JAR to GitHub Packages
run: |
# Copy native libraries
mkdir -p curvine-libsdk/java/native
cp native-artifacts/*.so curvine-libsdk/java/native/
cd curvine-libsdk/java
# Update version
VERSION="${{ needs.package-jar.outputs.version }}"
sed -i "s/<version>0.1.0<\/version>/<version>${VERSION}<\/version>/" pom.xml
# Add distribution management for GitHub Packages
sed -i '/<\/project>/i \
<distributionManagement>\
<repository>\
<id>github</id>\
<name>GitHub CurvineIO Apache Maven Packages</name>\
<url>https://maven.pkg.github.com/CurvineIO/curvine</url>\
</repository>\
</distributionManagement>' pom.xml
# Create settings.xml for GitHub Packages authentication
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << EOF
<settings>
<servers>
<server>
<id>github</id>
<username>\${env.GITHUB_ACTOR}</username>
<password>\${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
EOF
# Build and deploy
mvn protobuf:compile deploy -DskipTests -B
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
# Build summary
summary:
needs: [build-native, package-jar, publish]
runs-on: ubuntu-latest
if: always()
steps:
- name: Build summary
run: |
echo "### Java SDK Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ needs.package-jar.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Native Libraries Built:**" >> $GITHUB_STEP_SUMMARY
echo "| OS | x86_64 | aarch64 |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|---------|" >> $GITHUB_STEP_SUMMARY
echo "| Rocky Linux 9 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Alibaba Cloud Linux 3 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Ubuntu 22.04 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Ubuntu 24.04 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Amazon Linux 2 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "**Published to:**" >> $GITHUB_STEP_SUMMARY
echo "- GitHub Release" >> $GITHUB_STEP_SUMMARY
echo "- GitHub Packages (Maven)" >> $GITHUB_STEP_SUMMARY
else
echo "**Note:** Manual trigger - artifacts uploaded but not published to release" >> $GITHUB_STEP_SUMMARY
fi