Skip to content

Commit 92386f1

Browse files
committed
Multi platform build.
1 parent d6a86bf commit 92386f1

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
.*
33

44
# binaries
5-
bin/
6-
builds/
5+
dist/
6+
build/

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ go:
33
- 1.6
44
script:
55
- make run-compose-test
6-
- make package
6+
- GOOS=linux GOARCH=amd64 make package
7+
- GOOS=linux GOARCH=386 make package
8+
- GOOS=linux GOARCH=arm make package
9+
- GOOS=darwin GOARCH=amd64 make package
10+
- GOOS=windows BINEXT=.exe GOARCH=386 make package
11+
- GOOS=windows BINEXT=.exe GOARCH=amd64 make package
712
services:
813
- docker
914
deploy:
@@ -12,7 +17,7 @@ deploy:
1217
api_key:
1318
secure: hue09xkRBLJpF5gR7nBCn1CySTTwUwe2ZYZA4Q2RjqdQ6Tk8KXgaJp+wk3xl24oWUb4l6dv2dETy+awT/G1DsOz6z5oGzuNFvAuTIqWgk5eIpctwPYlc9t0mgUnBJCx/eDYIoN/ogBxoE2QFE4CCfYcGd5iFpYb2aPw8oP6Pc5LYsm6PYUHi1IE69tyMj9aFWgtMYX8OxjhTx4vFpDvQmipQE3LqYlu9z7DyeIeuxLBgGFnrjOBQsjlUsQcsgmyeazUBN8qSUhYTdhSwYw5OEI45Ddc/Pkj/pz6HbHygUmO6FIa64rLADVK0Cuaw8+jxYSgeFu2sdIk7wE30sWBITzZhvs9k/OLIghwg+eu9mZ0l0i0K1gfdwqMpQA//QnXDzSiu6FkbCz0dNQX95VJNHfmMCSrg8Dd3ebMx+4VceU6IdWEtyJAHwFONJ4cNieufaPawnEym5VBG2uZ/Iv7rYFoS1W53oCD2mGDRWpTMxQkfFMAgD0gIDB+oN0FVaApjWy+/4KVXRYf4+Eqh0BZ6YizTRt+QmD3X+0jh3j/h0wMYUE6lAGqOmTcJUPUpGBzzx3jT9XVBHCeBTVTWT7wZAMtVPGyFj2Izm/B601DIsrIdvCco4QEUTCUjZjKDM6A3OUz512GBSbKYZ0EVGoxhRv2CRSO4MeQM5Y7Lwpu/6mc=
1419
file_glob: true
15-
file: "builds/*.tar.gz"
20+
file: "dist/*.tar.gz"
1621
on:
1722
tags: true
1823
repo: brocaar/lora-semtech-bridge

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM golang:1.6.1
22

33
ENV PROJECT_PATH=/go/src/github.com/brocaar/lora-semtech-bridge
4-
ENV PATH=$PATH:$PROJECT_PATH/bin
4+
ENV PATH=$PATH:$PROJECT_PATH/build
55

66
# install tools
77
RUN go get github.com/golang/lint/golint

Makefile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
PKGS := $(shell go list ./... | grep -v /vendor/)
22
VERSION := $(shell git describe --always)
3+
GOOS ?= linux
4+
GOARCH ?= amd64
35

46
build:
5-
@echo "Compiling source"
6-
@mkdir -p bin
7-
@GOBIN="$(CURDIR)/bin" go install -ldflags "-X main.version=$(VERSION)" $(PKGS)
7+
@echo "Compiling source for $(GOOS) $(GOARCH)"
8+
@mkdir -p build
9+
@GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "-X main.version=$(VERSION)" -o build/semtech-bridge$(BINEXT) cmd/semtech-bridge/main.go
810

911
clean:
1012
@echo "Cleaning up workspace"
11-
@rm -rf bin
13+
@rm -rf build
14+
@rm -rf dist/$(VERSION)
1215

1316
test:
1417
@echo "Running tests"
@@ -19,16 +22,16 @@ test:
1922
@go test -cover -v $(PKGS)
2023

2124
package: clean build
22-
@echo "Creating package"
23-
@mkdir -p builds/$(VERSION)
24-
@cp bin/* builds/$(VERSION)
25-
@cd builds/$(VERSION)/ && tar -pczf ../lora_semtech_bridge_$(VERSION)_linux_amd64.tar.gz .
26-
@rm -rf builds/$(VERSION)
25+
@echo "Creating package for $(GOOS) $(GOARCH)"
26+
@mkdir -p dist/$(VERSION)
27+
@cp build/* dist/$(VERSION)
28+
@cd dist/$(VERSION)/ && tar -pczf ../lora_semtech_bridge_$(VERSION)_$(GOOS)_$(GOARCH).tar.gz .
29+
@rm -rf dist/$(VERSION)
2730

2831
# shortcuts for development
2932

3033
serve: build
31-
./bin/semtech-bridge
34+
./build/semtech-bridge
3235

3336
run-compose-test:
3437
docker-compose run --rm semtechbridge make test

0 commit comments

Comments
 (0)