hakodb 0.23.2

Embedded & Cloud-native Document Engine
Documentation
name: release

# Core library releases only. Satellites (cli, cloudserver, SDKs, bench,
# tauri) version independently and carry no workflows; FFI consumers pin
# these assets by tag: hakodb-<version>-<target>.<ext> + headers.
#
# Linux is a per-distro-family MATRIX, not one ubuntu build: our server is
# only ONE consumer — the public runs ubuntu/arch/EL/Alpine. glibc is
# backward-compatible (an EL8 build runs on newer distros) but never
# forward: an ubuntu-24.04 .so refuses to load on EL8 (proven at deploy:
# GLIBC_2.30..2.38 missing). So each family gets a native-container build
# plus a static musl fallback that runs anywhere (incl. Alpine).
on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  VERSION: ${{ github.ref_name }}

jobs:
  windows-msvc:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Build cdylib (MSVC import lib is a release artifact)
        run: cargo build --release --features header
      - name: Collect assets
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Force dist | Out-Null
          Copy-Item target/release/hakodb.dll dist/
          Copy-Item target/release/hakodb.dll.lib dist/hakodb.lib
          # Per-target header: generated by THIS build (build.rs copies the
          # cbindgen output next to the binaries). No checked-in header
          # exists since 0.9.1 — one file pretending to serve all targets
          # caused the stale socket-API incident.
          Copy-Item target/release/hakodb.h dist/
          (Get-FileHash dist/hakodb.dll -Algorithm SHA256).Hash | Out-File dist/SHA256SUMS
          (Get-FileHash dist/hakodb.lib -Algorithm SHA256).Hash | Out-File dist/SHA256SUMS -Append
      - uses: actions/upload-artifact@v4
        with:
          name: hakodb-${{ github.ref_name }}-x86_64-pc-windows-msvc
          path: dist/

  # Public Linux matrix: one native-container build per distro family
  # (glibc floor pinned by the container) + one static musl fallback.
  # Containers run as root; every image gets git + a C/C++ toolchain
  # (ring/aws-lc-sys compile C/C++ at build time: cmake + perl + g++).
  linux:
    strategy:
      fail-fast: false
      matrix:
        include:
          # EL/Rocky/Alma 8-9 class: glibc 2.28 floor — runs on EL8 AND all
          # newer glibc distros (backward-compatible). Also what our own
          # server fleet consumes.
          - image: almalinux:8
            suffix: linux-glibc2.28-el8
            setup: yum install -y git gcc gcc-c++ cmake perl make curl tar gzip ca-certificates
          - image: ubuntu:22.04
            suffix: linux-glibc2.35-ubuntu22
            setup: apt-get update && apt-get install -y git gcc g++ cmake perl make curl tar gzip ca-certificates
          - image: ubuntu:24.04
            suffix: linux-glibc2.39-ubuntu24
            setup: apt-get update && apt-get install -y git gcc g++ cmake perl make curl tar gzip ca-certificates
          # Rolling: no glibc promise (rebuild often); provided for Arch users
          # who want a same-week toolchain build.
          - image: archlinux:latest
            suffix: linux-arch
            setup: pacman -Sy --noconfirm base-devel cmake perl curl tar gzip ca-certificates
    runs-on: ubuntu-latest
    container:
      image: ${{ matrix.image }}
    # Containers run as root but the runner injects HOME=/github/home;
    # rustup >= 1.28 refuses that mismatch ("$HOME differs from
    # euid-obtained home directory"). Pin HOME so rustup installs to
    # /root/.cargo and the rustup shims resolve the same toolchain in
    # every step.
    env:
      HOME: /root
    steps:
      - uses: actions/checkout@v4
      - name: Setup container toolchain
        run: ${{ matrix.setup }}
      - uses: dtolnay/rust-toolchain@stable
      - name: Build cdylib + rlib
        run: cargo build --release --features header
      - name: Collect assets
        run: |
          mkdir -p dist
          cp target/release/libhakodb.so target/release/libhakodb.rlib target/release/hakodb.h dist/
          (cd dist && sha256sum * > SHA256SUMS)
      - uses: actions/upload-artifact@v4
        with:
          name: hakodb-${{ github.ref_name }}-x86_64-unknown-${{ matrix.suffix }}
          path: dist/

  linux-musl:
    # Static fallback: runs on ANY Linux incl. musl distros (Alpine) and
    # ancient glibc. Embedded core only (--no-default-features): the sync
    # features pull rustls/ring/aws-lc-sys, whose C++ build has no musl
    # toolchain in stock CI images (musl-tools ships C only). The suffix
    # says so explicitly — no surprise for consumers. If a full-featured
    # static build is ever needed, the road is cargo-zigbuild (zig ships
    # musl libc++), not stock musl-gcc.
    #
    # rlib ONLY: rustc drops `cdylib` for musl targets ("unsupported crate
    # type") — there is no .so here by construction, not by accident. Rust
    # consumers link the rlib statically; C consumers take a glibc .so.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-unknown-linux-musl
      - name: Setup musl toolchain
        run: sudo apt-get update && sudo apt-get install -y musl-tools
      - name: Build rlib (static, embedded core)
        run: cargo build --release --no-default-features --features header --target x86_64-unknown-linux-musl
        env:
          CC_x86_64_unknown_linux_musl: musl-gcc
          CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: musl-gcc
      - name: Collect assets
        run: |
          mkdir -p dist
          cp target/x86_64-unknown-linux-musl/release/libhakodb.rlib target/x86_64-unknown-linux-musl/release/hakodb.h dist/
          (cd dist && sha256sum * > SHA256SUMS)
      - uses: actions/upload-artifact@v4
        with:
          name: hakodb-${{ github.ref_name }}-x86_64-unknown-linux-musl-core
          path: dist/

  android:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-linux-android
      - uses: nttld/setup-ndk@v1
        id: setup-ndk
        with:
          ndk-version: r26c
      - name: Build cdylib for aarch64-linux-android (API 21)
        run: |
          NDK="${{ steps.setup-ndk.outputs.ndk-path }}"
          BIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
          CLANG="$BIN/aarch64-linux-android21-clang"
          export CC_aarch64_linux_android="$CLANG"
          export CXX_aarch64_linux_android="${CLANG}++"
          export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$CLANG"
          # cc-rs (ring, aws-lc-sys) looks for the archiver under the
          # target-prefixed name; the NDK only ships it as llvm-ar.
          export AR_aarch64_linux_android="$BIN/llvm-ar"
          cargo build --release --features header --target aarch64-linux-android
      - name: Collect assets
        run: |
          mkdir -p dist
          cp target/aarch64-linux-android/release/libhakodb.so target/aarch64-linux-android/release/hakodb.h dist/
          (cd dist && sha256sum * > SHA256SUMS)
      - uses: actions/upload-artifact@v4
        with:
          name: hakodb-${{ github.ref_name }}-aarch64-linux-android
          path: dist/

  publish:
    needs: [windows-msvc, linux, linux-musl, android]
    runs-on: ubuntu-latest
    steps:
      # Full history: the notes below diff this tag against the previous
      # one, and a shallow clone has no tags to diff against.
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/download-artifact@v4
        with:
          name: hakodb-${{ github.ref_name }}-x86_64-pc-windows-msvc
          path: assets/windows
      - uses: actions/download-artifact@v4
        with:
          name: hakodb-${{ github.ref_name }}-aarch64-linux-android
          path: assets/android
      # All linux-matrix artifacts land in their own subdirectory each.
      - uses: actions/download-artifact@v4
        with:
          pattern: hakodb-${{ github.ref_name }}-x86_64-unknown-linux-*
          path: assets/linux-matrix
      # Flat staging with target-qualified names: deterministic download
      # URLs regardless of how the uploader preserves directories.
      # Consumers rename to canonical names on download (see each
      # satellite's sync-core/sync-native script). Per-target bundles
      # (.zip for Windows, .tar.gz elsewhere) carry the same payload for
      # one-click installs; individual files stay for script consumers.
      - name: Stage flat release files and bundles
        run: |
          mkdir -p release pkg/win pkg/android
          cp assets/windows/hakodb.dll release/hakodb-x86_64-pc-windows-msvc.dll
          cp assets/windows/hakodb.lib release/hakodb-x86_64-pc-windows-msvc.lib
          cp assets/android/libhakodb.so release/libhakodb-aarch64-linux-android.so
          # Flat header = el8 linux-generated superset (unix decls included).
          # Windows-only consumers ignore decls they never call; per-target
          # bundles below carry exact-match headers for their own build.
          cp "assets/linux-matrix/hakodb-${{ github.ref_name }}-x86_64-unknown-linux-glibc2.28-el8/hakodb.h" release/hakodb.h
          cp assets/windows/hakodb.dll assets/windows/hakodb.lib assets/windows/hakodb.h pkg/win/
          cp assets/android/libhakodb.so assets/android/hakodb.h pkg/android/
          (cd pkg/win && sha256sum * > SHA256SUMS)
          (cd pkg/android && sha256sum * > SHA256SUMS)
          (cd pkg/win && zip -q ../hakodb-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip *)
          (cd pkg/android && tar -czf ../hakodb-${{ github.ref_name }}-aarch64-linux-android.tar.gz *)
          mv pkg/*.zip pkg/*.tar.gz release/
          # Linux matrix: one qualified set per distro family. The .so is
          # optional per family (musl ships rlib-only: rustc drops cdylib
          # for musl targets) — hence the existence guard, not || true.
          for d in assets/linux-matrix/*/; do
            tag=$(basename "$d" | sed "s/^hakodb-${{ github.ref_name }}-//")
            cp "$d/libhakodb.rlib" "release/libhakodb-$tag.rlib"
            mkdir -p "pkg/$tag"
            cp "$d/libhakodb.rlib" "$d/hakodb.h" "pkg/$tag/"
            if [ -f "$d/libhakodb.so" ]; then
              cp "$d/libhakodb.so" "release/libhakodb-$tag.so"
              cp "$d/libhakodb.so" "pkg/$tag/"
            fi
            (cd "pkg/$tag" && sha256sum * > SHA256SUMS)
            (cd pkg && tar -czf "../release/hakodb-${{ github.ref_name }}-$tag.tar.gz" "$tag")
          done
          (cd release && sha256sum * > SHA256SUMS)
      - name: Derive release notes
        run: |
          PREV=$(git tag --sort=-creatordate --merged HEAD | sed -n 2p)
          {
            if [ -n "$PREV" ]; then
              echo "## Changes since $PREV"
              git log --no-merges --pretty=format:"- %s (%h)" "$PREV..HEAD"
            else
              echo "## Initial tagged release"
              git log --no-merges --pretty=format:"- %s (%h)" | head -30
            fi
          } > body.md
      - uses: softprops/action-gh-release@v2
        with:
          files: release/*
          body_path: body.md
          generate_release_notes: true

  # crates.io is independent of the binary artifacts: publish as soon as the
  # tag lands, in parallel with the build matrix. A failure here must not
  # block the GitHub release (and vice versa), hence no `needs`.
  publish-crate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io
        run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}