Skip to content

Commit

Permalink
Merge pull request #29 from banzaicloud/goreleaser
Browse files Browse the repository at this point in the history
Finalize binary release process
  • Loading branch information
sagikazarmark authored Jan 20, 2019
2 parents 8ff92d7 + 80ef05b commit 856c523
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 9 deletions.
35 changes: 35 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,44 @@ jobs:
paths:
- bin/

-
persist_to_workspace:
root: .
paths: .

-
store_test_results:
path: build/test_results/
-
store_artifacts:
path: build/

release:
docker:
-
image: circleci/golang:1.11

working_directory: /go/src/github.com/banzaicloud/banzai-cli

steps:
-
attach_workspace:
at: .

-
run:
name: Release
command: make release

workflows:
version: 2
build:
jobs:
- build
-
release:
filters:
tags:
only: /^v?\d+\.\d+\.\d+(-\S*)?$/
branches:
ignore: /.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/bin/
/build/
/dist/
/vendor/

# IDE integration
Expand Down
12 changes: 4 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
builds:
-
main: ./cmd/banzai
binary: banzai
env:
- CGO_ENABLED=0
ldflags: "-s -w -X main.version={{ .Version }} -X main.commitHash={{ .ShortCommit }} -X main.buildDate={{ .Date }}"
goos:
- linux
- darwin
- windows
goarch:
- amd64

archive:
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"

checksum:
name_template: 'checksums.txt'

brew:
github:
owner: banzaicloud
description: Command-line interface for Banzai Cloud products
description: Command-line interface for Banzai Cloud Pipeline platform
homepage: https://banzaicloud.com/
test: |
system "#{bin}/banzai-cli --version"
system "#{bin}/banzai --version"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BUILD_PACKAGE = ${PACKAGE}/cmd/banzai
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD)
COMMIT_HASH ?= $(shell git rev-parse --short HEAD 2>/dev/null)
BUILD_DATE ?= $(shell date +%FT%T%z)
LDFLAGS += -X main.Version=${VERSION} -X main.CommitHash=${COMMIT_HASH} -X main.BuildDate=${BUILD_DATE}
LDFLAGS += -X main.version=${VERSION} -X main.commitHash=${COMMIT_HASH} -X main.buildDate=${BUILD_DATE}
export CGO_ENABLED ?= 0
export GOOS = $(shell go env GOOS)
ifeq (${VERBOSE}, 1)
Expand Down
9 changes: 9 additions & 0 deletions cmd/banzai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ package main

import "github.com/banzaicloud/banzai-cli/cmd"

// Provisioned by ldflags
// nolint: gochecknoglobals
var (
version string
commitHash string
buildDate string
)

func main() {
cmd.Init(version, commitHash, buildDate)
cmd.Execute()
}
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ func preRun(cmd *cobra.Command, args []string) {
}
}

// Init is a temporary function to set initial values in the root cmd.
func Init(version string, commitHash string, buildDate string) {
rootCmd.Version = version

rootCmd.SetVersionTemplate(fmt.Sprintf("Banzai CLI version %s (%s) built on %s\n", version, commitHash, buildDate))
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
Expand Down

0 comments on commit 856c523

Please sign in to comment.