|
| 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 }} |
0 commit comments