Skip to content

Commit 0e42821

Browse files
committed
make releases
1 parent 7a97c3e commit 0e42821

File tree

9 files changed

+111
-3
lines changed

9 files changed

+111
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/*.txt
22
/*.pprof
3+
/dist/

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
run:
2-
deadline: 30s
32
tests: true
43

54
linters-settings:

.goreleaser.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
project_name: golangci-lint
3+
4+
release:
5+
github:
6+
owner: golangci
7+
name: golangci-lint
8+
9+
builds:
10+
- binary: golangci-lint
11+
goos: &goos
12+
- darwin
13+
- windows
14+
- linux
15+
goarch: &goarch
16+
- amd64
17+
- i386
18+
env:
19+
- CGO_ENABLED=0
20+
main: ./cmd/golangci-lint/
21+
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
22+
23+
archive:
24+
format: tar.gz
25+
wrap_in_directory: true
26+
format_overrides:
27+
- goos: windows
28+
format: zip
29+
name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
30+
files:
31+
- LICENSE
32+
- README.md
33+
34+
snapshot:
35+
name_template: SNAPSHOT-{{ .Commit }}
36+
37+
checksum:
38+
name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt'
39+
40+
changelog:
41+
sort: asc
42+
filters:
43+
exclude:
44+
- '^docs:'
45+
- '^test:'
46+
- 'README.md'
47+
- Merge pull request
48+
- Merge branch
49+
50+
dockers:
51+
- image: golangci/golangci-lint
52+
tag_templates:
53+
- '{{ .Tag }}'
54+
- 'v{{ .Major }}.{{ .Minor }}'
55+
- 'latest'
56+
57+
brew:
58+
github:
59+
owner: golangci
60+
name: golangci-lint-formula
61+
folder: Formula
62+
homepage: https://golangci.com
63+
description: Fast linters runner for Go.
64+
test: |
65+
system "#{bin}/golangci-lint --version"
66+
67+
git:
68+
short_hash: true

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,18 @@ go:
44
- 1.9.x
55
- 1.10.x
66
script: make test
7+
8+
after_success:
9+
- test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
10+
11+
# needed for the docker pipe
12+
services:
13+
- docker
14+
15+
deploy:
16+
- provider: script
17+
skip_cleanup: true
18+
script: curl -sL https://git.io/goreleaser | bash
19+
on:
20+
tags: true
21+
condition: $TRAVIS_GO_VERSION =~ ^1\.10\.[0-9]+$

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
COPY golangci-lint /
3+
ENTRYPOINT ["/golangci-lint"]

cmd/golangci-lint/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ import (
44
"github.com/golangci/golangci-lint/pkg/commands"
55
)
66

7+
var (
8+
// Populated by goreleaser during build
9+
version = "master"
10+
commit = "?"
11+
date = ""
12+
)
13+
714
func main() {
8-
e := commands.NewExecutor()
15+
e := commands.NewExecutor(version, commit, date)
916
if err := e.Execute(); err != nil {
1017
panic(err)
1118
}

pkg/commands/executor.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ type Executor struct {
1111
cfg *config.Config
1212

1313
exitCode int
14+
15+
version, commit, date string
1416
}
1517

16-
func NewExecutor() *Executor {
18+
func NewExecutor(version, commit, date string) *Executor {
1719
e := &Executor{
1820
cfg: &config.Config{},
1921
}
@@ -22,6 +24,10 @@ func NewExecutor() *Executor {
2224
e.initRun()
2325
e.initLinters()
2426

27+
e.version = version
28+
e.commit = commit
29+
e.date = date
30+
2531
return e
2632
}
2733

pkg/commands/root.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package commands
22

33
import (
4+
"fmt"
45
"log"
56
"os"
67
"runtime"
78
"runtime/pprof"
89

10+
"github.com/golangci/golangci-lint/pkg/printers"
911
"github.com/sirupsen/logrus"
1012
"github.com/spf13/cobra"
1113
)
@@ -21,6 +23,11 @@ func (e *Executor) initRoot() {
2123
}
2224
},
2325
PersistentPreRun: func(cmd *cobra.Command, args []string) {
26+
if e.cfg.Run.PrintVersion {
27+
fmt.Fprintf(printers.StdOut, "golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
28+
os.Exit(0)
29+
}
30+
2431
runtime.GOMAXPROCS(e.cfg.Run.Concurrency)
2532

2633
log.SetFlags(0) // don't print time
@@ -62,6 +69,7 @@ func (e *Executor) initRoot() {
6269
rootCmd.PersistentFlags().StringVar(&e.cfg.Run.CPUProfilePath, "cpu-profile-path", "", "Path to CPU profile output file")
6370
rootCmd.PersistentFlags().StringVar(&e.cfg.Run.MemProfilePath, "mem-profile-path", "", "Path to memory profile output file")
6471
rootCmd.PersistentFlags().IntVarP(&e.cfg.Run.Concurrency, "concurrency", "j", runtime.NumCPU(), "Concurrency (default NumCPU)")
72+
rootCmd.PersistentFlags().BoolVar(&e.cfg.Run.PrintVersion, "version", false, "Print version")
6573

6674
e.rootCmd = rootCmd
6775
}

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type Run struct {
5555
ExitCodeIfIssuesFound int `mapstructure:"issues-exit-code"`
5656
AnalyzeTests bool `mapstructure:"tests"`
5757
Deadline time.Duration
58+
PrintVersion bool
5859
}
5960

6061
type LintersSettings struct {

0 commit comments

Comments
 (0)