2 Commits

Author SHA1 Message Date
jamie 5f2f7ea855 fix: use clean version variable for binary build flags and docker build arguments
Release / release (pull_request) Successful in 26s
2026-06-12 14:45:38 +01:00
jamie 416684c0c1 feat: inject version string into binary via Docker build argument
Release / release (pull_request) Successful in 29s
2026-06-12 14:43:20 +01:00
2 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -32,11 +32,11 @@ jobs:
- name: Build Binary - name: Build Binary
run: | run: |
go mod tidy go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${{ steps.get_version.outputs.VERSION }}" -o goencode ./cmd/goencode CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${{ steps.get_version.outputs.CLEAN_VERSION }}" -o goencode ./cmd/goencode
- name: Build and push Docker image - name: Build and push Docker image
run: | run: |
docker build -t cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} . docker build --build-arg APP_VERSION=${{ steps.get_version.outputs.CLEAN_VERSION }} -t cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} .
docker push cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} docker push cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }}
docker tag cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} cr.jdbnet.co.uk/public/goencode:latest docker tag cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} cr.jdbnet.co.uk/public/goencode:latest
docker push cr.jdbnet.co.uk/public/goencode:latest docker push cr.jdbnet.co.uk/public/goencode:latest
+3 -1
View File
@@ -6,11 +6,13 @@ WORKDIR /app
# Copy source code # Copy source code
COPY . . COPY . .
ARG APP_VERSION=dev
# Run go mod tidy to generate go.sum based on source # Run go mod tidy to generate go.sum based on source
RUN go mod tidy RUN go mod tidy
# Build the application # Build the application
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/bin/goencode ./cmd/goencode RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${APP_VERSION}" -o /app/bin/goencode ./cmd/goencode
# Final stage # Final stage
FROM debian:bookworm-slim FROM debian:bookworm-slim