Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 59 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@ jobs:
build-darwin:
strategy:
matrix:
goarch: [amd64, arm64]
variant: [full, lite, minimal]
include:
- goarch: amd64
runner: macos-15-intel
- goarch: arm64
runner: macos-latest
- variant: full
tags: ""
suffix: ""
cgo: "1"
- variant: lite
tags: noduckdb,nosnowflake,noracle
suffix: lite-
cgo: "0"
- variant: minimal
tags: noduckdb,nosnowflake,noracle,noclickhouse,nofirebird,nosqlserver
suffix: minimal-
cgo: "0"
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
Expand All @@ -33,19 +47,35 @@ jobs:

- name: Build
env:
CGO_ENABLED: 1
CGO_ENABLED: ${{ matrix.cgo }}
GOOS: darwin
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist
go build -buildvcs=false -ldflags="-s -w -X main.Version=${{ github.ref_name }}" -o dist/${{ env.APP_NAME }}-darwin-${{ matrix.goarch }} ./cmd/squix
go build -buildvcs=false -ldflags="-s -w -X main.Version=${{ github.ref_name }}" -tags "${{ matrix.tags }}" -o dist/${{ env.APP_NAME }}-${{ matrix.suffix }}darwin-${{ matrix.goarch }} ./cmd/squix

- uses: actions/upload-artifact@v4
with:
name: darwin-${{ matrix.goarch }}
path: dist/${{ env.APP_NAME }}-darwin-${{ matrix.goarch }}
name: darwin-${{ matrix.goarch }}-${{ matrix.variant }}
path: dist/${{ env.APP_NAME }}-${{ matrix.suffix }}darwin-${{ matrix.goarch }}

build-windows:
strategy:
matrix:
variant: [full, lite, minimal]
include:
- variant: full
tags: ""
suffix: ""
cgo: "1"
- variant: lite
tags: noduckdb,nosnowflake,noracle
suffix: lite-
cgo: "0"
- variant: minimal
tags: noduckdb,nosnowflake,noracle,noclickhouse,nofirebird,nosqlserver
suffix: minimal-
cgo: "0"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -58,27 +88,39 @@ jobs:

- name: Build
env:
CGO_ENABLED: 1
CGO_ENABLED: ${{ matrix.cgo }}
GOOS: windows
GOARCH: amd64
run: |
mkdir dist
go build -buildvcs=false -ldflags="-s -w -X main.Version=${{ github.ref_name }}" -o dist/${{ env.APP_NAME }}-windows-amd64.exe ./cmd/squix
go build -buildvcs=false -ldflags="-s -w -X main.Version=${{ github.ref_name }}" -tags "${{ matrix.tags }}" -o dist/${{ env.APP_NAME }}-${{ matrix.suffix }}windows-amd64.exe ./cmd/squix

- uses: actions/upload-artifact@v4
with:
name: windows-amd64
path: dist/${{ env.APP_NAME }}-windows-amd64.exe
name: windows-amd64-${{ matrix.variant }}
path: dist/${{ env.APP_NAME }}-${{ matrix.suffix }}windows-amd64.exe

build-linux:
strategy:
matrix:
goarch: [amd64, arm64]
variant: [full, lite, minimal]
include:
- goarch: amd64
packages: ""
- goarch: arm64
variant: full
cc: aarch64-linux-gnu-gcc
packages: "gcc-aarch64-linux-gnu g++-aarch64-linux-gnu"
- variant: full
tags: ""
suffix: ""
cgo: "1"
- variant: lite
tags: noduckdb,nosnowflake,noracle
suffix: lite-
cgo: "0"
- variant: minimal
tags: noduckdb,nosnowflake,noracle,noclickhouse,nofirebird,nosqlserver
suffix: minimal-
cgo: "0"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -90,23 +132,23 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: Install cross-compiler
if: matrix.packages != ''
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.packages }}
if: matrix.goarch == 'arm64' && matrix.variant == 'full'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

- name: Build
env:
CGO_ENABLED: 1
CGO_ENABLED: ${{ matrix.cgo }}
GOOS: linux
GOARCH: ${{ matrix.goarch }}
CC: ${{ matrix.cc }}
run: |
mkdir -p dist
go build -buildvcs=false -ldflags="-s -w -X main.Version=${{ github.ref_name }}" -o dist/${{ env.APP_NAME }}-linux-${{ matrix.goarch }} ./cmd/squix
go build -buildvcs=false -ldflags="-s -w -X main.Version=${{ github.ref_name }}" -tags "${{ matrix.tags }}" -o dist/${{ env.APP_NAME }}-${{ matrix.suffix }}linux-${{ matrix.goarch }} ./cmd/squix

- uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.goarch }}
path: dist/${{ env.APP_NAME }}-linux-${{ matrix.goarch }}
name: linux-${{ matrix.goarch }}-${{ matrix.variant }}
path: dist/${{ env.APP_NAME }}-${{ matrix.suffix }}linux-${{ matrix.goarch }}

create-release:
needs:
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
.PHONY: test test-verbose lint fmt vet build ci clean
.PHONY: test test-verbose lint fmt vet build build-lite build-minimal ci clean

BINARY=squix
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS=-ldflags "-X main.Version=$(VERSION)"
LDFLAGS=-ldflags "-s -w -X main.Version=$(VERSION)"

LITE_TAGS=noduckdb,nosnowflake,noracle
MINIMAL_TAGS=noduckdb,nosnowflake,noracle,noclickhouse,nofirebird,nosqlserver

build:
go build $(LDFLAGS) -o $(BINARY) ./cmd/squix

build-lite:
go build $(LDFLAGS) -tags "$(LITE_TAGS)" -o $(BINARY)-lite ./cmd/squix

build-minimal:
go build $(LDFLAGS) -tags "$(MINIMAL_TAGS)" -o $(BINARY)-minimal ./cmd/squix

test:
go test ./...

Expand All @@ -25,4 +34,4 @@ vet:
ci: fmt vet lint test

clean:
rm -f $(BINARY)
rm -f $(BINARY) $(BINARY)-lite $(BINARY)-minimal
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ go build -o squix ./cmd/squix
```
The squix binary will be available in the root project directory

DuckDB requires CGO and is included in the default build. To build without DuckDB:
```bash
CGO_ENABLED=0 go build -o squix ./cmd/squix
```
See [Build variants](docs/features.md#build-variants) for the full/lite/minimal builds and which drivers each one includes.
</details>

<details>
Expand Down
88 changes: 54 additions & 34 deletions build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ BUILD_DIR="./dist"
NATIVE_OS=$(go env GOOS)
NATIVE_ARCH=$(go env GOARCH)

LITE_TAGS="noduckdb,nosnowflake,noracle"
MINIMAL_TAGS="noduckdb,nosnowflake,noracle,noclickhouse,nofirebird,nosqlserver"

echo "Building $APP_NAME version $VERSION"
echo "=================================="

Expand All @@ -17,54 +20,81 @@ rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"

FULL_DRIVERS=()
LIMITED_DRIVERS=()

# Build with appropriate CGO setting based on target arch
# Build with appropriate CGO setting based on target arch.
# Variants:
# full - every driver (DuckDB needs CGO; only the native platform gets CGO=1)
# lite - no DuckDB/Snowflake/Oracle, works without CGO
# minimal - lite minus ClickHouse/Firebird/SQL Server (postgres, mysql, sqlite)
build_platform() {
local platform=$1
local goos=$2
local goarch=$3
local output=$4
local name_suffix=$4

echo ""
echo "Building $platform..."
echo "Building $platform ($name_suffix)..."

local tags=""
if [ "$name_suffix" = "lite" ]; then tags=$LITE_TAGS; fi
if [ "$name_suffix" = "minimal" ]; then tags=$MINIMAL_TAGS; fi

local output_name="${APP_NAME}-${platform}"
if [ "$name_suffix" != "full" ]; then
output_name="${APP_NAME}-${name_suffix}-${platform}"
fi
if [ "$goos" = "windows" ]; then
output_name="${output_name}.exe"
fi

local cgo=0
if [ "$name_suffix" = "full" ] && [ "$goos" = "$NATIVE_OS" ] && [ "$goarch" = "$NATIVE_ARCH" ]; then
cgo=1
fi

local extra_args=()
if [ -n "$tags" ]; then
extra_args=(-tags "$tags")
fi

if [ "$goos" = "$NATIVE_OS" ] && [ "$goarch" = "$NATIVE_ARCH" ]; then
CGO_ENABLED=1 GOOS=$goos GOARCH=$goarch go build -ldflags="-s -w -X main.Version=$VERSION" -o "$output" ./cmd/squix
CGO_ENABLED=$cgo GOOS=$goos GOARCH=$goarch go build \
-ldflags="-s -w -X main.Version=$VERSION" \
"${extra_args[@]}" \
-o "$BUILD_DIR/$output_name" ./cmd/squix

if [ "$cgo" = "1" ]; then
FULL_DRIVERS+=("$platform")
else
CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch go build -ldflags="-s -w -X main.Version=$VERSION" -o "$output" ./cmd/squix
LIMITED_DRIVERS+=("$platform")
fi

echo "✓ Built $platform successfully"
echo "✓ Built $output_name successfully"
}

# Build Linux AMD64
build_platform "Linux AMD64" "linux" "amd64" "$BUILD_DIR/${APP_NAME}-linux-amd64"
for suffix in full lite minimal; do
# Build Linux AMD64
build_platform "linux-amd64" "linux" "amd64" "$suffix"

# Build Linux ARM64
build_platform "Linux ARM64" "linux" "arm64" "$BUILD_DIR/${APP_NAME}-linux-arm64"
# Build Linux ARM64
build_platform "linux-arm64" "linux" "arm64" "$suffix"

# Build Windows AMD64
build_platform "Windows AMD64" "windows" "amd64" "$BUILD_DIR/${APP_NAME}-windows-amd64.exe"
# Build Windows AMD64
build_platform "windows-amd64" "windows" "amd64" "$suffix"

# Build macOS AMD64
build_platform "macOS AMD64" "darwin" "amd64" "$BUILD_DIR/${APP_NAME}-darwin-amd64"
# Build macOS AMD64
build_platform "darwin-amd64" "darwin" "amd64" "$suffix"

# Build macOS ARM64
build_platform "macOS ARM64" "darwin" "arm64" "$BUILD_DIR/${APP_NAME}-darwin-arm64"
# Build macOS ARM64
build_platform "darwin-arm64" "darwin" "arm64" "$suffix"
done

echo ""
echo "=================================="
echo "Build complete!"
echo "=================================="
echo ""
echo "Full driver support (CGO_ENABLED=1):"
echo "Full driver support (CGO_ENABLED=1, native platform only):"
for p in "${FULL_DRIVERS[@]}"; do echo " ✓ $p"; done
echo ""
echo "Limited driver support - no DuckDB (CGO_ENABLED=0):"
for p in "${LIMITED_DRIVERS[@]}"; do echo " ✓ $p"; done
echo "DuckDB is not included in non-native full builds (CGO_ENABLED=0):"
echo " use the lite/minimal variants for those platforms instead"
echo ""

# Create source code archives
Expand All @@ -78,17 +108,7 @@ echo ""
echo "Generating checksums for all artifacts..."
find "$BUILD_DIR" -type f -exec sha256sum {} + | sed "s|$BUILD_DIR/||" > "$BUILD_DIR/checksums.txt"
echo "✓ Checksums generated in $BUILD_DIR/checksums.txt"

echo ""
echo "=================================="
echo "All tasks complete!"
echo "=================================="
echo ""
echo "Binaries location: $BUILD_DIR/"
echo "Source archives location: $BUILD_DIR/source/"
echo "Checksum file: $BUILD_DIR/checksums.txt"
echo ""
ls -lh "$BUILD_DIR/"
echo ""
ls -lh "$BUILD_DIR/source/"
echo ""
10 changes: 10 additions & 0 deletions cmd/squix/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (a *App) Run() {
os.Exit(0)
}

if os.Args[1] == "--drivers" {
a.handleDrivers()
os.Exit(0)
}

command := os.Args[1]
switch command {
case "init":
Expand Down Expand Up @@ -125,6 +130,11 @@ func (a *App) printUsage() {
"List database connections",
),
)
fmt.Println(
" squix --drivers " + styles.Faint.Render(
"List database drivers in this build",
),
)
fmt.Println(
" squix disconnect " + styles.Faint.Render(
"Disconnect from current database",
Expand Down
22 changes: 22 additions & 0 deletions cmd/squix/drivers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"

"github.com/eduardofuncao/squix/internal/db"
"github.com/eduardofuncao/squix/internal/styles"
)

func (a *App) handleDrivers() {
fmt.Println(styles.Title.Render("Drivers in this build"))
for _, t := range db.KnownDBTypes() {
if db.IsDriverBuilt(t) {
fmt.Println(" " + styles.Success.Render("✓") + " " + t)
} else {
msg := "✗ " + t + " — not included (excluded via -tags " + db.DriverBuildTag(t) + ")"
Comment thread
eduardofuncao marked this conversation as resolved.
fmt.Println(" " + styles.Faint.Render(msg))
}
}
fmt.Println()
fmt.Println(styles.Faint.Render("Rebuild without the tag, or install the full squix build, to enable excluded drivers."))
}
28 changes: 28 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,31 @@ squix@mydb> status
| `list`, `ls`, `\l` | List queries or connections |

Multi-line: type SQL without trailing `;` to continue. End with `;` or press Enter on blank line to execute.

## Build variants

Squix ships in three variants so you can trade driver coverage for binary size and portability. DuckDB is the only driver needing CGO; the slimmer variants build without it.

| Variant | Excluded drivers | Included drivers |
|---------|------------------|------------------|
| full | none | postgres, mysql, sqlite, sqlserver, clickhouse, oracle, firebird, duckdb, snowflake |
| lite | duckdb, snowflake, oracle | postgres, mysql, sqlite, sqlserver, clickhouse, firebird |
| minimal | duckdb, snowflake, oracle, clickhouse, firebird, sqlserver | postgres, mysql, sqlite |

Check what your binary supports:

```bash
squix --drivers
```

Excluded drivers report which build tag removes them, e.g. `not included (excluded via -tags noduckdb)`. Rebuild without the tag, or install the full build, to enable them.

Build a variant from source:

```bash
make build # full
make build-lite # lite (-tags "noduckdb,nosnowflake,noracle")
make build-minimal # minimal (-tags "noduckdb,nosnowflake,noracle,noclickhouse,nofirebird,nosqlserver")
```

Or via Nix flakes: `squix.packages.<system>.default` / `.lite` / `.minimal`. Release pages carry all three per platform (`squix-<os>-<arch>`, `squix-lite-<os>-<arch>`, `squix-minimal-<os>-<arch>`); the Homebrew formula and nixpkgs package track the full build.
Loading
Loading