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
Set version and revision at linked time #234
Conversation
Codecov Report
@@ Coverage Diff @@
## master #234 +/- ##
=======================================
Coverage 55.25% 55.25%
=======================================
Files 9 9
Lines 666 666
=======================================
Hits 368 368
Misses 255 255
Partials 43 43
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
oh, sorry; needs a rebase now 😅 |
// Package is filled at linking time | ||
Package = "github.com/docker/docker-credential-helpers" | ||
|
||
// Version holds the complete version number. Filled in at linking time. | ||
Version = "v0.0.0+unknown" | ||
|
||
// Revision is filled with the VCS (e.g. git) revision being used to build | ||
// the program at linking time. | ||
Revision = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we already at a point where we could use Go's built-in features for this?
If so; can they still be overridden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum good idea we should look at this in a follow-up
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Hmm... so for fun, I tried
|
Yes I have a branch ready to fix this. Pretty much like #209 but specs not inline. |
I tried changing
to version=${1##v} Which fixes the version issue:
But then breaks because we added
Yeah, looks like that needs more work (was hoping fixing that version would make it "somewhat" work); let's keep that for later |
make pass
./bin/build/docker-credential-pass version
docker-credential-pass (github.com/docker/docker-credential-helpers) v0.6.4-39-geb147ed.m make VERSION=v1.2.3 pass
./bin/build/docker-credential-pass version
docker-credential-pass (github.com/docker/docker-credential-helpers) v1.2.3 Hm... this one doesn't look right; make VERSION=v1.2.3 PKG=hello-package pass
./bin/build/docker-credential-pass version
(github.com/docker/docker-credential-helpers) v0.0.0+unknown AH!
Looks like you're using |
Yeah deb pkg is broken since Go 1.18.5. I made quick changes to fix that but I have another branch to merge that logic in the main Dockerfile. Also added a simple gha job to check deb package builds correctly: https://github.com/docker/docker-credential-helpers/runs/8045166392?check_suite_focus=true |
Makefile
Outdated
.PHONY: build-% | ||
build-%: # build, can be one of build-osxkeychain build-pass build-secretservice build-wincred | ||
$(eval BINNAME ?= docker-credential-$*) | ||
go build -trimpath -ldflags="$(GO_LDFLAGS) -X ${PKG}/credentials.Package=${PKG}/$* -X ${PKG}/credentials.Name=docker-credential-$*" -o $(DESTDIR)/$(BINNAME) ./$*/cmd/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you update, because this looks to still have PKG
used both at the start and as value;
go build -trimpath -ldflags="$(GO_LDFLAGS) -X ${PKG}/credentials.Package=${PKG}/$* -X ${PKG}/credentials.Name=docker-credential-$*" -o $(DESTDIR)/$(BINNAME) ./$*/cmd/ | |
go build -trimpath -ldflags="$(GO_LDFLAGS) -X ${PKG}/credentials.Package=${PACKAGE_NAME}/$* -X ${PKG}/credentials.Name=docker-credential-$*" -o $(DESTDIR)/$(BINNAME) ./$*/cmd/ |
(mostly thinking that Package
here could, e.g., be docker-ce
or some other name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I get it now, so for me Package
is Go module or base package. Will change that with a new var like you said..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so wondering if PKG
needs to be configurable in this context 🤔 (could just be hard-coded)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes hardcoded is fine, changed to GO_PKG
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Signed-off-by: CrazyMax crazy-max@users.noreply.github.com