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
29 changes: 9 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 .
Expand All @@ -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
Expand Down