Skip to content

Commit

Permalink
Versioning forced on release script
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Sep 16, 2015
1 parent e4c96e0 commit 15840c0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
27 changes: 3 additions & 24 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,6 @@ const (
OAUTH_PREFIX string = "oauth-data."
)

func VERSION() string {
var maj, min, patch, rel string
maj = strconv.Itoa(MAJOR)
min = strconv.Itoa(MINOR)
patch = strconv.Itoa(PATCH)
rel = strconv.Itoa(RELEASE)

v := strings.Join([]string{
maj,
min,
patch,
rel,
}, ".")

if SUFFIX != "" {
v = strings.Join([]string{v, SUFFIX}, ".")
}

return v
}

// Display configuration options
func displayConfig() {
log.Info("--> Listening on port: ", config.ListenPort)
Expand Down Expand Up @@ -646,7 +625,7 @@ func init() {
--as-version=<version> The version number to use when inserting
`

arguments, err := docopt.Parse(usage, nil, true, VERSION(), false, false)
arguments, err := docopt.Parse(usage, nil, true, VERSION, false, false)
if err != nil {
log.Warning("Error while parsing arguments: ", err)
}
Expand Down Expand Up @@ -841,7 +820,7 @@ func main() {
go s.Serve(l)
displayConfig()
} else {
log.Printf("Gateway started (%v)", VERSION())
log.Printf("Gateway started (%v)", VERSION)
go http.Serve(l, nil)
displayConfig()
}
Expand All @@ -867,7 +846,7 @@ func main() {
go s.Serve(l)
displayConfig()
} else {
log.Printf("Gateway started (%v)", VERSION())
log.Printf("Gateway started (%v)", VERSION)
displayConfig()
http.Serve(l, nil)
}
Expand Down
23 changes: 22 additions & 1 deletion utils/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,28 @@

# Super hacky release script

VERSION=$1
# ----- SET THE VERSION NUMBER -----
CURRENTVERS=$(perl -n -e'/v(\d+).(\d+).(\d+).(\d+)/'' && print "v$1\.$2\.$3\.$4"' version.go)

echo "Current version is: " $CURRENTVERS

echo -n "Major version [ENTER]: "
read maj
echo -n "Minor version [ENTER]: "
read min
echo -n "Patch version [ENTER]: "
read patch
echo -n "Release version [ENTER]: "
read rel

NEWVERSION="v$maj.$min.$patch.$rel"
echo "Setting new version in source: " $NEWVERSION

perl -pi -e 's/var VERSION string = \"(.*)\"/var VERSION string = \"'$NEWVERSION'\"/g' version.go

# ----- END VERSION SETTING -----

VERSION=$NEWVERSION
SOURCEBIN=tyk
SOURCEBINPATH=~/tyk
i386BINDIR=$SOURCEBINPATH/build/i386/tyk.linux.i386-$VERSION
Expand Down
18 changes: 18 additions & 0 deletions utils/set-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
CURRENTVERS=$(perl -n -e'/v(\d+).(\d+).(\d+).(\d+)/'' && print "v$1\.$2\.$3\.$4"' version.go)

echo "Current version is: " $CURRENTVERS

echo -n "Major version [ENTER]: "
read maj
echo -n "Minor version [ENTER]: "
read min
echo -n "Patch version [ENTER]: "
read patch
echo -n "Release version [ENTER]: "
read rel

NEWVERSION="v$maj.$min.$patch.$rel"
echo "Setting new version in source: " $NEWVERSION

perl -pi -e 's/var VERSION string = \"(.*)\"/var VERSION string = \"'$NEWVERSION'\"/g' version.go
6 changes: 1 addition & 5 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
package main

var MAJOR int = 1
var MINOR int = 8
var PATCH int = 3
var RELEASE int = 2
var SUFFIX string = ""
var VERSION string = "v1.8.3.3"

0 comments on commit 15840c0

Please sign in to comment.