diff --git a/Makefile b/Makefile index a7882d6c0..19e405186 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ js: cd cmd/droned/assets && find js -name "*.js" ! -name '.*' ! -name "main.js" -exec cat {} \; > js/main.js build: - cd cmd/drone && go build -o ../../bin/drone + cd cmd/drone && go build -ldflags "-X main.version $(SHA)" -o ../../bin/drone cd cmd/droned && go build -ldflags "-X main.version $(SHA)" -o ../../bin/droned test: $(PKGS) diff --git a/cmd/drone/drone.go b/cmd/drone/drone.go index ea5d98652..0e7429ce8 100644 --- a/cmd/drone/drone.go +++ b/cmd/drone/drone.go @@ -39,6 +39,10 @@ var ( // displays the help / usage if True help = flag.Bool("h", false, "") + + // version number, currently deterined by the + // git revision number (sha) + version string ) func init() { @@ -103,6 +107,10 @@ func main() { path = filepath.Join(path, ".drone.yml") vet(path) + // print the version / revision number + case args[0] == "version" && len(args) == 1: + println(version) + // print the help message case args[0] == "help" && len(args) == 1: flag.Usage()