Skip to content

Commit

Permalink
Merge pull request #18 from longdog/master
Browse files Browse the repository at this point in the history
Build binaries in CI and publish in github releases
  • Loading branch information
freetonik authored Nov 1, 2019
2 parents 6111db6 + cc6b5af commit 8a6956d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: go
sudo: false

os:
- linux

go:
- 1.13

script:
# Windows 386 build
- GOOS=windows GOARCH=386 VERSION=${TRAVIS_TAG} make release
# Windows amd64 build
- GOOS=windows GOARCH=amd64 VERSION=${TRAVIS_TAG} make release
# Linux 386 build
- GOOS=linux GOARCH=386 VERSION=${TRAVIS_TAG} make release
# Linux amd64 build
- GOOS=linux GOARCH=amd64 VERSION=${TRAVIS_TAG} make release
# Darwin amd64 build
- GOOS=darwin GOARCH=amd64 VERSION=${TRAVIS_TAG} make release

deploy:
provider: releases
api_key: ${GITHUB_TOKEN}
file:
- release/underblog-*.zip
- release/underblog-*.tar.gz
on:
tags: true
file_glob: true
skip_cleanup: true
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
include version.mk
NAME = underblog
BUILD_NAME = $(GOOS)-$(GOARCH)
BUILD_DIR = release/$(BUILD_NAME)


ifeq ($(GOOS),windows)
ext=.exe
archiveCmd=zip -9 -r $(NAME)-$(BUILD_NAME)-$(VERSION).zip $(BUILD_NAME)
else
ext=
archiveCmd=tar czpvf $(NAME)-$(BUILD_NAME)-$(VERSION).tar.gz $(BUILD_NAME)
endif

all: build test targz sha move

Expand All @@ -12,10 +24,16 @@ bench:
go test -v -run Bench -bench=. ./...

targz:
tar -czf underblog_$(version).tar.gz underblog
tar -czf underblog_$(VERSION).tar.gz underblog

sha:
shasum -a 256 underblog_$(version).tar.gz
shasum -a 256 underblog_$(VERSION).tar.gz

move:
mv underblog release/ && mv underblog_$(version).tar.gz release/
mv underblog release/ && mv underblog_$(VERSION).tar.gz release/

.PHONY: release
release:
-mkdir -p $(BUILD_DIR)
GOOS=$(GOOS) GOARCH=$(GOARCH) GO111MODULE=on CGO_ENABLED=0 go build -o $(BUILD_DIR)/$(NAME)$(ext) ./app/main.go
cd release ; $(archiveCmd)
3 changes: 3 additions & 0 deletions app/internal/runtime.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// +build linux darwin
// +build !windows

package internal

import (
Expand Down
2 changes: 1 addition & 1 deletion version.mk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = 0.2
VERSION ?= 0.2

0 comments on commit 8a6956d

Please sign in to comment.