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
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ jobs:
type=semver,pattern={{major}},value=${{ needs.release.outputs.new_release_version }}
type=raw,value=latest

# Same timestamp format as the release binaries' BUILD_DATE above.
- name: Compute build date
id: build_date
run: echo "date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"

- name: Build and push
id: push
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
Expand All @@ -246,6 +251,13 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Stamp version metadata into the binary (Dockerfile ARGs feeding
# -X ldflags on cmd/version.go); without these the image reports
# "plumber version dev" (getplumber/plumber#425).
build-args: |
VERSION=${{ needs.release.outputs.new_release_version }}
COMMIT=${{ github.sha }}
BUILD_DATE=${{ steps.build_date.outputs.date }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Always rebuild the `runtime` stage so `apk upgrade` re-runs and pulls
Expand Down
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ RUN go mod download
# Copy source code
COPY . .

# Version metadata stamped into the binary (cmd/version.go). The release
# workflow passes these as build args so `plumber version` in the published
# image reports the release, matching the ldflags used for the release
# binaries in release.yml. Plain `docker build` (ci.yml, local) keeps the
# dev defaults. Declared here, after the cacheable dependency layers, so a
# changing BUILD_DATE never invalidates `go mod download`.
ARG VERSION=dev
ARG COMMIT=none
ARG BUILD_DATE=unknown

# Build static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o plumber .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X github.com/getplumber/plumber/cmd.Version=${VERSION} -X github.com/getplumber/plumber/cmd.Commit=${COMMIT} -X github.com/getplumber/plumber/cmd.BuildDate=${BUILD_DATE}" -o plumber .

# Final stage - Alpine (small, has shell for CI compatibility)
# Named `runtime` so CI can target it with build-push-action's `no-cache-filter:
Expand Down