Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add goreleaser setup #9

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
dist
63 changes: 63 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
project_name: github-releases-notifier
release:
github:
owner: justwatchcom
name: github-releases-notifier
name_template: '{{ .Tag }}'
builds:
- goos:
- linux
- darwin
goarch:
- amd64
- arm
- arm64
goarm:
- "6"
main: .
binary: github-releases-notifier
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -extldflags '-static'

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

checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
dist: dist
changelog:
filters:
exclude:
- typo
- Fix
- Merge
- WIP
archive:
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
format: tar.gz
files:
- license*
- LICENSE*
- readme*
- README*
- changelog*
- CHANGELOG*
dockers:
- image: justwatchcom/github-releases-notifier
goos: linux
goarch: amd64
goarm: ''
binary: github-releases-notifier
dockerfile: Dockerfile.amd64
- image: justwatchcom/github-releases-notifier-armv6
goos: linux
goarch: arm
goarm: '6'
binary: github-releases-notifier
dockerfile: Dockerfile.armv6
- image: justwatchcom/github-releases-notifier-arm64
goos: linux
goarch: arm64
binary: github-releases-notifier
dockerfile: Dockerfile.arm64
env_files:
github_token: ~/.goreleaser.token
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
language: go

go:
- 1.8.x
- 1.10.x

services:
- docker

before_install:
- go get -u github.com/golang/dep/cmd/dep
- go get -v github.com/golang/lint/golint
- go get -d github.com/goreleaser/goreleaser
- cd $GOPATH/src/github.com/goreleaser/goreleaser
- dep ensure -vendor-only
- make setup build
- go install
- cd -

script:
- make clean
Expand Down
12 changes: 0 additions & 12 deletions Dockerfile

This file was deleted.

5 changes: 5 additions & 0 deletions Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine:3.6
RUN apk --no-cache add ca-certificates

COPY dist/linux_amd64/github-releases-notifier /bin/
ENTRYPOINT [ "/bin/github-releases-notifier" ]
6 changes: 6 additions & 0 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM arm64v8/alpine:3.7
RUN apk --no-cache add ca-certificates

COPY dist/linux_arm64/github-releases-notifier /bin/

ENTRYPOINT [ "/bin/github-releases-notifier" ]
6 changes: 6 additions & 0 deletions Dockerfile.armv6
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM arm32v6/alpine:3.7
RUN apk --no-cache add ca-certificates

COPY dist/linux_arm_6/github-releases-notifier /bin/

ENTRYPOINT [ "/bin/github-releases-notifier" ]
31 changes: 11 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
DIST := dist
BIN := bin

EXECUTABLE := github-releases-notifier

PWD := $(shell pwd)
VERSION := $(shell cat VERSION)
SHA := $(shell cat COMMIT 2>/dev/null || git rev-parse --short=8 HEAD)
DATE := $(shell date -u '+%FT%T%z')

GOLDFLAGS += -X "main.version=$(VERSION)"
GOLDFLAGS += -X "main.date=$(DATE)"
GOLDFLAGS += -X "main.commit=$(SHA)"
GOLDFLAGS += -extldflags '-static'

GO := CGO_ENABLED=0 go

GOOS ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f1)
GOARCH ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f2)
GO := go

PACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /tests)

Expand All @@ -29,6 +13,7 @@ all: clean test build
clean:
$(GO) clean -i ./...
find . -type f -name "coverage.out" -delete
if [ -f Dockerfile ]; then rm Dockerfile ; fi

.PHONY: fmt
fmt:
Expand Down Expand Up @@ -67,7 +52,13 @@ test:
STATUS=0; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || STATUS=1; done; exit $$STATUS

.PHONY: build
build: $(EXECUTABLE)-$(GOOS)-$(GOARCH)
build:
go build

.PHONY: snapshot
snapshot:
goreleaser --snapshot --rm-dist

$(EXECUTABLE)-$(GOOS)-$(GOARCH): $(wildcard *.go)
$(GO) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE)
.PHONY: release
release:
goreleaser --rm-dist