diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7212fc0f..fe48d75a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,7 @@ jobs: echo "Testing with PostgreSQL 17" PGSCHEMA_POSTGRES_VERSION=17 go test -v ./... - # Build Linux binaries using Docker (handles CGO cross-compilation) + # Build Linux binaries using native Go cross-compilation build-linux: needs: test runs-on: ubuntu-latest @@ -60,11 +60,10 @@ jobs: with: fetch-depth: 0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.24" - name: Read version id: version @@ -76,21 +75,11 @@ jobs: echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT echo "BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_OUTPUT - - name: Build Docker image and extract binary + - name: Build binary run: | - # Build Docker image for the target architecture - docker buildx build \ - --platform linux/${{ matrix.arch }} \ - --build-arg GIT_COMMIT=${{ steps.build_info.outputs.GIT_COMMIT }} \ - --build-arg BUILD_DATE="${{ steps.build_info.outputs.BUILD_DATE }}" \ - --load \ - -t pgschema-build:${{ matrix.arch }} \ - . - - # Extract binary from the image - docker create --name pgschema-extract pgschema-build:${{ matrix.arch }} - docker cp pgschema-extract:/usr/local/bin/pgschema ./pgschema-linux-${{ matrix.arch }} - docker rm pgschema-extract + GOOS=linux GOARCH=${{ matrix.arch }} go build \ + -ldflags "-X github.com/pgschema/pgschema/cmd.GitCommit=${{ steps.build_info.outputs.GIT_COMMIT }} -X 'github.com/pgschema/pgschema/cmd.BuildDate=${{ steps.build_info.outputs.BUILD_DATE }}'" \ + -o pgschema-linux-${{ matrix.arch }} . - name: Upload artifacts uses: actions/upload-artifact@v4 diff --git a/CLAUDE.md b/CLAUDE.md index 7f8f6ab0..2a1a5f5a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -43,7 +43,7 @@ Skills are located in `.claude/skills/` and provide detailed workflows for commo go build -o pgschema . # Build with version info (used in CI/Docker) -CGO_ENABLED=1 go build -ldflags="-w -s -X github.com/pgschema/pgschema/cmd.GitCommit=... -X 'github.com/pgschema/pgschema/cmd.BuildDate=...'" -o pgschema . +go build -ldflags="-w -s -X github.com/pgschema/pgschema/cmd.GitCommit=... -X 'github.com/pgschema/pgschema/cmd.BuildDate=...'" -o pgschema . ``` ### Testing diff --git a/Dockerfile b/Dockerfile index b00b8541..e396a22b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,9 @@ # Build stage FROM golang:1.24-alpine AS builder -# Install build dependencies including gcc for CGO +# Install build dependencies RUN apk add --no-cache \ - git \ - gcc \ - g++ \ - musl-dev + git # Set working directory WORKDIR /build @@ -24,8 +21,8 @@ COPY . . ARG GIT_COMMIT=unknown ARG BUILD_DATE=unknown -# Build with CGO enabled and optimizations -RUN CGO_ENABLED=1 GOOS=linux go build \ +# Build with optimizations +RUN GOOS=linux go build \ -ldflags="-w -s -X github.com/pgschema/pgschema/cmd.GitCommit=${GIT_COMMIT} -X 'github.com/pgschema/pgschema/cmd.BuildDate=${BUILD_DATE}'" \ -a \ -o pgschema . @@ -36,8 +33,7 @@ FROM alpine:3.20 # Install runtime dependencies RUN apk add --no-cache \ ca-certificates \ - tzdata \ - libc6-compat && \ + tzdata && \ adduser -D -g '' pgschema # Copy binary from builder