Skip to content

Commit

Permalink
add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Jul 1, 2019
1 parent 22f39cd commit 1017671
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# binaries
out/

# releases
dist/

# config files
config.yaml

Expand Down
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
before:
hooks:
- go mod download
builds:
- main: ./cmd/darkroom/
goos:
- linux
- darwin
- windows
goarch:
- amd64
- 386
env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: macOS
linux: Linux
windows: Windows
386: 32-bit
amd64: 64-bit
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
22 changes: 21 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
language: go
go: '1.12.x'
services:
- docker

stages:
- test
- name: release
if: (repo == gojek/darkroom) AND (branch == master) AND (tag IS present)

env:
global:
Expand All @@ -11,11 +15,27 @@ env:
install: echo "Skip global `install` ..."
script: echo "Skip global `script` ..."

build_docker_image: &build_docker_image
before_script:
- |
docker build -f build/Dockerfile .
[ ! -z $TRAVIS_TAG ] && docker tag gojek/darkroom:$DOCKER_LATEST gojek/darkroom:$TRAVIS_TAG
[ ! -z $TRAVIS_TAG ] && docker tag gojek/darkroom:$TRAVIS_TAG gojek/darkroom:$DOCKER_LATEST
[ ! -z $DOCKER_PASSWORD ] && echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker images
jobs:
include:
- stage: test
install: make setup
script: make ci
script: make test-ci

- stage: release
- name: "Release Builds"
script: curl -sL https://git.io/goreleaser | bash -s -- --rm-dist --skip-validate
- name: "Docker Builds"
<<: *build_docker_image
script: docker push gojek/darkroom:$TRAVIS_TAG && docker push gojek/darkroom:$DOCKER_LATEST

notifications:
email: false
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
APP=darkroom
APP_EXECUTABLE="./out/$(APP)"

all: ci
all: test-ci

setup:
go get -u golang.org/x/lint/golint
Expand All @@ -11,7 +11,7 @@ compile:
mkdir -p out
go build -o $(APP_EXECUTABLE) ./cmd/darkroom/main.go

lint: setup
lint:
golint ./... | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; }

format:
Expand All @@ -31,10 +31,9 @@ test-cov-report:
gocov report coverage.json

copy-config:
mkdir -p out
cp config.yaml.example config.yaml

docker-image:
docker build -t ${USER}/darkroom:latest -f build/Dockerfile .

ci: copy-config compile lint format vet test test-cov test-cov-report
test-ci: copy-config compile lint format vet test test-cov test-cov-report

0 comments on commit 1017671

Please sign in to comment.