File tree Expand file tree Collapse file tree 4 files changed +75
-2
lines changed
Expand file tree Collapse file tree 4 files changed +75
-2
lines changed Original file line number Diff line number Diff line change 11ca-certificates.crt
22auth_server
33Godeps /
4+ version. *
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ MAKEFLAGS += --warn-undefined-variables
22IMAGE ?= cesanta/docker_auth
33COMPRESS_BINARY ?= false
44CA_BUNDLE = /etc/ssl/certs/ca-certificates.crt
5+ VERSION = $(shell cat version.txt)
56
67BUILDER_IMAGE ?= centurylink/golang-builder
78BUILDER_IMAGE_EXTRA-build-cross = -cross
@@ -15,24 +16,31 @@ local: build-local
1516
1617update-deps :
1718 go get -v -u -f github.com/tools/godep github.com/jteeuwen/go-bindata/...
19+ go generate ./...
1820
1921godep :
2022 godep save
2123
2224build-local : update-deps
23- go generate ./...
2425 go build
2526
2627ca-certificates.crt :
2728 cp $(CA_BUNDLE ) .
2829
2930docker-build :
3031 docker run --rm -v $(PWD ) :/src -e COMPRESS_BINARY=$(COMPRESS_BINARY ) $(BUILDER_OPTS-$@ ) $(BUILDER_IMAGE )$(BUILDER_IMAGE_EXTRA-$@ ) $(IMAGE )
32+ @echo === Built version $(VERSION ) ===
3133
3234build build-cross : update-deps godep ca-certificates.crt docker-build
3335
36+ docker-tag :
37+ docker tag $(IMAGE ) :latest $(IMAGE ) :$(VERSION )
38+
3439docker-tag-% :
35- docker tag -f $(IMAGE ) :latest $(IMAGE ) :$*
40+ docker tag $(IMAGE ) :latest $(IMAGE ) :$*
41+
42+ docker-push :
43+ docker push $(IMAGE ) :latest $(IMAGE ) :$(VERSION )
3644
3745docker-push-% : docker-tag-%
3846 docker push $(IMAGE ) :$*
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import datetime
4+ import sys
5+
6+ # Debian/Ubuntu: apt-get install python-git
7+ # PIP: pip install GitPython
8+ import git
9+
10+ repo = git .Repo ('.' , search_parent_directories = True )
11+
12+
13+ def get_tag_for_commit (repo , commit ):
14+ for tag in repo .tags :
15+ if tag .commit == commit :
16+ return tag .name
17+ return None
18+
19+
20+ if repo .head .is_detached :
21+ branch_or_tag = get_tag_for_commit (repo , repo .head .commit )
22+ if branch_or_tag is None :
23+ branch_or_tag = '?'
24+ else :
25+ branch_or_tag = repo .active_branch
26+
27+ dirty = repo .is_dirty ()
28+
29+ ts = datetime .datetime .utcnow ()
30+ build_id = '%s/%s@%s%s' % (ts .strftime ('%Y%m%d-%H%M%S' ),
31+ branch_or_tag ,
32+ str (repo .head .commit )[:8 ],
33+ '+' if dirty else '' )
34+
35+ version = None
36+ if not dirty :
37+ version = get_tag_for_commit (repo , repo .head .commit )
38+ if version is None :
39+ version = ts .strftime ('%Y%m%d%H%M%S' )
40+
41+
42+ if len (sys .argv ) == 1 or sys .argv [1 ] == '-' :
43+ f = sys .stdout
44+ else :
45+ f = open (sys .argv [1 ], 'w' )
46+
47+ with open ('version.go' , 'w' ) as f :
48+ f .write ("""\
49+ package main
50+
51+ const (
52+ \t Version = "{version}"
53+ \t BuildId = "{build_id}"
54+ )
55+ """ .format (version = version , build_id = build_id ))
56+
57+ with open ('version.txt' , 'w' ) as f :
58+ f .write (version )
59+
60+ f .close ()
Original file line number Diff line number Diff line change 1414 limitations under the License.
1515*/
1616
17+ //go:generate ./gen_version.py
18+
1719package main // import "github.com/cesanta/docker_auth/auth_server"
1820
1921import (
@@ -158,6 +160,8 @@ func main() {
158160 rand .Seed (time .Now ().UnixNano ())
159161 glog .CopyStandardLogTo ("INFO" )
160162
163+ glog .Infof ("docker_auth %s build %s" , Version , BuildId )
164+
161165 cf := flag .Arg (0 )
162166 if cf == "" {
163167 glog .Exitf ("Config file not specified" )
You can’t perform that action at this time.
0 commit comments