Skip to content

Commit 1ddf3ce

Browse files
committed
use goreleaser to release binaries with signed checksums to GH
Version is default goreleaser and not nicely set because of goreleaser/goreleaser#985 Signed-off-by: Sandor Szuecs <[email protected]>
1 parent 34c9451 commit 1ddf3ce

File tree

6 files changed

+102
-29
lines changed

6 files changed

+102
-29
lines changed

.goreleaser.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
project_name: binary-patch
3+
4+
release:
5+
github:
6+
owner: szuecs
7+
name: binary-patch
8+
9+
builds:
10+
- main : ./cmd/binary-patch/
11+
binary: binary-patch
12+
goos:
13+
- darwin
14+
- linux
15+
- windows
16+
goarch:
17+
- amd64
18+
env:
19+
- CGO_ENABLED=0
20+
- GO111MODULE=on
21+
- VERSION=$(git describe --tags --always --dirty)
22+
#ldflags: -X main.version={{ .Version }} # works
23+
#ldflags: -X main.version={{ .Env.VERSION }}
24+
#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)
25+
26+
- main : ./cmd/binary-patch-server/
27+
binary: binary-patch-server
28+
goos:
29+
- darwin
30+
- linux
31+
- windows
32+
goarch:
33+
- amd64
34+
#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)
35+
env:
36+
- CGO_ENABLED=0
37+
- GO111MODULE=on
38+
- VERSION=$(git describe --tags --always --dirty)
39+
40+
archive:
41+
files:
42+
- README.md
43+
- LICENSE
44+
45+
checksum:
46+
name_template: 'checksums.txt'
47+
48+
changelog:
49+
sort: asc
50+
filters:
51+
exclude:
52+
- '^doc'
53+
- '^test'
54+
55+
sign:
56+
artifacts: checksum

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ IMAGE ?= pierone.stups.zalan.do/teapot/$(BINARY)
44
TAG ?= $(VERSION)
55
DOCKERFILE ?= Dockerfile
66
BUILD_FLAGS ?= -v
7-
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)
7+
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)
88
GITHEAD = $(shell git rev-parse --short HEAD)
99
GITURL = $(shell git config --get remote.origin.url)
1010
GITSTATUS = $(shell git status --porcelain || echo "no changes")
@@ -35,7 +35,7 @@ check:
3535
GO111MODULE=$(GO111) go vet -v $(GOPKGS)
3636

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

4040
build.local: build/$(BINARY)
4141
build.linux: build/linux/$(BINARY)

cmd/binary-patch-server/server.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,14 @@ import (
1212
"golang.org/x/oauth2"
1313
)
1414

15-
// Buildstamp is used to store the timestamp of the build
16-
var Buildstamp = "Not set"
15+
var (
16+
version string = ""
17+
commit string = ""
18+
date string = ""
1719

18-
// Githash is used to store the commit hash of the build
19-
var Githash = "Not set"
20-
21-
// Version is used to store the tagged version of the build
22-
var Version = "Not set"
23-
24-
// flag variables
25-
var version bool
26-
27-
var serverConfig *conf.Config
20+
versionflag bool
21+
serverConfig *conf.Config
22+
)
2823

2924
func init() {
3025
bin := path.Base(os.Args[0])
@@ -45,7 +40,7 @@ Example:
4540
os.Exit(2)
4641
}
4742

48-
flag.BoolVar(&version, "version", false, "Print version and exit")
43+
flag.BoolVar(&versionflag, "version", false, "Print version and exit")
4944
flag.BoolVar(&serverConfig.DebugEnabled, "debug", serverConfig.DebugEnabled, "Enable debug output")
5045
flag.BoolVar(&serverConfig.Oauth2Enabled, "oauth", serverConfig.Oauth2Enabled, "Enable OAuth2")
5146
flag.BoolVar(&serverConfig.ProfilingEnabled, "profile", serverConfig.ProfilingEnabled, "Enable profiling.")
@@ -61,12 +56,12 @@ Example:
6156
}
6257

6358
func main() {
64-
if version {
59+
if versionflag {
6560
fmt.Printf(`%s Version: %s
6661
================================
6762
Buildtime: %s
6863
GitHash: %s
69-
`, path.Base(os.Args[0]), Version, Buildstamp, Githash)
64+
`, path.Base(os.Args[0]), version, date, commit)
7065
os.Exit(0)
7166
}
7267

cmd/binary-patch/main.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import (
99

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

12-
"gopkg.in/alecthomas/kingpin.v2"
12+
kingpin "gopkg.in/alecthomas/kingpin.v2"
1313
)
1414

1515
var (
16-
//Buildstamp is used for storing the timestamp of the build
17-
Buildstamp string = "Not set"
18-
//Githash is used for storing the commit hash of the build
19-
Githash string = "Not set"
20-
// Version is used to store the tagged version of the build
21-
Version string = "Not set"
16+
version string = ""
17+
commit string = ""
18+
date string = ""
19+
2220
// public key to verify signed updates
2321
publicKey []byte
2422
)
@@ -62,31 +60,31 @@ func main() {
6260
================================
6361
Buildtime: %s
6462
GitHash: %s
65-
`, path.Base(os.Args[0]), Version, Buildstamp, Githash)
63+
`, path.Base(os.Args[0]), version, date, commit)
6664
os.Exit(0)
6765
case update.FullCommand():
68-
pc := patchclient.NewInsecurePatchClient(*baseUpdateURL, Version)
66+
pc := patchclient.NewInsecurePatchClient(*baseUpdateURL, version)
6967
err := pc.UnsignedNotVerifiedUpdate()
7068
if err != nil {
7169
log.Fatalf("Failed to update: %v", err)
7270
}
7371

7472
case patchUpdate.FullCommand():
75-
pc := patchclient.NewInsecurePatchClient(*basePatchUpdateURL, Version)
73+
pc := patchclient.NewInsecurePatchClient(*basePatchUpdateURL, version)
7674
err := pc.UnsignedNotVerifiedPatchUpdate()
7775
if err != nil {
7876
log.Fatalf("Failed to update: %v", err)
7977
}
8078

8179
case signedUpdate.FullCommand():
82-
pc := patchclient.NewPatchClient(*baseSignedUpdateURL, Version, publicKey)
80+
pc := patchclient.NewPatchClient(*baseSignedUpdateURL, version, publicKey)
8381
err := pc.SignedVerifiedUpdate()
8482
if err != nil {
8583
log.Fatalf("Failed to update: %v", err)
8684
}
8785

8886
case signedPatchUpdate.FullCommand():
89-
pc := patchclient.NewPatchClient(*baseSignedPatchUpdateURL, Version, publicKey)
87+
pc := patchclient.NewPatchClient(*baseSignedPatchUpdateURL, version, publicKey)
9088
err := pc.SignedVerifiedPatchUpdate()
9189
if err != nil {
9290
log.Fatalf("Failed to update: %v", err)

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ require (
1010
github.com/gin-gonic/gin v1.3.0
1111
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
1212
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
13+
github.com/json-iterator/go v1.1.6 // indirect
1314
github.com/kr/binarydist v0.1.0
1415
github.com/mattn/go-isatty v0.0.7 // indirect
16+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
17+
github.com/modern-go/reflect2 v1.0.1 // indirect
1518
github.com/pkg/errors v0.8.1
19+
github.com/stretchr/testify v1.3.0 // indirect
1620
github.com/szuecs/gin-glog v1.1.1
1721
github.com/szuecs/gin-gomonitor v1.1.3
1822
github.com/ugorji/go/codec v0.0.0-20190316083543-95c34d148dff // indirect
1923
github.com/zalando/gin-oauth2 v1.5.2
2024
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
2125
gopkg.in/alecthomas/kingpin.v2 v2.2.6
26+
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
2227
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
2328
gopkg.in/mcuadros/go-monitor.v1 v1.1.1
2429
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0

go.sum

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5Vpd
55
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
66
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
77
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
8+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
9+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
810
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g=
911
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
1012
github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs=
@@ -15,12 +17,23 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
1517
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1618
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
1719
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
20+
github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
21+
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
1822
github.com/kr/binarydist v0.1.0 h1:6kAoLA9FMMnNGSehX0s1PdjbEaACznAv/W219j2uvyo=
1923
github.com/kr/binarydist v0.1.0/go.mod h1:DY7S//GCoz1BCd0B0EVrinCKAZN3pXe+MDaIZbXQVgM=
2024
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
2125
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
26+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
27+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
28+
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
29+
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
2230
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
2331
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
32+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
33+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
34+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
35+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
36+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2437
github.com/szuecs/gin-glog v1.1.1 h1:YwewjwcnxTVJeB6U7zcJ82FohUzxR4wzSTuspkj6BRE=
2538
github.com/szuecs/gin-glog v1.1.1/go.mod h1:eFFtHjaaO5lc0ich5AZPMsu3i8rn1TvwmpQnJb+3HP4=
2639
github.com/szuecs/gin-gomonitor v1.1.3 h1:osvldnORsCEsA6XyDiW80/apKOMkqwvYLniDVBd04Ow=
@@ -36,13 +49,19 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI
3649
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
3750
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
3851
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
52+
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
3953
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
54+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
4055
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
4156
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
57+
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
4258
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
4359
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
4460
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
61+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
4562
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
63+
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
64+
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
4665
gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=
4766
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
4867
gopkg.in/mcuadros/go-monitor.v1 v1.1.1 h1:n03FeVN561iWj1nQcmOW4NBG8eUk/TEErbeSD2rp+wM=

0 commit comments

Comments
 (0)