docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.59k stars 483 forks source link

Tweak 'BUILDX_GIT_LABELS' to get the git tag if it exists #2735

Closed a-watts-fnc closed 1 month ago

a-watts-fnc commented 1 month ago

Description

Hi, I think it might make sense to edit the behaviour of BUILDX_GIT_LABELS=1 to also add a label org.opencontainers.image.tag=<git_tagged_version>?

If it exists, a tag is more semantically useful than the commit hash IMO - I'd even make the argument that it should attempt to use the tag first, and then fall back to using the commit hash if it isn't present. It looks that there is already the Git.Tag function for retrieving the tag, so hopefully it wouldn't be too big a change.

tonistiigi commented 1 month ago

What's the behavior if there are more than one tags for a commit?

a-watts-fnc commented 1 month ago

Ah, I didn't know you could have multiple tags, in that case I see why the hash make sense