Skip to content

Commit

Permalink
chore: new release system.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Feb 23, 2019
1 parent 736168b commit 05fbd00
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 73 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
dist/
unsecured/
vendor/
4 changes: 2 additions & 2 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
max-same-issues = 0
exclude = []
[[issues.exclude-rules]]
path = "meta/version.go"
text = "`(Version|BuildDate)` is a global variable"
path = "version.go"
text = "`(version|date|commit)` is a global variable"
[[issues.exclude-rules]]
path = "mjolnir/close.go"
text = "`(.+)RE` is a global variable"
39 changes: 39 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
project_name: lobicornis

builds:
- binary: lobicornis
goos:
- windows
- darwin
- linux
goarch:
- amd64
- 386
- arm
- arm64
goarm:
- 7

ignore:
- goos: darwin
goarch: 386

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^doc:'
- '^chore:'
- '^test:'
- '^tests:'

archive:
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm
}}v{{ .Arm }}{{ end }}'
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ before_install:
install: make dependencies

deploy:
- provider: releases
api_key: ${GITHUB_TOKEN}
file: dist/lobicornis*
- provider: script
skip_cleanup: true
overwrite: true
file_glob: true
script: curl -sL https://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_GO_VERSION =~ ^1\.x$
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ FROM alpine:3.6
RUN apk --update upgrade \
&& apk --no-cache --no-progress add ca-certificates git \
&& rm -rf /var/cache/apk/*
COPY --from=builder /go/src/github.com/containous/lobicornis/lobicornis .
CMD ["./lobicornis", "-h"]

COPY --from=builder /go/src/github.com/containous/lobicornis/lobicornis /usr/bin/lobicornis

ENTRYPOINT ["/usr/bin/lobicornis"]
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean fmt check test build build-crossbinary
.PHONY: clean fmt check test build

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

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

VERSION_PACKAGE=github.com/containous/lobicornis/meta

default: clean check test build-crossbinary
default: clean check test build

test: clean
go test -v -cover ./...
Expand All @@ -22,13 +20,10 @@ clean:

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

check:
golangci-lint run

fmt:
@gofmt -s -l -w $(GOFILES)

build-crossbinary:
./_script/crossbinary
30 changes: 0 additions & 30 deletions _script/crossbinary

This file was deleted.

3 changes: 1 addition & 2 deletions lobicornis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/containous/flaeg"
"github.com/containous/lobicornis/core"
"github.com/containous/lobicornis/gh"
"github.com/containous/lobicornis/meta"
"github.com/containous/lobicornis/types"
"github.com/ogier/pflag"
)
Expand Down Expand Up @@ -60,7 +59,7 @@ func main() {
Config: &types.NoOption{},
DefaultPointersConfig: &types.NoOption{},
Run: func() error {
meta.DisplayVersion()
displayVersion()
return nil
},
}
Expand Down
24 changes: 0 additions & 24 deletions meta/version.go

This file was deleted.

24 changes: 24 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"fmt"
"runtime"
)

var (
version = "dev"
commit = "I don't remember exactly"
date = "I don't remember exactly"
)

// displayVersion DisplayVersion version.
func displayVersion() {
fmt.Printf(`Myrmica Lobicornis:
version : %s
commit : %s
build date : %s
go version : %s
go compiler : %s
platform : %s/%s
`, version, commit, date, runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH)
}

0 comments on commit 05fbd00

Please sign in to comment.