Merge pull request #1553 from bradrydzewski/master

move version to package [CI SKIP]
This commit is contained in:
Brad Rydzewski 2016-03-30 00:57:32 -07:00
commit db8fd7f098
4 changed files with 25 additions and 14 deletions

View file

@ -37,7 +37,7 @@ build:
go build go build
build_static: build_static:
go build --ldflags '-extldflags "-static" -X main.build=$(CI_BUILD_NUMBER)' -o drone_static go build --ldflags '-extldflags "-static" -X github.com/drone/drone/version.VersionDev=$(CI_BUILD_NUMBER)' -o drone_static
test: test:
go test -cover $(PACKAGES) go test -cover $(PACKAGES)

View file

@ -16,10 +16,6 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
// build revision number populated by the continuous
// integration server at compile time.
var build string = "custom"
var ( var (
dotenv = flag.String("config", ".env", "") dotenv = flag.String("config", ".env", "")
debug = flag.Bool("debug", false, "") debug = flag.Bool("debug", false, "")
@ -49,7 +45,7 @@ func main() {
server_ := server.Load(env) server_ := server.Load(env)
server_.Run( server_.Run(
router.Load( router.Load(
header.Version(build), header.Version,
cache.Default(), cache.Default(),
context.SetStore(store_), context.SetStore(store_),
context.SetRemote(remote_), context.SetRemote(remote_),

View file

@ -4,11 +4,10 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/drone/drone/version"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
var version string
// NoCache is a middleware function that appends headers // NoCache is a middleware function that appends headers
// to prevent the client from caching the HTTP response. // to prevent the client from caching the HTTP response.
func NoCache(c *gin.Context) { func NoCache(c *gin.Context) {
@ -52,10 +51,7 @@ func Secure(c *gin.Context) {
// Version is a middleware function that appends the Drone // Version is a middleware function that appends the Drone
// version information to the HTTP response. This is intended // version information to the HTTP response. This is intended
// for debugging and troubleshooting. // for debugging and troubleshooting.
func Version(version string) gin.HandlerFunc { func Version(c *gin.Context) {
return func(c *gin.Context) { c.Header("X-DRONE-VERSION", version.Version)
c.Set("version", "0.4.0-beta+"+version)
c.Header("X-DRONE-VERSION", "0.4.0-beta+"+version)
c.Next() c.Next()
} }
}

19
version/version.go Normal file
View file

@ -0,0 +1,19 @@
package version
import "fmt"
const (
// VersionMajor is for an API incompatible changes
VersionMajor = 0
// VersionMinor is for functionality in a backwards-compatible manner
VersionMinor = 4
// VersionPatch is for backwards-compatible bug fixes
VersionPatch = 1
// VersionDev indicates development branch. Releases will be empty string.
VersionDev = "dev"
)
// Version is the specification version that the package types support.
var Version = fmt.Sprintf("%d.%d.%d+%s",
VersionMajor, VersionMinor, VersionPatch, VersionDev)