Skip to content

Commit 8fa8d5e

Browse files
committed
nit
1 parent ae792e1 commit 8fa8d5e

File tree

3 files changed

+189
-10
lines changed

3 files changed

+189
-10
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Build Java Native Libraries
2+
3+
on:
4+
# Manually trigger the workflow
5+
workflow_dispatch:
6+
# Trigger on PRs affecting Java bindings
7+
pull_request:
8+
paths:
9+
- 'bindings/java/**'
10+
- '.github/workflows/java-build-natives.yml'
11+
# Trigger on push to main
12+
push:
13+
branches:
14+
- main
15+
paths:
16+
- 'bindings/java/**'
17+
- '.github/workflows/java-build-natives.yml'
18+
# Allow this workflow to be called by other workflows
19+
workflow_call:
20+
21+
env:
22+
working-directory: bindings/java
23+
24+
jobs:
25+
build-natives:
26+
strategy:
27+
matrix:
28+
include:
29+
- os: ubuntu-latest
30+
target: x86_64-unknown-linux-gnu
31+
make-target: linux_x86
32+
artifact-name: linux-x86_64
33+
- os: macos-latest
34+
target: x86_64-apple-darwin
35+
make-target: macos_x86
36+
artifact-name: macos-x86_64
37+
- os: macos-latest
38+
target: aarch64-apple-darwin
39+
make-target: macos_arm64
40+
artifact-name: macos-arm64
41+
- os: ubuntu-latest
42+
target: x86_64-pc-windows-gnu
43+
make-target: windows
44+
artifact-name: windows-x86_64
45+
46+
runs-on: ${{ matrix.os }}
47+
timeout-minutes: 30
48+
49+
defaults:
50+
run:
51+
working-directory: ${{ env.working-directory }}
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Install Rust
58+
uses: dtolnay/rust-toolchain@stable
59+
with:
60+
targets: ${{ matrix.target }}
61+
62+
- name: Install cross-compilation tools (Windows on Linux)
63+
if: matrix.target == 'x86_64-pc-windows-gnu'
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y mingw-w64
67+
68+
- name: Build native library
69+
run: make ${{ matrix.make-target }}
70+
71+
- name: Verify build output
72+
run: |
73+
echo "Build completed for ${{ matrix.target }}"
74+
ls -lah libs/
75+
find libs/ -type f
76+
77+
- name: Upload native library
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: native-${{ matrix.artifact-name }}
81+
path: ${{ env.working-directory }}/libs/
82+
retention-days: 7
83+
84+
# Test job to verify all natives were built
85+
verify-natives:
86+
needs: build-natives
87+
runs-on: ubuntu-latest
88+
timeout-minutes: 10
89+
90+
defaults:
91+
run:
92+
working-directory: ${{ env.working-directory }}
93+
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
98+
- name: Download all native libraries
99+
uses: actions/download-artifact@v4
100+
with:
101+
pattern: native-*
102+
path: ${{ env.working-directory }}/libs-collected
103+
merge-multiple: true
104+
105+
- name: Verify all platforms built
106+
run: |
107+
echo "Collected native libraries:"
108+
ls -R libs-collected/
109+
110+
# Check that all expected files exist
111+
expected_files=(
112+
"libs-collected/macos_x86/lib_turso_java.dylib"
113+
"libs-collected/macos_arm64/lib_turso_java.dylib"
114+
"libs-collected/windows/lib_turso_java.dll"
115+
"libs-collected/linux_x86/lib_turso_java.so"
116+
)
117+
118+
all_found=true
119+
for file in "${expected_files[@]}"; do
120+
if [ -f "$file" ]; then
121+
echo "✓ Found: $file"
122+
else
123+
echo "✗ Missing: $file"
124+
all_found=false
125+
fi
126+
done
127+
128+
if [ "$all_found" = false ]; then
129+
echo "ERROR: Not all native libraries were built"
130+
exit 1
131+
fi
132+
133+
echo "✓ All native libraries built successfully!"

.github/workflows/java-publish.yml

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ on:
77
release-version:
88
description: 'Release version (e.g., 0.0.1)'
99
required: false
10-
# Trigger on release tags
11-
push:
12-
tags:
13-
- 'java-v*'
1410

1511
env:
1612
working-directory: bindings/java
1713

1814
jobs:
15+
# Publish to Maven Central (assumes native libraries already exist in libs/)
1916
publish:
2017
runs-on: ubuntu-latest
2118
timeout-minutes: 30
@@ -28,9 +25,6 @@ jobs:
2825
- name: Checkout code
2926
uses: actions/checkout@v4
3027

31-
- name: Install Rust (stable)
32-
uses: dtolnay/rust-toolchain@stable
33-
3428
- name: Set up JDK
3529
uses: actions/setup-java@v4
3630
with:
@@ -40,17 +34,68 @@ jobs:
4034
- name: Setup Gradle
4135
uses: gradle/actions/setup-gradle@v3
4236

43-
- name: Build native libraries
44-
run: make build
37+
- name: Install Rust (for test builds)
38+
uses: dtolnay/rust-toolchain@stable
39+
40+
- name: Verify native libraries exist
41+
run: |
42+
echo "Checking for native libraries in libs/ directory..."
43+
if [ ! -d "libs" ]; then
44+
echo "ERROR: libs/ directory not found"
45+
echo "Please ensure native libraries are committed or built before publishing"
46+
exit 1
47+
fi
48+
echo "Native libraries found:"
49+
ls -R libs/
50+
51+
- name: Build test natives
52+
run: make build_test
4553

4654
- name: Run tests
4755
run: ./gradlew test
4856

57+
- name: Build and sign artifacts
58+
env:
59+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
60+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
61+
run: |
62+
./gradlew clean build --no-daemon --stacktrace
63+
64+
- name: Verify build artifacts
65+
run: |
66+
echo "Build artifacts:"
67+
ls -lah build/libs/
68+
echo ""
69+
echo "Checking for required files..."
70+
required_files=(
71+
"build/libs/turso-*.jar"
72+
"build/libs/turso-*-sources.jar"
73+
"build/libs/turso-*-javadoc.jar"
74+
"build/libs/turso-*.jar.asc"
75+
)
76+
for pattern in "${required_files[@]}"; do
77+
if ls $pattern 1> /dev/null 2>&1; then
78+
echo "✓ Found: $pattern"
79+
else
80+
echo "✗ Missing: $pattern"
81+
exit 1
82+
fi
83+
done
84+
4985
- name: Publish to Maven Central
5086
env:
5187
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
5288
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
5389
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
5490
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
5591
run: |
56-
./gradlew publishToMavenCentral --no-daemon --stacktrace
92+
echo "Publishing to Maven Central..."
93+
./gradlew publishToMavenCentral --no-daemon --stacktrace
94+
95+
- name: Upload bundle artifact
96+
if: always()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: maven-central-bundle
100+
path: ${{ env.working-directory }}/build/maven-central/*.zip
101+
retention-days: 7

bindings/java/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ bin/
4141

4242
### turso builds ###
4343
libs
44+
temp

0 commit comments

Comments
 (0)