Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.8 backport] ci: use proper git ref for versioning #3595

Merged
merged 1 commit into from Feb 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile
Expand Up @@ -12,6 +12,10 @@ WORKDIR /go/src/github.com/docker/distribution
FROM base AS build
ENV GO111MODULE=auto
ENV CGO_ENABLED=0
# GIT_REF is used by goreleaser-xx to handle the proper git ref when available.
# It will fallback to the working tree info if empty and use "git tag --points-at"
# or "git describe" to define the version info.
ARG GIT_REF
ARG TARGETPLATFORM
ARG PKG="github.com/distribution/distribution"
ARG BUILDTAGS="include_oss include_gcs"
Expand All @@ -28,7 +32,7 @@ RUN --mount=type=bind,rw \
--files="LICENSE" \
--files="README.md"

FROM scratch AS artifacts
FROM scratch AS artifact
COPY --from=build /out/*.tar.gz /
COPY --from=build /out/*.zip /
COPY --from=build /out/*.sha256 /
Expand Down
18 changes: 16 additions & 2 deletions docker-bake.hcl
@@ -1,3 +1,15 @@
// GITHUB_REF is the actual ref that triggers the workflow
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
variable "GITHUB_REF" {
default = ""
}

target "_common" {
args = {
GIT_REF = GITHUB_REF
}
}

group "default" {
targets = ["image-local"]
}
Expand All @@ -8,12 +20,14 @@ target "docker-metadata-action" {
}

target "binary" {
inherits = ["_common"]
target = "binary"
output = ["./bin"]
}

target "artifact" {
target = "artifacts"
inherits = ["_common"]
target = "artifact"
output = ["./bin"]
}

Expand All @@ -30,7 +44,7 @@ target "artifact-all" {
}

target "image" {
inherits = ["docker-metadata-action"]
inherits = ["_common", "docker-metadata-action"]
}

target "image-local" {
Expand Down