Skip to content

Commit

Permalink
make releases
Browse files Browse the repository at this point in the history
  • Loading branch information
golangcidev committed May 29, 2018
1 parent 7a97c3e commit 0e42821
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/*.txt
/*.pprof
/dist/
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
run:
deadline: 30s
tests: true

linters-settings:
Expand Down
68 changes: 68 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
project_name: golangci-lint

release:
github:
owner: golangci
name: golangci-lint

builds:
- binary: golangci-lint
goos: &goos
- darwin
- windows
- linux
goarch: &goarch
- amd64
- i386
env:
- CGO_ENABLED=0
main: ./cmd/golangci-lint/
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}

archive:
format: tar.gz
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip
name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
files:
- LICENSE
- README.md

snapshot:
name_template: SNAPSHOT-{{ .Commit }}

checksum:
name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt'

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- 'README.md'
- Merge pull request
- Merge branch

dockers:
- image: golangci/golangci-lint
tag_templates:
- '{{ .Tag }}'
- 'v{{ .Major }}.{{ .Minor }}'
- 'latest'

brew:
github:
owner: golangci
name: golangci-lint-formula
folder: Formula
homepage: https://golangci.com
description: Fast linters runner for Go.
test: |
system "#{bin}/golangci-lint --version"
git:
short_hash: true
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@ go:
- 1.9.x
- 1.10.x
script: make test

after_success:
- test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"

# needed for the docker pipe
services:
- docker

deploy:
- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_GO_VERSION =~ ^1\.10\.[0-9]+$
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY golangci-lint /
ENTRYPOINT ["/golangci-lint"]
9 changes: 8 additions & 1 deletion cmd/golangci-lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import (
"github.com/golangci/golangci-lint/pkg/commands"
)

var (
// Populated by goreleaser during build
version = "master"
commit = "?"
date = ""
)

func main() {
e := commands.NewExecutor()
e := commands.NewExecutor(version, commit, date)
if err := e.Execute(); err != nil {
panic(err)
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/commands/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ type Executor struct {
cfg *config.Config

exitCode int

version, commit, date string
}

func NewExecutor() *Executor {
func NewExecutor(version, commit, date string) *Executor {
e := &Executor{
cfg: &config.Config{},
}
Expand All @@ -22,6 +24,10 @@ func NewExecutor() *Executor {
e.initRun()
e.initLinters()

e.version = version
e.commit = commit
e.date = date

return e
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/commands/root.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package commands

import (
"fmt"
"log"
"os"
"runtime"
"runtime/pprof"

"github.com/golangci/golangci-lint/pkg/printers"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand All @@ -21,6 +23,11 @@ func (e *Executor) initRoot() {
}
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if e.cfg.Run.PrintVersion {
fmt.Fprintf(printers.StdOut, "golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
os.Exit(0)
}

runtime.GOMAXPROCS(e.cfg.Run.Concurrency)

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

e.rootCmd = rootCmd
}
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Run struct {
ExitCodeIfIssuesFound int `mapstructure:"issues-exit-code"`
AnalyzeTests bool `mapstructure:"tests"`
Deadline time.Duration
PrintVersion bool
}

type LintersSettings struct {
Expand Down

0 comments on commit 0e42821

Please sign in to comment.