Skip to content

Commit

Permalink
core: versioned automated builds
Browse files Browse the repository at this point in the history
* core: figure out a process to autobuild releases - closes ory#210
* cmd: add version command - closes ory#218
  • Loading branch information
arekkas committed Sep 1, 2016
1 parent d5c267f commit 76c23f8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ vendor/
.hydra.yml
cover.out
output/
_book/
_book/
dist/
28 changes: 26 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go:
- 1.7

install:
- go get github.com/mattn/goveralls golang.org/x/tools/cmd/cover github.com/pierrre/gotestcover github.com/Masterminds/glide
- go get github.com/mattn/goveralls golang.org/x/tools/cmd/cover github.com/pierrre/gotestcover github.com/Masterminds/glide github.com/mitchellh/gox github.com/tcnksm/ghr
- git clone https://github.com/docker-library/official-images.git ~/official-images
- glide install
- go install github.com/ory-am/hydra
Expand All @@ -28,4 +28,28 @@ script:
- docker run -d hydra-travis-ci
- $GOPATH/bin/hydra host --dangerous-auto-logon &
- while ! echo exit | nc localhost 4444; do sleep 1; done
- $GOPATH/bin/hydra token client --skip-tls-verify
- $GOPATH/bin/hydra token client --skip-tls-verify

after_success:
- gox -ldflags "-s \
-X main.Version=`git describe --tags` \
-X main.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` \
-X main.GitHash=`git rev-parse HEAD`" -output "dist/{{.Dir}}-{{.OS}}-{{.Arch}}"
# - ghr --username arekkas --token $GITHUB_TOKEN --replace --prerelease --debug pre-release dist/

deploy:
provider: releases
api_key: $GITHUB_TOKEN
file:
- dist/hydra-darwin-386
- dist/hydra-darwin-amd64
- dist/hydra-freebsd-386
- dist/hydra-freebsd-amd64
- dist/hydra-linux-arm
- dist/hydra-netbsd-arm
- dist/hydra-openbsd-386
- dist/hydra-windows-amd64.exe
skip_cleanup: true
on:
tags: true
go: 1.7
6 changes: 3 additions & 3 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func TestExecute(t *testing.T) {
{args: []string{"clients", "create", "--id", "foobarbaz"}},
{args: []string{"clients", "create", "--id", "foobarbaz", "--dry"}},
{args: []string{"clients", "delete", "foobarbaz"}},
{args: []string{"keys", "create", "foo", "-a", "RS256"}},
{args: []string{"keys", "create", "foo", "-a", "RS256", "--dry"}},
{args: []string{"keys", "create", "foo", "-a", "ES521"}},
{args: []string{"keys", "create", "foo", "-a", "HS256"}},
{args: []string{"keys", "create", "foo", "-a", "HS256", "--dry"}},
{args: []string{"keys", "create", "foo", "-a", "HS256"}},
{args: []string{"keys", "get", "foo"}},
{args: []string{"keys", "delete", "foo"}},
{args: []string{"connections", "create", "google", "localuser", "googleuser"}},
Expand Down
29 changes: 29 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"time"
)

var (
Version = "dev-master"
BuildTime = time.Now().String()
GitHash = "undefined"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Display this binary's version, build time and git hash of this build",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Version: %s\n", Version)
fmt.Printf("Git Hash: %s\n", GitHash)
fmt.Printf("Build Time: %s\n", BuildTime)
},
}

func init() {
RootCmd.AddCommand(versionCmd)
}

0 comments on commit 76c23f8

Please sign in to comment.