Skip to content

Commit

Permalink
use goreleaser to release binaries with signed checksums to GH
Browse files Browse the repository at this point in the history
Version is default goreleaser and not nicely set because of goreleaser/goreleaser#985

Signed-off-by: Sandor Szuecs <[email protected]>
  • Loading branch information
szuecs committed Mar 16, 2019
1 parent 34c9451 commit 1ddf3ce
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 29 deletions.
56 changes: 56 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
project_name: binary-patch

release:
github:
owner: szuecs
name: binary-patch

builds:
- main : ./cmd/binary-patch/
binary: binary-patch
goos:
- darwin
- linux
- windows
goarch:
- amd64
env:
- CGO_ENABLED=0
- GO111MODULE=on
- VERSION=$(git describe --tags --always --dirty)
#ldflags: -X main.version={{ .Version }} # works
#ldflags: -X main.version={{ .Env.VERSION }}
#ldflags: -X main.version=$(VERSION) -X main.date=$(shell date -u '+%Y-%m-%d_%I:%M%p') -X main.commit=$(shell git rev-parse HEAD)

- main : ./cmd/binary-patch-server/
binary: binary-patch-server
goos:
- darwin
- linux
- windows
goarch:
- amd64
#ldflags: -X main.version=$(VERSION) -X main.date=$(shell date -u '+%Y-%m-%d_%I:%M%p') -X main.commit=$(shell git rev-parse HEAD)
env:
- CGO_ENABLED=0
- GO111MODULE=on
- VERSION=$(git describe --tags --always --dirty)

archive:
files:
- README.md
- LICENSE

checksum:
name_template: 'checksums.txt'

changelog:
sort: asc
filters:
exclude:
- '^doc'
- '^test'

sign:
artifacts: checksum
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ IMAGE ?= pierone.stups.zalan.do/teapot/$(BINARY)
TAG ?= $(VERSION)
DOCKERFILE ?= Dockerfile
BUILD_FLAGS ?= -v
LDFLAGS ?= -X main.Version=$(VERSION) -X main.Buildstamp=$(shell date -u '+%Y-%m-%d_%I:%M:%S%p') -X main.Githash=$(shell git rev-parse HEAD)
LDFLAGS ?= -X main.version=$(VERSION) -X main.date=$(shell date -u '+%Y-%m-%d_%I:%M%p') -X main.commit=$(shell git rev-parse HEAD)
GITHEAD = $(shell git rev-parse --short HEAD)
GITURL = $(shell git config --get remote.origin.url)
GITSTATUS = $(shell git status --porcelain || echo "no changes")
Expand Down Expand Up @@ -35,7 +35,7 @@ check:
GO111MODULE=$(GO111) go vet -v $(GOPKGS)

build.server:
GO111MODULE=$(GO111) go build -o build/binary-patch-server ./cmd/binary-patch-server
GO111MODULE=$(GO111) go build -o build/binary-patch-server $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" ./cmd/binary-patch-server

build.local: build/$(BINARY)
build.linux: build/linux/$(BINARY)
Expand Down
25 changes: 10 additions & 15 deletions cmd/binary-patch-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@ import (
"golang.org/x/oauth2"
)

// Buildstamp is used to store the timestamp of the build
var Buildstamp = "Not set"
var (
version string = ""
commit string = ""
date string = ""

// Githash is used to store the commit hash of the build
var Githash = "Not set"

// Version is used to store the tagged version of the build
var Version = "Not set"

// flag variables
var version bool

var serverConfig *conf.Config
versionflag bool
serverConfig *conf.Config
)

func init() {
bin := path.Base(os.Args[0])
Expand All @@ -45,7 +40,7 @@ Example:
os.Exit(2)
}

flag.BoolVar(&version, "version", false, "Print version and exit")
flag.BoolVar(&versionflag, "version", false, "Print version and exit")
flag.BoolVar(&serverConfig.DebugEnabled, "debug", serverConfig.DebugEnabled, "Enable debug output")
flag.BoolVar(&serverConfig.Oauth2Enabled, "oauth", serverConfig.Oauth2Enabled, "Enable OAuth2")
flag.BoolVar(&serverConfig.ProfilingEnabled, "profile", serverConfig.ProfilingEnabled, "Enable profiling.")
Expand All @@ -61,12 +56,12 @@ Example:
}

func main() {
if version {
if versionflag {
fmt.Printf(`%s Version: %s
================================
Buildtime: %s
GitHash: %s
`, path.Base(os.Args[0]), Version, Buildstamp, Githash)
`, path.Base(os.Args[0]), version, date, commit)
os.Exit(0)
}

Expand Down
22 changes: 10 additions & 12 deletions cmd/binary-patch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import (

"github.com/szuecs/binary-patch/patchclient"

"gopkg.in/alecthomas/kingpin.v2"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
//Buildstamp is used for storing the timestamp of the build
Buildstamp string = "Not set"
//Githash is used for storing the commit hash of the build
Githash string = "Not set"
// Version is used to store the tagged version of the build
Version string = "Not set"
version string = ""
commit string = ""
date string = ""

// public key to verify signed updates
publicKey []byte
)
Expand Down Expand Up @@ -62,31 +60,31 @@ func main() {
================================
Buildtime: %s
GitHash: %s
`, path.Base(os.Args[0]), Version, Buildstamp, Githash)
`, path.Base(os.Args[0]), version, date, commit)
os.Exit(0)
case update.FullCommand():
pc := patchclient.NewInsecurePatchClient(*baseUpdateURL, Version)
pc := patchclient.NewInsecurePatchClient(*baseUpdateURL, version)
err := pc.UnsignedNotVerifiedUpdate()
if err != nil {
log.Fatalf("Failed to update: %v", err)
}

case patchUpdate.FullCommand():
pc := patchclient.NewInsecurePatchClient(*basePatchUpdateURL, Version)
pc := patchclient.NewInsecurePatchClient(*basePatchUpdateURL, version)
err := pc.UnsignedNotVerifiedPatchUpdate()
if err != nil {
log.Fatalf("Failed to update: %v", err)
}

case signedUpdate.FullCommand():
pc := patchclient.NewPatchClient(*baseSignedUpdateURL, Version, publicKey)
pc := patchclient.NewPatchClient(*baseSignedUpdateURL, version, publicKey)
err := pc.SignedVerifiedUpdate()
if err != nil {
log.Fatalf("Failed to update: %v", err)
}

case signedPatchUpdate.FullCommand():
pc := patchclient.NewPatchClient(*baseSignedPatchUpdateURL, Version, publicKey)
pc := patchclient.NewPatchClient(*baseSignedPatchUpdateURL, version, publicKey)
err := pc.SignedVerifiedPatchUpdate()
if err != nil {
log.Fatalf("Failed to update: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ require (
github.com/gin-gonic/gin v1.3.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
github.com/json-iterator/go v1.1.6 // indirect
github.com/kr/binarydist v0.1.0
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.3.0 // indirect
github.com/szuecs/gin-glog v1.1.1
github.com/szuecs/gin-gomonitor v1.1.3
github.com/ugorji/go/codec v0.0.0-20190316083543-95c34d148dff // indirect
github.com/zalando/gin-oauth2 v1.5.2
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
gopkg.in/mcuadros/go-monitor.v1 v1.1.1
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0
Expand Down
19 changes: 19 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5Vpd
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs=
Expand All @@ -15,12 +17,23 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/kr/binarydist v0.1.0 h1:6kAoLA9FMMnNGSehX0s1PdjbEaACznAv/W219j2uvyo=
github.com/kr/binarydist v0.1.0/go.mod h1:DY7S//GCoz1BCd0B0EVrinCKAZN3pXe+MDaIZbXQVgM=
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/szuecs/gin-glog v1.1.1 h1:YwewjwcnxTVJeB6U7zcJ82FohUzxR4wzSTuspkj6BRE=
github.com/szuecs/gin-glog v1.1.1/go.mod h1:eFFtHjaaO5lc0ich5AZPMsu3i8rn1TvwmpQnJb+3HP4=
github.com/szuecs/gin-gomonitor v1.1.3 h1:osvldnORsCEsA6XyDiW80/apKOMkqwvYLniDVBd04Ow=
Expand All @@ -36,13 +49,19 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/mcuadros/go-monitor.v1 v1.1.1 h1:n03FeVN561iWj1nQcmOW4NBG8eUk/TEErbeSD2rp+wM=
Expand Down

0 comments on commit 1ddf3ce

Please sign in to comment.