diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c9e333..9cb3c54 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,6 +48,8 @@ jobs: path: test-results/ - store_artifacts: path: test-results/ + - store_artifacts: + path: /go/bin/vault-plugin-splunk - save_cache: name: Saving Cache for vendor @@ -59,3 +61,38 @@ jobs: key: build-cache-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_BUILD_NUM }} paths: - /tmp/go/cache + + - persist_to_workspace: + root: /go/bin + # Must be relative path from root + paths: + - vault-plugin-splunk + + publish-github-release: + docker: + - image: cibuilds/github:0.10 + steps: + - attach_workspace: + at: ./artifacts + - run: + name: "Publish Release on GitHub" + command: | + VERSION=$(artifacts/vault-plugin-splunk -version) + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/ + +workflows: + version: 2 + tagged-build: + jobs: + - build: + filters: + tags: + only: /^\d+\.\d+\.\d+$/ + - publish-github-release: + requires: + - build + filters: + branches: + ignore: /.*/ + tags: + only: /^\d+\.\d+\.\d+$/ diff --git a/Makefile b/Makefile index c302d17..87ee0cb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.1.0 +VERSION := $(shell git describe --tags --always 2>/dev/null) SHORT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo dev) GO_VERSION := $(shell go version | awk '{ print $$3}' | sed 's/^go//') diff --git a/cmd/vault-plugin-splunk/main.go b/cmd/vault-plugin-splunk/main.go index 4dd04a4..bf09a38 100644 --- a/cmd/vault-plugin-splunk/main.go +++ b/cmd/vault-plugin-splunk/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/hashicorp/go-hclog" @@ -10,13 +11,26 @@ import ( splunk "github.com/splunk/vault-plugin-splunk" ) +var ( + version string + goVersion string +) + func main() { apiClientMeta := &pluginutil.APIClientMeta{} flags := apiClientMeta.FlagSet() + printVersion := flags.Bool("version", false, "Prints version") + // all plugins ignore Parse errors // #nosec G104 flags.Parse(os.Args[1:]) + switch { + case *printVersion: + fmt.Printf("%s %s (golang %s)\n", os.Args[0], version, goVersion) + os.Exit(0) + } + tlsConfig := apiClientMeta.GetTLSConfig() tlsProviderFunc := pluginutil.VaultPluginTLSProvider(tlsConfig)