Skip to content

Commit

Permalink
Merge pull request #356 from sensu/alpha
Browse files Browse the repository at this point in the history
Add prerelease flag for specifying alpha/beta/RC builds
  • Loading branch information
jamesdphillips committed Sep 1, 2017
2 parents c8aaca1 + cb9ca23 commit c057e89
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $(shell mkdir -p out)
# FPM
##
VERSION=$(shell cat version/version.txt)
PRERELEASE=$(shell cat version/prerelease.txt)
ITERATION=$(shell cat version/iteration.txt)
ARCHITECTURE=$(GOARCH)
DESCRIPTION="A monitoring framework that aims to be simple, malleable, and scalable."
Expand All @@ -34,7 +35,7 @@ URL="https://sensuapp.org"
BIN_SOURCE_DIR=target/$(GOOS)-$(GOARCH)

FPM_FLAGS = \
--version $(VERSION) \
--version $(VERSION)-$(PRERELEASE) \
--iteration $(ITERATION) \
--url $(URL) \
--license $(LICENSE) \
Expand Down
2 changes: 1 addition & 1 deletion agent/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func newVersionCommand() *cobra.Command {
Short: "Show the sensu-agent version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("sensu-agent version %s, build %s, built %s\n",
version.Version,
version.Semver(),
version.BuildSHA,
version.BuildDate,
)
Expand Down
2 changes: 1 addition & 1 deletion backend/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func newVersionCommand() *cobra.Command {
Short: "Show the sensu-backend version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("sensu-backend version %s, build %s, built %s\n",
version.Version,
version.Semver(),
version.BuildSHA,
version.BuildDate,
)
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ build_binary () {
local outfile="target/${goos}-${goarch}/${cmd_name}"

local version=$(cat version/version.txt)
local iteration=$(cat version/iteration.txt)
local prerelease=$(cat version/prerelease.txt)
local build_date=$(date +"%Y-%m-%dT%H:%M:%S%z")
local build_sha=$(git rev-parse HEAD)

local version_pkg="github.com/sensu/sensu-go/version"
local ldflags="-X $version_pkg.Version=${version}"
local ldflags+=" -X $version_pkg.Iteration=${iteration}"
local ldflags=" -X $version_pkg.Version=${version}"
local ldflags+=" -X $version_pkg.PreReleaseIdentifier=${prerelease}"
local ldflags+=" -X $version_pkg.BuildDate=${build_date}"
local ldflags+=" -X $version_pkg.BuildSHA=${build_sha}"

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newVersionCommand() *cobra.Command {
Short: "Show the sensu-ctl version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("sensu-ctl version %s, build %s, built %s\n",
version.Version,
version.Semver(),
version.BuildSHA,
version.BuildDate,
)
Expand Down
1 change: 1 addition & 0 deletions version/prerelease.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alpha.1
19 changes: 19 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,28 @@ var (
// Version stores the version of the current build (e.g. 2.0.0)
Version string

// PreReleaseIdentifier stores the pre-release identifier of the current build (eg. beta-2)
PreReleaseIdentifier string

// BuildDate stores the timestamp of the build (e.g. 2017-07-31T13:11:15-0700)
BuildDate string

// BuildSHA stores the git sha of the build (e.g. 8673bed0a9705083987b9ecbbc1cc0758df13dd2)
BuildSHA string
)

// Semver returns full semantic versioning compatible identifier.
// Format: VERSION-PRERELEASE+METADATA
func Semver() string {
version := Version
if PreReleaseIdentifier != "" {
version = version + "-" + PreReleaseIdentifier
}

gitSHA := BuildSHA
if len(gitSHA) > 7 {
gitSHA = gitSHA[:7]
}

return version + "#" + gitSHA
}
2 changes: 1 addition & 1 deletion version/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0p1
2.0.0

0 comments on commit c057e89

Please sign in to comment.