name: Release MariaDB on: workflow_dispatch: inputs: version: description: 'MariaDB version' required: true type: choice options: - 13.0.2 - 12.3.3 - 11.8.9 - 11.8.8 - 11.8.6 - 11.8.5 - 11.4.13 - 11.4.10 - 11.4.5 - 10.11.19 - 10.11.16 - 10.11.15 default: 13.0.2 platforms: description: 'Platforms to build' required: true default: 'all' type: choice options: - 'all' - 'linux-x64' - 'linux-arm64' - 'darwin-x64' - 'darwin-arm64' - 'win32-x64' dry_run: description: 'Build and check only: no GitHub release, no R2 upload, no releases.json change' required: false default: false type: boolean # Every publishing job (release, upload-to-r2, update-releases) carries # `if: ${{ !inputs.dry_run }}`, so a dry run stops after the build and its # checks. The negation fails closed: anything but a real boolean false skips # publishing. tests/workflow-job-gates.test.ts pins these gates. # Prevent concurrent runs that could conflict when updating releases.json concurrency: group: release-mariadb-${{ github.event.inputs.version }} cancel-in-progress: false jobs: # Validate version against databases.json validate: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 - name: Validate version against databases.json run: | VERSION="${{ github.event.inputs.version }}" DB="mariadb" echo "Validating MariaDB version: $VERSION" # A version is enabled if its value is `true` or an object without `"enabled": false` ENABLED=$(jq -r " .databases.$DB.versions[\"$VERSION\"] // null | if . == null or . == false then \"false\" elif type == \"object\" and .enabled == false then \"false\" else \"true\" end " databases.json) if [ "$ENABLED" != "true" ]; then echo "::error::Version '$VERSION' is not enabled in databases.json" echo "" echo "Available versions:" jq -r " .databases.$DB.versions | to_entries | map(select(.value == true or ((.value | type) == \"object\" and (.value.enabled // true) == true))) | .[].key " databases.json exit 1 fi echo "✓ Version $VERSION is enabled in databases.json" - name: Validate sources.json exists run: | DB="mariadb" if [ ! -f "builds/$DB/sources.json" ]; then echo "::error::Missing builds/$DB/sources.json" exit 1 fi echo "✓ builds/$DB/sources.json exists" - name: Validate version in sources.json run: | VERSION="${{ github.event.inputs.version }}" DB="mariadb" HAS_VERSION=$(jq -r ".versions[\"$VERSION\"] // empty" "builds/$DB/sources.json") if [ -z "$HAS_VERSION" ]; then echo "::error::Version '$VERSION' not found in builds/$DB/sources.json" echo "" echo "Available versions in sources.json:" jq -r ".versions | keys[]" "builds/$DB/sources.json" exit 1 fi echo "✓ Version $VERSION found in sources.json" # Determine which platforms to build based on input prepare: needs: validate runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Set build matrix id: set-matrix run: | PLATFORMS="${{ github.event.inputs.platforms }}" if [ "$PLATFORMS" = "all" ]; then # All 5 platforms with their appropriate runners MATRIX='[ {"platform": "linux-x64", "runner": "ubuntu-latest", "build_type": "docker"}, {"platform": "linux-arm64", "runner": "ubuntu-latest", "build_type": "docker"}, {"platform": "darwin-x64", "runner": "macos-15-intel", "build_type": "native"}, {"platform": "darwin-arm64", "runner": "macos-15", "build_type": "native"}, {"platform": "win32-x64", "runner": "ubuntu-latest", "build_type": "download"} ]' else # Single platform - determine runner and build type case "$PLATFORMS" in linux-x64|linux-arm64) MATRIX="[{\"platform\": \"$PLATFORMS\", \"runner\": \"ubuntu-latest\", \"build_type\": \"docker\"}]" ;; darwin-x64) MATRIX="[{\"platform\": \"$PLATFORMS\", \"runner\": \"macos-15-intel\", \"build_type\": \"native\"}]" ;; darwin-arm64) MATRIX="[{\"platform\": \"$PLATFORMS\", \"runner\": \"macos-15\", \"build_type\": \"native\"}]" ;; win32-x64) MATRIX="[{\"platform\": \"$PLATFORMS\", \"runner\": \"ubuntu-latest\", \"build_type\": \"download\"}]" ;; esac fi # Compact the JSON for output MATRIX=$(echo "$MATRIX" | jq -c .) echo "matrix=$MATRIX" >> $GITHUB_OUTPUT echo "Building platforms: $MATRIX" # Build each platform in parallel build: needs: prepare strategy: fail-fast: false matrix: include: ${{ fromJson(needs.prepare.outputs.matrix) }} runs-on: ${{ matrix.runner }} steps: - name: Checkout uses: actions/checkout@v6 - name: Setup pnpm uses: pnpm/action-setup@v6 - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: '24' cache: 'pnpm' - name: Install dependencies run: pnpm install --frozen-lockfile # Set up QEMU for cross-platform Docker builds (required for linux-arm64 on x64 runners) - name: Set up QEMU if: matrix.build_type == 'docker' uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx if: matrix.build_type == 'docker' uses: docker/setup-buildx-action@v4 # For Linux: use Docker-based builds (download or source build) - name: Build for Linux/Windows (download or Docker) if: matrix.build_type == 'docker' || matrix.build_type == 'download' id: build-linux timeout-minutes: 180 run: | VERSION="${{ github.event.inputs.version }}" PLATFORM="${{ matrix.platform }}" echo "Building MariaDB $VERSION for $PLATFORM" pnpm download:mariadb -- \ --version "$VERSION" \ --platform "$PLATFORM" \ --build-fallback \ --output ./dist # Check if artifact was created shopt -s nullglob FILES=(./dist/mariadb-*.tar.gz ./dist/mariadb-*.zip) if [ ${#FILES[@]} -eq 0 ]; then echo "::error::No artifact created for $PLATFORM" exit 1 fi ls -la ./dist/ # For macOS: native build with Homebrew dependencies - name: Install macOS build dependencies if: matrix.build_type == 'native' run: | brew install cmake pcre2 lz4 xz zstd snappy jemalloc bison # Add Homebrew bison to PATH (system bison 2.3 is too old, need 2.4+) if [ -d "/opt/homebrew/opt/bison/bin" ]; then echo "/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH elif [ -d "/usr/local/opt/bison/bin" ]; then echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH fi - name: Build for macOS (native) if: matrix.build_type == 'native' id: build-macos timeout-minutes: 120 run: | VERSION="${{ github.event.inputs.version }}" PLATFORM="${{ matrix.platform }}" echo "Building MariaDB $VERSION for $PLATFORM (native macOS build)" # Pin the minimum macOS (see builds/common/macos-deployment-target.env) # and build the bundled OpenSSL with it: Homebrew bottles carry the # runner's own macOS as their minimum. source "$GITHUB_WORKSPACE/builds/common/macos-deployment-target.env" echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET" DEPS_PREFIX="$RUNNER_TEMP/hostdb-macos-deps" "$GITHUB_WORKSPACE/builds/common/build-macos-deps.sh" --prefix "$DEPS_PREFIX" openssl export HOSTDB_MACOS_DEPS_PREFIX="$DEPS_PREFIX" OPENSSL_PREFIX="$DEPS_PREFIX" # Get Homebrew prefix (differs between ARM64 and Intel macOS) BREW_PREFIX=$(brew --prefix) BISON_PATH="$BREW_PREFIX/opt/bison/bin/bison" echo "Using OpenSSL at: $OPENSSL_PREFIX" echo "Using Bison at: $BISON_PATH" # Validate bison executable exists if [ ! -x "$BISON_PATH" ]; then echo "::error::Bison not found or not executable at $BISON_PATH" echo "Install with: brew install bison" exit 1 fi # Verify bison version (need 2.4+) BISON_VERSION=$("$BISON_PATH" --version | head -1 | grep -oE '[0-9]+\.[0-9]+' | head -1) echo "Bison version: $BISON_VERSION (from $BISON_PATH)" BISON_MAJOR=$(echo "$BISON_VERSION" | cut -d. -f1) BISON_MINOR=$(echo "$BISON_VERSION" | cut -d. -f2) if [ "$BISON_MAJOR" -lt 2 ] || { [ "$BISON_MAJOR" -eq 2 ] && [ "$BISON_MINOR" -lt 4 ]; }; then echo "::error::Bison version $BISON_VERSION at $BISON_PATH is too old. MariaDB requires Bison >= 2.4" exit 1 fi if [ ! -d "$OPENSSL_PREFIX" ]; then echo "::error::OpenSSL not found at $OPENSSL_PREFIX" exit 1 fi # Clean up any previous build artifacts rm -rf mariadb-source.tar.gz mariadb-${VERSION} install dist # Download source curl -fsSL "https://archive.mariadb.org/mariadb-${VERSION}/source/mariadb-${VERSION}.tar.gz" \ -o mariadb-source.tar.gz tar -xzf mariadb-source.tar.gz # Build in source directory SOURCE_DIR="$GITHUB_WORKSPACE/mariadb-${VERSION}" BUILD_DIR="$SOURCE_DIR/build" mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" # Fix for Xcode 16+ SDK/toolchain mismatch issues # Force latest Xcode as the active developer directory XCODE_PATH=$(ls -d /Applications/Xcode*.app 2>/dev/null | sort -V | tail -1) echo "Using Xcode: $XCODE_PATH" sudo xcode-select -s "$XCODE_PATH/Contents/Developer" # Get SDK and toolchain paths export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) XCODE_TOOLCHAIN=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain echo "Using Xcode SDK (SDKROOT): $SDKROOT" echo "Using Xcode Toolchain: $XCODE_TOOLCHAIN" # Set compiler environment variables to force correct SDK # These take precedence over any CMake-added flags export CC="$XCODE_TOOLCHAIN/usr/bin/clang" export CXX="$XCODE_TOOLCHAIN/usr/bin/clang++" export CFLAGS="--sysroot=$SDKROOT" export CXXFLAGS="--sysroot=$SDKROOT -stdlib=libc++" export LDFLAGS="--sysroot=$SDKROOT" # Verify clang uses correct SDK echo "Clang SDK check:" $CC --version $CC -v -E -x c /dev/null 2>&1 | grep "selected sysroot" || true # Configure (disable Columnstore as it has macOS compatibility issues) # The lz4/lzo/snappy compression providers and the client zstd # plugin would link Homebrew bottles, which are built for the # runner's macOS (above the pinned target) and absent on most users' # Macs. They are optional, load-on-demand plugins (INSTALL SONAME or # plugin-load-add) and are not built; bzip2 and lzma providers link # the system libraries and stay. # Use xcrun to ensure cmake inherits correct SDK environment # Include both Xcode SDK and Homebrew in search paths (exclude Command Line Tools) # CMAKE_POLICY_VERSION_MINIMUM fixes compatibility with older wsrep-lib CMakeLists.txt # that specify cmake_minimum_required < 3.5 (CMake 4.0+ removed support for < 3.5) xcrun cmake "$SOURCE_DIR" \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/mariadb" \ -DCMAKE_OSX_SYSROOT="$SDKROOT" \ -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOSX_DEPLOYMENT_TARGET" \ -DCMAKE_FIND_ROOT_PATH="$SDKROOT;$DEPS_PREFIX;$BREW_PREFIX" \ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ -DZLIB_ROOT="$SDKROOT/usr" \ -DBISON_EXECUTABLE="$BISON_PATH" \ -DWITH_SSL="$OPENSSL_PREFIX" \ -DWITH_GNUTLS=OFF \ -DWITH_PCRE=system \ -DWITH_JEMALLOC=system \ -DWITH_UNIT_TESTS=OFF \ -DPLUGIN_TOKUDB=NO \ -DPLUGIN_ROCKSDB=NO \ -DPLUGIN_MROONGA=NO \ -DPLUGIN_SPIDER=NO \ -DPLUGIN_SPHINX=NO \ -DPLUGIN_CONNECT=NO \ -DPLUGIN_OQGRAPH=NO \ -DPLUGIN_COLUMNSTORE=NO \ -DPLUGIN_DUCKDB=NO \ -DPLUGIN_VIDEX=NO \ -DPLUGIN_S3=NO \ -DPLUGIN_PROVIDER_LZ4=NO \ -DPLUGIN_PROVIDER_LZO=NO \ -DPLUGIN_PROVIDER_SNAPPY=NO \ -DCLIENT_PLUGIN_ZSTD=OFF \ -DCOMPILATION_COMMENT="hostdb build" \ -DCOMPILATION_COMMENT_SERVER="Built by hostdb for spindb" # Build make -j$(sysctl -n hw.ncpu) # Install make install # Drop the test suites of the two plugins this build excludes. # -DPLUGIN_DUCKDB=NO / -DPLUGIN_VIDEX=NO stop the ENGINES from being # built, but `make install` still copies their mariadb-test suites # (text only, ~1 MB), so without this the macOS builds would ship # something the repacked official archives strip. These two paths # mirror the `directory` entries of BUNDLED_PLUGIN_EXCLUSIONS in # builds/mariadb/plugin-exclusions.ts - keep them in sync; # tests/mariadb-plugin-exclusions.test.ts asserts they match. rm -rf "$GITHUB_WORKSPACE/install/mariadb/mariadb-test/plugin/duckdb" \ "$GITHUB_WORKSPACE/install/mariadb/mariadb-test/plugin/videx" # Add metadata cd "$GITHUB_WORKSPACE/install" cat > mariadb/.hostdb-metadata.json << EOF { "name": "mariadb", "version": "${VERSION}", "platform": "${PLATFORM}", "source": "source-build", "sourceUrl": "https://archive.mariadb.org/", "rehosted_by": "hostdb", "rehosted_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" } EOF # Fix macOS dylib paths for relocatable binaries chmod +x "$GITHUB_WORKSPACE/builds/common/fix-macos-dylibs.sh" "$GITHUB_WORKSPACE/builds/common/fix-macos-dylibs.sh" "$GITHUB_WORKSPACE/install/mariadb" # Create tarball mkdir -p "$GITHUB_WORKSPACE/dist" tar -czvf "$GITHUB_WORKSPACE/dist/mariadb-${VERSION}-${PLATFORM}.tar.gz" mariadb echo "Build complete:" ls -la "$GITHUB_WORKSPACE/dist/" # Fail if any shipped Mach-O file needs a newer macOS than the pinned # target (builds/common/macos-deployment-target.env). - name: Check minimum macOS if: runner.os == 'macOS' run: ./builds/common/check-macos-minos.sh dist/*.tar.gz # Fail if any shipped Mach-O file (binaries, dylibs, lib/plugin/*.so) # loads a library by an absolute path outside /usr/lib and /System. - name: Check relocatable macOS binaries if: runner.os == 'macOS' run: ./builds/common/check-macos-dylibs.sh dist/*.tar.gz - name: Generate checksum run: | cd dist shopt -s nullglob for f in *.tar.gz *.zip; do if [ -f "$f" ]; then if command -v sha256sum &> /dev/null; then sha256sum "$f" >> checksums.txt else # macOS uses shasum shasum -a 256 "$f" >> checksums.txt fi fi done cat checksums.txt - name: Upload artifact uses: actions/upload-artifact@v4 with: name: mariadb-${{ github.event.inputs.version }}-${{ matrix.platform }} path: | dist/*.tar.gz dist/*.zip dist/checksums.txt retention-days: 1 # Collect all artifacts and create release release: needs: build if: ${{ !inputs.dry_run }} runs-on: ubuntu-latest permissions: contents: write steps: - name: Checkout uses: actions/checkout@v6 - name: Download all artifacts uses: actions/download-artifact@v4 with: path: ./artifacts pattern: mariadb-${{ github.event.inputs.version }}-* - name: Prepare release assets run: | mkdir -p ./release-assets # Move all artifacts to release-assets, flattening the directory structure find ./artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} ./release-assets/ \; # Combine all checksums find ./artifacts -name "checksums.txt" -exec cat {} \; > ./release-assets/checksums.txt echo "Release assets:" ls -la ./release-assets/ # Verify we have at least one artifact shopt -s nullglob FILES=(./release-assets/*.tar.gz ./release-assets/*.zip) if [ ${#FILES[@]} -eq 0 ]; then echo "ERROR: No artifacts were created for any platform" exit 1 fi echo "" echo "Checksums:" cat ./release-assets/checksums.txt - name: Validate required binaries run: | chmod +x builds/common/validate-binaries.sh ./builds/common/validate-binaries.sh mariadb ./release-assets - name: Check GLIBC floor (Linux artifacts) run: | chmod +x builds/common/check-glibc-floor.sh ./builds/common/check-glibc-floor.sh mariadb ./release-assets - name: Check platform coverage run: | chmod +x builds/common/check-platform-coverage.sh ./builds/common/check-platform-coverage.sh mariadb "${{ github.event.inputs.version }}" "${{ github.event.inputs.platforms }}" ./release-assets # A partial-platform dispatch (platforms != all) only rebuilds the # checksums for what it built, and action-gh-release REPLACES the # release's checksums.txt rather than merging. releases.json is derived # from checksums.txt, so an unmerged partial upload silently drops every # platform this run did not touch. Merge the existing lines back in first. - name: Merge existing release checksums env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | chmod +x builds/common/merge-release-checksums.sh ./builds/common/merge-release-checksums.sh "mariadb-${{ github.event.inputs.version }}" ./release-assets/checksums.txt # action-gh-release uploaded all six assets CONCURRENTLY with no per-file # retry and published the release before anything was verified. On the # 2026-09-17 MariaDB wave that step failed or stalled on 5 of 8 attempts # ("Error saving asset", "Headers Timeout Error", "Error creating asset # temp dir", and a 46-minute stall on the 450 MB linux-x64 archive that a # hand-run `gh release upload` then finished in 44 seconds). The release # is now created as a DRAFT, every asset is uploaded one at a time with # retries, checksums.txt goes last, the upload is verified against it, and # only then is the release published. - name: Publish release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Bound through env: a workflow input is attacker-controlled text, # and an expression splices it into the script before bash sees it. VERSION: ${{ github.event.inputs.version }} REPOSITORY: ${{ github.repository }} run: | mkdir -p ./release-notes cat >./release-notes/body.md <<'RELEASE_NOTES' ## MariaDB __VERSION__ MariaDB binaries for hostdb - all 5 platforms. ### Available Platforms | Platform | Source | |----------|--------| | `linux-x64` | Official binary or source build | | `linux-arm64` | Built from source (Docker) | | `darwin-x64` | Built from source (native macOS) | | `darwin-arm64` | Built from source (native macOS) | | `win32-x64` | Official binary | ### Usage ```bash # Download URL pattern https://github.com/__REPOSITORY__/releases/download/mariadb-__VERSION__/mariadb-__VERSION__-.tar.gz ``` ### Checksums See `checksums.txt` for SHA256 checksums. ### Sources - **Official**: [MariaDB Archive](https://archive.mariadb.org/) - **Source Build**: Compiled from source for platforms without official binaries RELEASE_NOTES # The notes are written with placeholders so the heredoc carries no # expression at all; fill them in from the env bindings above. python3 - <<'FILL_PLACEHOLDERS' import os path = './release-notes/body.md' with open(path, encoding='utf-8') as handle: body = handle.read() body = body.replace('__VERSION__', os.environ['VERSION']) body = body.replace('__REPOSITORY__', os.environ['REPOSITORY']) with open(path, 'w', encoding='utf-8') as handle: handle.write(body) FILL_PLACEHOLDERS chmod +x builds/common/publish-release.sh ./builds/common/publish-release.sh \ --tag "mariadb-$VERSION" \ --title "MariaDB $VERSION" \ --notes-file ./release-notes/body.md \ --assets-dir ./release-assets # Update the releases manifest upload-to-r2: needs: release if: ${{ !inputs.dry_run }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: ref: main - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v6 with: node-version: '24' cache: 'pnpm' - run: pnpm install --frozen-lockfile - name: Upload to R2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} run: pnpm tsx scripts/upload-to-r2.ts --tag "mariadb-${{ github.event.inputs.version }}" --force update-releases: needs: upload-to-r2 if: ${{ !inputs.dry_run }} # releases.json is one shared file committed to main and pushed to R2, and # each run rebuilds the WHOLE manifest, so two of these at once is # last-writer-wins: the loser's version silently disappears from the # manifest. Serialize repo-wide across every engine. # # Trade-off: GitHub keeps only one PENDING entry per group, so a third # simultaneous manifest job would be evicted. That is the strictly better # failure: an evicted job leaves a version missing from releases.json, which # publish.yml's drift gate catches before anything ships and one # rebuild-releases.yml dispatch repairs, whereas the race it prevents # silently reverts an already-published version with nothing to catch it. concurrency: group: hostdb-releases-manifest cancel-in-progress: false runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v6 with: ref: main - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v6 with: node-version: '24' cache: 'pnpm' - run: pnpm install --frozen-lockfile - name: Rebuild releases.json env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }} run: pnpm tsx scripts/build-releases-json.ts --upload-r2 - name: Commit and push run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add releases.json databases.json git diff --staged --quiet && echo "No changes" && exit 0 git commit -m "chore: update releases.json" git pull --rebase origin main git push