Skip to content

Commit 25bc8c6

Browse files
committed
Native compilation via GitHub Actions instead of fetching binaries
1 parent 618d203 commit 25bc8c6

File tree

7 files changed

+158
-180
lines changed

7 files changed

+158
-180
lines changed

.github/workflows/build.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags: ['native-*']
7+
pull_request:
8+
branches: [master]
9+
workflow_dispatch:
10+
11+
env:
12+
LMDB: lmdb/libraries/liblmdb
13+
14+
jobs:
15+
linux:
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
# Container versions: debian:bookworm = glibc 2.36, alpine:3.21 = musl
20+
include:
21+
- { runner: ubuntu-latest, container: "debian:bookworm", artifact: x86_64-linux-gnu.so }
22+
- { runner: ubuntu-24.04-arm, container: "debian:bookworm", artifact: aarch64-linux-gnu.so }
23+
- { runner: ubuntu-latest, container: "alpine:3.21", artifact: x86_64-linux-musl.so }
24+
runs-on: ${{ matrix.runner }}
25+
container: ${{ matrix.container }}
26+
steps:
27+
- name: Install tools
28+
run: |
29+
if command -v apt-get >/dev/null; then
30+
apt-get update && apt-get install -y build-essential git
31+
else
32+
apk add --no-cache build-base git
33+
fi
34+
- uses: actions/checkout@v4
35+
with:
36+
submodules: true
37+
- name: Build and test
38+
run: make test
39+
working-directory: ${{ env.LMDB }}
40+
- name: Prepare artifact
41+
run: cp ${{ env.LMDB }}/liblmdb.so ${{ matrix.artifact }}
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: ${{ matrix.artifact }}
45+
path: ${{ matrix.artifact }}
46+
retention-days: 1
47+
48+
# ARM64 Alpine (alpine:3.21) requires QEMU because GitHub's JS actions don't run in Alpine on ARM64.
49+
# Tests are skipped because LMDB's MDB_FIXEDMAP doesn't work under QEMU emulation.
50+
linux-arm64-musl:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
submodules: true
56+
- uses: docker/setup-qemu-action@v3
57+
- name: Build
58+
run: |
59+
docker run --rm -v $PWD:/work -w /work --platform linux/arm64 alpine:3.21 sh -c '
60+
apk add --no-cache build-base
61+
make -C ${{ env.LMDB }}
62+
'
63+
- name: Prepare artifact
64+
run: cp ${{ env.LMDB }}/liblmdb.so aarch64-linux-musl.so
65+
- uses: actions/upload-artifact@v4
66+
with:
67+
name: aarch64-linux-musl.so
68+
path: aarch64-linux-musl.so
69+
retention-days: 1
70+
71+
macos:
72+
strategy:
73+
fail-fast: true
74+
matrix:
75+
include:
76+
- { runner: macos-15-intel, artifact: x86_64-macos-none.so } # Intel available until Aug 2027
77+
- { runner: macos-latest, artifact: aarch64-macos-none.so }
78+
runs-on: ${{ matrix.runner }}
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
submodules: true
83+
- name: Build and test
84+
run: make test
85+
working-directory: ${{ env.LMDB }}
86+
- name: Prepare artifact
87+
run: cp ${{ env.LMDB }}/liblmdb.so ${{ matrix.artifact }}
88+
- uses: actions/upload-artifact@v4
89+
with:
90+
name: ${{ matrix.artifact }}
91+
path: ${{ matrix.artifact }}
92+
retention-days: 1
93+
94+
windows:
95+
runs-on: windows-latest
96+
steps:
97+
- uses: actions/checkout@v4
98+
with:
99+
submodules: true
100+
- uses: msys2/setup-msys2@v2
101+
with:
102+
msystem: MINGW64
103+
install: mingw-w64-x86_64-gcc make
104+
- name: Build and test
105+
shell: msys2 {0}
106+
run: make SOEXT=.dll test
107+
working-directory: ${{ env.LMDB }}
108+
- name: Prepare artifact
109+
run: cp ${{ env.LMDB }}/liblmdb.dll x86_64-windows-gnu.dll
110+
- uses: actions/upload-artifact@v4
111+
with:
112+
name: x86_64-windows-gnu.dll
113+
path: x86_64-windows-gnu.dll
114+
retention-days: 1
115+
116+
package:
117+
needs: [linux, linux-arm64-musl, macos, windows]
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@v4
121+
- uses: actions/download-artifact@v4
122+
with:
123+
path: target/classes/org/lmdbjava/native
124+
merge-multiple: true
125+
- run: ls -la target/classes/org/lmdbjava/native
126+
- uses: actions/setup-java@v4
127+
with:
128+
distribution: zulu
129+
java-version: 21
130+
server-id: central
131+
server-username: MAVEN_CENTRAL_USERNAME
132+
server-password: MAVEN_CENTRAL_PASSWORD
133+
gpg-private-key: ${{ secrets.gpg_private_key }}
134+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
135+
- run: mvn -B package
136+
- uses: actions/upload-artifact@v4
137+
with:
138+
name: native.jar
139+
path: target/*.jar
140+
- name: Deploy
141+
if: startsWith(github.ref, 'refs/tags/')
142+
run: mvn -B -Pcentral-deploy deploy -DskipTests
143+
env:
144+
MAVEN_GPG_PASSPHRASE: ${{ secrets.gpg_passphrase }}
145+
MAVEN_CENTRAL_USERNAME: ${{ secrets.central_username }}
146+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.central_password }}

.github/workflows/maven.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lmdb"]
2+
path = lmdb
3+
url = https://git.openldap.org/openldap/openldap.git

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
[![Maven Build and Deployment](https://github.com/lmdbjava/native/workflows/Maven%20Build%20and%20Deployment/badge.svg)](https://github.com/lmdbjava/native/actions)
1+
[![Build](https://github.com/lmdbjava/native/workflows/Build/badge.svg)](https://github.com/lmdbjava/native/actions)
22
[![Maven Central](https://img.shields.io/maven-central/v/org.lmdbjava/native.svg?maxAge=3600)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.lmdbjava%22%20AND%20a%3A%22native%22)
33
[![License](https://img.shields.io/badge/license-OpenLDAP-blue.svg?maxAge=2592000)](http://www.openldap.org/software/release/license.html)
44

55
# LMDB Native Libraries
66

7-
Provides pre-compiled LMDB native libraries for Linux, macOS and Windows. These libraries are fetched from distribution package managers (Alpine Linux, Fedora, Homebrew, MSYS2) and packaged into a single JAR for easy dependency resolution.
7+
Compiled LMDB native libraries for Linux (glibc/musl), macOS and Windows on x86_64 and aarch64.
88

99
**If you are using LMDB from Java, use the [LmdbJava](https://github.com/lmdbjava/lmdbjava) project instead.** This artifact is a dependency of LmdbJava.
1010

11-
Available from [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.lmdbjava%22%20AND%20a%3A%22native%22) and [Central Portal Snapshots](https://central.sonatype.com/repository/maven-snapshots/org/lmdbjava/native).
11+
### Updating LMDB
1212

13-
### Version Management
14-
15-
Update all dependency and plugin versions:
1613
```bash
17-
mvn versions:update-properties
14+
cd lmdb
15+
git fetch --tags
16+
git checkout LMDB_0.9.XX
17+
cd ..
18+
git add lmdb
1819
```
1920

20-
Update the LMDB version by editing `LMDB_VERSION` in `fetch-native-libs.sh`.
21-
22-
### Releasing
23-
24-
GitHub Actions will perform an official release whenever a developer executes `mvn release:clean release:prepare`.
25-
2621
### License
2722

2823
LMDB (and this repository for simplicity) is licensed under [The OpenLDAP Public License](http://www.openldap.org/software/release/license.html).

fetch-native-libs.sh

Lines changed: 0 additions & 84 deletions
This file was deleted.

lmdb

Submodule lmdb added at 3a29a24

pom.xml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<properties>
1111
<buildnumber-maven-plugin.version>3.2.1</buildnumber-maven-plugin.version>
1212
<central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
13-
<exec-maven-plugin.version>3.6.2</exec-maven-plugin.version>
1413
<maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
1514
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
1615
<maven-release-plugin.version>3.1.1</maven-release-plugin.version>
@@ -109,27 +108,6 @@
109108
</execution>
110109
</executions>
111110
</plugin>
112-
<plugin>
113-
<groupId>org.codehaus.mojo</groupId>
114-
<artifactId>exec-maven-plugin</artifactId>
115-
<version>${exec-maven-plugin.version}</version>
116-
<executions>
117-
<execution>
118-
<id>fetch-native-libraries</id>
119-
<goals>
120-
<goal>exec</goal>
121-
</goals>
122-
<phase>generate-resources</phase>
123-
<configuration>
124-
<executable>${project.basedir}/fetch-native-libs.sh</executable>
125-
<workingDirectory>${project.basedir}</workingDirectory>
126-
<environmentVariables>
127-
<DEST>target/classes/org/lmdbjava/native</DEST>
128-
</environmentVariables>
129-
</configuration>
130-
</execution>
131-
</executions>
132-
</plugin>
133111
<plugin>
134112
<groupId>org.codehaus.mojo</groupId>
135113
<artifactId>versions-maven-plugin</artifactId>

0 commit comments

Comments
 (0)