Skip to content

Commit 367ad01

Browse files
committed
chore: new release system.
1 parent 90d1b44 commit 367ad01

14 files changed

+131
-122
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
dist/
3+
unsecured/
4+
vendor/

.golangci.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@
3939
max-same-issues = 0
4040
exclude = []
4141
[[issues.exclude-rules]]
42-
path = "meta/version.go"
43-
text = "`(Version|BuildDate)` is a global variable"
42+
path = "version.go"
43+
text = "`(version|date|commit)` is a global variable"

.goreleaser.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
project_name: kutteri
2+
3+
builds:
4+
- binary: kutteri
5+
goos:
6+
- windows
7+
- darwin
8+
- linux
9+
goarch:
10+
- amd64
11+
- 386
12+
- arm
13+
- arm64
14+
goarm:
15+
- 7
16+
17+
ignore:
18+
- goos: darwin
19+
goarch: 386
20+
21+
changelog:
22+
sort: asc
23+
filters:
24+
exclude:
25+
- '^docs:'
26+
- '^doc:'
27+
- '^chore:'
28+
- '^test:'
29+
- '^tests:'
30+
31+
archive:
32+
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
33+
format: tar.gz
34+
format_overrides:
35+
- goos: windows
36+
format: zip
37+
files:
38+
- LICENSE

.travis.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ before_install:
2323
install: make dependencies
2424

2525
deploy:
26-
- provider: releases
27-
api_key: ${GITHUB_TOKEN}
28-
file: dist/kutteri*
26+
- provider: script
2927
skip_cleanup: true
30-
overwrite: true
31-
file_glob: true
28+
script: curl -sL https://git.io/goreleaser | bash
3229
on:
3330
tags: true
31+
condition: $TRAVIS_GO_VERSION =~ ^1\.x$

Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ FROM alpine:3.6
1515
RUN apk --update upgrade \
1616
&& apk --no-cache --no-progress add ca-certificates git \
1717
&& rm -rf /var/cache/apk/*
18-
COPY --from=builder /go/src/github.com/containous/kutteri/kutteri .
19-
CMD ["./kutteri", "-h"]
18+
19+
COPY --from=builder /go/src/github.com/containous/kutteri/kutteri /usr/bin/kutteri
20+
21+
ENTRYPOINT ["/usr/bin/kutteri"]

Gopkg.lock

+22-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
# go-tests = true
2525
# unused-packages = true
2626

27-
[[override]]
28-
name = "google.golang.org/appengine"
29-
branch = "master"
30-
3127
[prune]
3228
non-go = true
3329
go-tests = true
34-
# unused-packages = true
30+
unused-packages = true
31+
32+
[[override]]
33+
name = "google.golang.org/appengine"
34+
branch = "master"

Makefile

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean checks test build build-crossbinary
1+
.PHONY: clean checks test build
22

33
GOFILES := $(shell git ls-files '*.go' | grep -v '^vendor/')
44

@@ -7,9 +7,7 @@ SHA := $(shell git rev-parse --short HEAD)
77
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
88
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
99

10-
VERSION_PACKAGE=github.com/containous/lobicornis/meta
11-
12-
default: clean checks test build-crossbinary
10+
default: clean checks test build
1311

1412
test: clean
1513
go test -v -cover ./...
@@ -22,10 +20,7 @@ clean:
2220

2321
build: clean
2422
@echo Version: $(VERSION) $(BUILD_DATE)
25-
go build -v -ldflags '-X "${VERSION_PACKAGE}.Version=${VERSION}" -X "${VERSION_PACKAGE}.BuildDate=${BUILD_DATE}"'
23+
go build -v -ldflags '-X "main.version=${VERSION}" -X "main.commit=${SHA}" -X "main.date=${BUILD_DATE}"'
2624

2725
checks:
2826
golangci-lint run
29-
30-
build-crossbinary:
31-
./_script/crossbinary

_script/crossbinary

-30
This file was deleted.

core/core.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,13 @@ func sendToSlack(client *slack.Client, config SlackConfig, text string) error {
253253

254254
// NewGitHubClient create a new GitHub client
255255
func NewGitHubClient(ctx context.Context, token string) *github.Client {
256-
var client *github.Client
257256
if len(token) == 0 {
258-
client = github.NewClient(nil)
259-
} else {
260-
ts := oauth2.StaticTokenSource(
261-
&oauth2.Token{AccessToken: token},
262-
)
263-
tc := oauth2.NewClient(ctx, ts)
264-
client = github.NewClient(tc)
257+
return github.NewClient(nil)
265258
}
266-
return client
259+
260+
ts := oauth2.StaticTokenSource(
261+
&oauth2.Token{AccessToken: token},
262+
)
263+
tc := oauth2.NewClient(ctx, ts)
264+
return github.NewClient(tc)
267265
}

kutteri.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/containous/flaeg"
1212
"github.com/containous/kutteri/core"
1313
"github.com/containous/kutteri/locker"
14-
"github.com/containous/kutteri/meta"
1514
"github.com/ogier/pflag"
1615
)
1716

@@ -34,8 +33,6 @@ type Configuration struct {
3433
type NoOption struct{}
3534

3635
func main() {
37-
defaultPointersConfig := &Configuration{}
38-
3936
config := &Configuration{
4037
BotName: "Bender",
4138
BotIcon: ":bento:",
@@ -46,7 +43,7 @@ func main() {
4643
rootCmd := &flaeg.Command{
4744
Name: "kuterri",
4845
Description: `Chalepoxenus Kutteri: Track a GitHub repository and publish on Slack.`,
49-
DefaultPointersConfig: defaultPointersConfig,
46+
DefaultPointersConfig: &Configuration{},
5047
Config: config,
5148
Run: runCommand(config),
5249
}
@@ -60,7 +57,7 @@ func main() {
6057
Config: &NoOption{},
6158
DefaultPointersConfig: &NoOption{},
6259
Run: func() error {
63-
meta.DisplayVersion()
60+
displayVersion()
6461
return nil
6562
},
6663
}

meta/version.go

-24
This file was deleted.

0 commit comments

Comments
 (0)