diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa55fdf..70f7938 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,6 +38,9 @@ jobs: - os: linux runs-on: ubuntu-latest arch: x86_64 + - os: linux-musl + runs-on: ubuntu-latest + arch: x86_64 steps: - name: Checkout code uses: actions/checkout@v4 @@ -46,13 +49,21 @@ jobs: uses: actions/setup-go@v4 with: go-version: "1.21" - - name: Install dependencies (Ubuntu) if: matrix.os == 'linux' run: | sudo apt-get update sudo apt-get install -y sqlite3 libsqlite3-dev build-essential + - name: Install dependencies (Alpine/musl) + if: matrix.os == 'linux-musl' + run: | + # Use Alpine container for musl builds + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace alpine:latest sh -c " + apk add --no-cache build-base sqlite-dev go curl git && + echo 'Alpine dependencies installed' + " + - name: Install dependencies (macOS) if: matrix.os == 'darwin' run: | @@ -64,7 +75,7 @@ jobs: choco install sqlite - name: Build SQLite (Unix) - if: matrix.os != 'windows' + if: matrix.os != 'windows' && matrix.os != 'linux-musl' run: | cd sqlite if [ ! -d "sqlite-latest" ]; then @@ -78,6 +89,24 @@ jobs: make make install + - name: Build SQLite (Alpine/musl) + if: matrix.os == 'linux-musl' + run: | + # Build SQLite in Alpine container for musl compatibility + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace alpine:latest sh -c " + apk add --no-cache build-base curl && + cd sqlite && + if [ ! -d 'sqlite-latest' ]; then + curl -O https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz + tar xzf sqlite-autoconf-3450100.tar.gz + mv sqlite-autoconf-3450100 sqlite-latest + fi && + cd sqlite-latest && + ./configure --prefix=\$(pwd)/../install --enable-static --disable-shared 'CFLAGS=-DSQLITE_ENABLE_DBPAGE_VTAB=1 -O2' && + make && + make install + " + - name: Build SQLite (Windows) if: matrix.os == 'windows' run: | @@ -94,10 +123,21 @@ jobs: bash -c "make install" - name: Build Bridge + if: matrix.os != 'linux-musl' run: | cd bridge make + - name: Build Bridge (Alpine/musl) + if: matrix.os == 'linux-musl' + run: | + # Build bridge in Alpine container + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace alpine:latest sh -c " + apk add --no-cache build-base go && + cd bridge && + make + " + - name: Set build environment (Darwin ARM64) if: matrix.os == 'darwin' && matrix.arch == 'arm64' run: | @@ -119,6 +159,13 @@ jobs: echo "GOARCH=amd64" >> $GITHUB_ENV echo "CGO_ENABLED=1" >> $GITHUB_ENV + - name: Set build environment (Linux musl x86_64) + if: matrix.os == 'linux-musl' && matrix.arch == 'x86_64' + run: | + echo "GOOS=linux" >> $GITHUB_ENV + echo "GOARCH=amd64" >> $GITHUB_ENV + echo "CGO_ENABLED=1" >> $GITHUB_ENV + - name: Set build environment (Windows) if: matrix.os == 'windows' run: | @@ -127,11 +174,38 @@ jobs: echo "CGO_ENABLED=1" >> $env:GITHUB_ENV - name: Build Client (Unix) - if: matrix.os != 'windows' + if: matrix.os != 'windows' && matrix.os != 'linux-musl' run: | cd client make build + - name: Build Client (Alpine/musl) + if: matrix.os == 'linux-musl' + run: | + # Build client in Alpine container + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace alpine:latest sh -c " + apk add --no-cache zlib-dev build-base go git && + git config --global --add safe.directory /workspace && + cd client && + make build + " + # Verify binary was created + if [ ! -f ./client/bin/sqlrsync ]; then + echo "ERROR: Binary not found at ./client/bin/sqlrsync" + exit 1 + fi + echo "✓ Binary built successfully at ./client/bin/sqlrsync" + file ./client/bin/sqlrsync + + - name: Docker based test (Alpine/musl) + if: matrix.os == 'linux-musl' + run: | + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace alpine:latest sh -c " + ldd ./client/bin/sqlrsync && + ./client/bin/sqlrsync --version && + ./client/bin/sqlrsync usgs.gov/earthquakes.db + " + - name: Build Client (Windows) if: matrix.os == 'windows' run: | @@ -140,16 +214,19 @@ jobs: bash -c "make build" - name: Test sqlrsync --version + if: matrix.os != 'linux-musl' run: | echo "Testing sqlrsync --version..." ./client/bin/sqlrsync --version - name: Test sqlrsync help + if: matrix.os != 'linux-musl' run: | echo "Testing sqlrsync help..." ./client/bin/sqlrsync || true - name: Test sqlrsync with usgs.gov/earthquakes.db + if: matrix.os != 'linux-musl' run: | echo "Testing sqlrsync usgs.gov/earthquakes.db..." ./client/bin/sqlrsync usgs.gov/earthquakes.db @@ -187,7 +264,7 @@ jobs: Receive-Job $job > subscribe_output.log 2>&1 || $true - name: Verify subscribe output (Unix) - if: matrix.os != 'windows' + if: matrix.os != 'windows' && matrix.os != 'linux-musl' run: | echo "Checking for 'Sync complete' in output..." cat subscribe_output.log diff --git a/client/main.go b/client/main.go index a264a0a..6c71614 100644 --- a/client/main.go +++ b/client/main.go @@ -15,7 +15,7 @@ import ( "github.com/sqlrsync/sqlrsync.com/sync" ) -var VERSION = "0.0.7" +var VERSION = "0.0.8" var ( serverURL string verbose bool