Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
e58a3d24
Commit
e58a3d24
authored
Aug 09, 2016
by
Eric Chiang
Committed by
GitHub
Aug 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #40 from coreos/inject-version-from-git-data
*: determine version from git
parents
b8e80ffa
e6f34e10
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
20 deletions
+36
-20
Makefile
Makefile
+8
-17
version.go
cmd/poke/version.go
+4
-1
git-version
scripts/git-version
+22
-0
version.go
version/version.go
+2
-2
No files found.
Makefile
View file @
e58a3d24
PROJ
=
"poke"
PROJ
=
poke
ORG_PATH
=
"github.com/coreos"
ORG_PATH
=
github.com/coreos
REPO_PATH
=
"
$(ORG_PATH)
/
$(PROJ)
"
REPO_PATH
=
$(ORG_PATH)
/
$(PROJ)
export
PATH
:=
$(PWD)
/bin:
$(PATH)
export
PATH
:=
$(PWD)
/bin:
$(PATH)
export
GOBIN
=
$(PWD)
/bin
export
GOBIN
=
$(PWD)
/bin
export
GO15VENDOREXPERIMENT
=
1
export
GO15VENDOREXPERIMENT
=
1
export
CGO_ENABLED
:=
0
LD_FLAGS
=
"-w -X
$(REPO_PATH)
/version.Version=
$(
shell
./scripts/git-version
)
"
GOOS
=
$(
shell
go
env
GOOS
)
GOOS
=
$(
shell
go
env
GOOS
)
GOARCH
=
$(
shell
go
env
GOARCH
)
GOARCH
=
$(
shell
go
env
GOARCH
)
COMMIT
=
$(
shell
git rev-parse HEAD
)
# check if the current commit has a matching tag
TAG
=
$(
shell
git describe
--exact-match
--abbrev
=
0
--tags
$(COMMIT)
2> /dev/null
||
true
)
ifeq
($(TAG),)
VERSION
=
$(TAG)
else
VERSION
=
$(COMMIT)
endif
build
:
bin/poke bin/example-app
build
:
bin/poke bin/example-app
bin/poke
:
FORCE
bin/poke
:
FORCE
@
go
install
$(REPO_PATH)
/cmd/poke
@
go
install
-ldflags
$(LD_FLAGS)
$(REPO_PATH)
/cmd/poke
bin/example-app
:
FORCE
bin/example-app
:
FORCE
@
go
install
$(REPO_PATH)
/cmd/example-app
@
go
install
-ldflags
$(LD_FLAGS)
$(REPO_PATH)
/cmd/example-app
test
:
test
:
@
go
test
$(
shell
go list ./... |
grep
-v
'/vendor/'
)
@
go
test
$(
shell
go list ./... |
grep
-v
'/vendor/'
)
...
...
cmd/poke/version.go
View file @
e58a3d24
...
@@ -11,8 +11,11 @@ import (
...
@@ -11,8 +11,11 @@ import (
func
commandVersion
()
*
cobra
.
Command
{
func
commandVersion
()
*
cobra
.
Command
{
return
&
cobra
.
Command
{
return
&
cobra
.
Command
{
Use
:
"version"
,
Use
:
"version"
,
Short
:
"Print the version and exit"
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
fmt
.
Printf
(
`v%s %s %s %s
fmt
.
Printf
(
`dex Version:%s
Go Version: %s
Go OS/ARCH: %s %s
`
,
version
.
Version
,
runtime
.
Version
(),
runtime
.
GOOS
,
runtime
.
GOARCH
)
`
,
version
.
Version
,
runtime
.
Version
(),
runtime
.
GOOS
,
runtime
.
GOARCH
)
},
},
}
}
...
...
scripts/git-version
0 → 100755
View file @
e58a3d24
#!/bin/bash -e
# parse the current git commit hash
COMMIT
=
`
git rev-parse HEAD
`
# check if the current commit has a matching tag
TAG
=
$(
git describe
--exact-match
--abbrev
=
0
--tags
${
COMMIT
}
2> /dev/null
||
true
)
# use the matching tag as the version, if available
if
[
-z
"
$TAG
"
]
;
then
VERSION
=
$COMMIT
else
VERSION
=
$TAG
fi
# check for changed files (not untracked files)
if
[
-n
"
$(
git diff
--shortstat
2> /dev/null |
tail
-n1
)
"
]
;
then
VERSION
=
"
${
VERSION
}
-dirty"
fi
echo
$VERSION
\ No newline at end of file
version/version.go
View file @
e58a3d24
// Package version contains version information for this app.
// Package version contains version information for this app.
package
version
package
version
// Version is
the semantic version of the server
.
// Version is
set by the build scripts
.
const
Version
=
"0.1.0
"
var
Version
=
"was not built properly
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment