Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
e6f34e10
Commit
e6f34e10
authored
8 years ago
by
Eric Chiang
Browse files
Options
Downloads
Patches
Plain Diff
*: determine version from git
parent
b8e80ffa
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+8
-17
8 additions, 17 deletions
Makefile
cmd/poke/version.go
+5
-2
5 additions, 2 deletions
cmd/poke/version.go
scripts/git-version
+21
-0
21 additions, 0 deletions
scripts/git-version
version/version.go
+2
-2
2 additions, 2 deletions
version/version.go
with
36 additions
and
21 deletions
Makefile
+
8
−
17
View file @
e6f34e10
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/'
)
...
...
This diff is collapsed.
Click to expand it.
cmd/poke/version.go
+
5
−
2
View file @
e6f34e10
...
@@ -10,9 +10,12 @@ import (
...
@@ -10,9 +10,12 @@ 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
)
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
scripts/git-version
0 → 100755
+
21
−
0
View file @
e6f34e10
#!/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
This diff is collapsed.
Click to expand it.
version/version.go
+
2
−
2
View file @
e6f34e10
// 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
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment