Skip to content

Commit

Permalink
Add mechanism to release binaries properly
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Yousuf <[email protected]>
  • Loading branch information
alyyousuf7 committed May 20, 2018
1 parent 548fde7 commit c31d7f4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 8 deletions.
53 changes: 45 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,62 @@
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.9

working_directory: /go/src/github.com/alyyousuf7/twenty48
steps:
- checkout
- run:
name: Build binary
command: make binary

test:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/alyyousuf7/twenty48
steps:
- checkout
- run:
name: Run unit tests
command: make test
- run:
name: Build binary
command: make binary

coverage:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/alyyousuf7/twenty48
steps:
- checkout
- run:
name: Generate coverage report
command: make coverage
- run:
name: Upload coverage report to codecov
command: bash <(curl -s https://codecov.io/bash)
command: bash <(curl -s https://codecov.io/bash)

release:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/alyyousuf7/twenty48
steps:
- checkout
- run:
name: Release with goreleaser
command: curl -sSL git.io/goreleaser | bash

workflows:
version: 2
build-test-and-release:
jobs:
- build
- test
- coverage:
requires:
- test
- release:
requires:
- test
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ # vx.x.x
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.so
*.dylib
bin/
dist/

# Test binary, build with `go test -c`
*.test
Expand Down
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Build for darwin, linux and windows
builds:
- main: ./cmd/twenty48
goos:
- darwin
- linux
- windows
goarch:
- 386
- amd64

# Make release files look nice
archive:
replacements:
386: 32-bit
amd64: 64-bit
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE

# Do not publish the release yet
release:
draft: true
name_template: "{{.ProjectName}}-v{{.Version}}"

0 comments on commit c31d7f4

Please sign in to comment.