Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from crazy-max/versioning
Set version and revision at linked time
- Loading branch information
Showing
10 changed files
with
123 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
/bin | ||
/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
/bin | ||
/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,95 @@ | ||
.PHONY: all osxkeychain secretservice test lint validate-vendor fmt validate wincred pass deb vendor | ||
PACKAGE ?= github.com/docker/docker-credential-helpers | ||
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags) | ||
REVISION ?= $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi) | ||
|
||
VERSION := $(shell grep 'const Version' credentials/version.go | awk -F'"' '{ print $$2 }') | ||
GO_PKG = github.com/docker/docker-credential-helpers | ||
GO_LDFLAGS = -s -w -X ${GO_PKG}/credentials.Version=${VERSION} -X ${GO_PKG}/credentials.Revision=${REVISION} -X ${GO_PKG}/credentials.Package=${PACKAGE} | ||
|
||
all: test | ||
BUILDX_CMD ?= docker buildx | ||
DESTDIR ?= ./bin/build | ||
|
||
.PHONY: all | ||
all: cross | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf bin | ||
rm -rf release | ||
|
||
osxkeychain: | ||
mkdir -p bin | ||
go build -ldflags -s -o bin/docker-credential-osxkeychain ./osxkeychain/cmd/ | ||
|
||
osxcodesign: osxkeychain | ||
$(eval SIGNINGHASH = $(shell security find-identity -v -p codesigning | grep "Developer ID Application: Docker Inc" | cut -d ' ' -f 4)) | ||
xcrun -log codesign -s $(SIGNINGHASH) --force --verbose bin/docker-credential-osxkeychain | ||
xcrun codesign --verify --deep --strict --verbose=2 --display bin/docker-credential-osxkeychain | ||
|
||
secretservice: | ||
mkdir -p bin | ||
go build -o bin/docker-credential-secretservice ./secretservice/cmd/ | ||
.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 ${GO_PKG}/credentials.Name=docker-credential-$*" -o $(DESTDIR)/$(BINNAME) ./$*/cmd/ | ||
|
||
pass: | ||
mkdir -p bin | ||
go build -o bin/docker-credential-pass ./pass/cmd/ | ||
# aliases for build-* targets | ||
.PHONY: osxkeychain secretservice pass wincred | ||
osxkeychain: build-osxkeychain | ||
secretservice: build-secretservice | ||
pass: build-pass | ||
wincred: build-wincred | ||
|
||
wincred: | ||
mkdir -p bin | ||
go build -o bin/docker-credential-wincred.exe ./wincred/cmd/ | ||
.PHONY: osxcodesign | ||
osxcodesign: build-osxkeychain | ||
$(eval SIGNINGHASH = $(shell security find-identity -v -p codesigning | grep "Developer ID Application: Docker Inc" | cut -d ' ' -f 4)) | ||
xcrun -log codesign -s $(SIGNINGHASH) --force --verbose bin/build/docker-credential-osxkeychain | ||
xcrun codesign --verify --deep --strict --verbose=2 --display bin/build/docker-credential-osxkeychain | ||
|
||
.PHONY: linuxrelease | ||
linuxrelease: | ||
mkdir -p release | ||
cd bin && tar cvfz ../release/docker-credential-pass-v$(VERSION)-amd64.tar.gz docker-credential-pass | ||
cd bin && tar cvfz ../release/docker-credential-secretservice-v$(VERSION)-amd64.tar.gz docker-credential-secretservice | ||
cd bin && tar cvfz ../release/docker-credential-pass-$(VERSION)-amd64.tar.gz docker-credential-pass | ||
cd bin && tar cvfz ../release/docker-credential-secretservice-$(VERSION)-amd64.tar.gz docker-credential-secretservice | ||
|
||
.PHONY: osxrelease | ||
osxrelease: | ||
mkdir -p release | ||
cd bin && tar cvfz ../release/docker-credential-osxkeychain-v$(VERSION)-amd64.tar.gz docker-credential-osxkeychain | ||
cd bin && tar cvfz ../release/docker-credential-pass-v$(VERSION)-darwin-amd64.tar.gz docker-credential-pass | ||
cd bin && tar cvfz ../release/docker-credential-osxkeychain-$(VERSION)-amd64.tar.gz docker-credential-osxkeychain | ||
cd bin && tar cvfz ../release/docker-credential-pass-$(VERSION)-darwin-amd64.tar.gz docker-credential-pass | ||
|
||
.PHONY: winrelease | ||
winrelease: | ||
mkdir -p release | ||
cd bin && zip ../release/docker-credential-wincred-v$(VERSION)-amd64.zip docker-credential-wincred.exe | ||
cd bin && zip ../release/docker-credential-wincred-$(VERSION)-amd64.zip docker-credential-wincred.exe | ||
|
||
.PHONY: cross | ||
cross: # cross build all supported credential helpers | ||
$(BUILDX_CMD) bake cross | ||
|
||
.PHONY: test | ||
test: | ||
# tests all packages except vendor | ||
go test -v `go list ./... | grep -v /vendor/` | ||
|
||
.PHONY: lint | ||
lint: | ||
docker buildx bake lint | ||
$(BUILDX_CMD) bake lint | ||
|
||
.PHONY: validate-vendor | ||
validate-vendor: | ||
docker buildx bake vendor-validate | ||
$(BUILDX_CMD) bake vendor-validate | ||
|
||
.PHONY: fmt | ||
fmt: | ||
gofmt -s -l `ls **/*.go | grep -v vendor` | ||
|
||
.PHONY: validate | ||
validate: lint validate-vendor fmt | ||
|
||
BUILDIMG:=docker-credential-secretservice-$(VERSION) | ||
.PHONY: deb | ||
deb: | ||
mkdir -p release | ||
docker build -f deb/Dockerfile \ | ||
--build-arg VERSION=$(VERSION) \ | ||
--build-arg DISTRO=xenial \ | ||
--build-arg VERSION=$(patsubst v%,%,$(VERSION)) \ | ||
--build-arg REVISION=$(REVISION) \ | ||
--tag $(BUILDIMG) \ | ||
. | ||
docker run --rm --net=none $(BUILDIMG) tar cf - /release | tar xf - | ||
docker rmi $(BUILDIMG) | ||
|
||
.PHONY: vendor | ||
vendor: | ||
$(eval $@_TMP_OUT := $(shell mktemp -d -t docker-output.XXXXXXXXXX)) | ||
docker buildx bake --set "*.output=type=local,dest=$($@_TMP_OUT)" vendor | ||
$(BUILDX_CMD) bake --set "*.output=type=local,dest=$($@_TMP_OUT)" vendor | ||
rm -rf ./vendor | ||
cp -R "$($@_TMP_OUT)"/* . | ||
rm -rf "$($@_TMP_OUT)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
package credentials | ||
|
||
// Version holds a string describing the current version | ||
const Version = "0.6.4" | ||
var ( | ||
// Name is filled at linking time | ||
Name = "" | ||
|
||
// 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 = "" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters