Set version and revision at linked time#234
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
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.
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.
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.mmake VERSION=v1.2.3 pass
./bin/build/docker-credential-pass version
docker-credential-pass (github.com/docker/docker-credential-helpers) v1.2.3Hm... 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+unknownAH! 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.
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.
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.
Yes, so wondering if PKG needs to be configurable in this context 🤔 (could just be hard-coded)
There was a problem hiding this comment.
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>
Signed-off-by: CrazyMax crazy-max@users.noreply.github.com