Skip to content

Commit

Permalink
update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
樊尚享 committed Aug 25, 2017
1 parent 4603d63 commit 89dae0f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
sudo: false
sudo: required
language: go
services:
- docker
go:
- 1.8
- 1.8.x
before_install:
install:
- make
- make release
script:
- echo "test skip"
before_deploy:
- "./release"
- make install
deploy:
provider: releases
api_key:
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:latest
MAINTAINER martinyunify <[email protected]>

ADD daemon /



ENTRYPOINT ["/daemon"]
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# GitHub viewer defaults to 8, change with ?ts=4 in URL

# Vars describing project
NAME = hostnic-cni
GIT_REPOSITORY = github.com/yunify/hostnic-cni
NAME= hostnic-cni
GIT_REPOSITORY= github.com/yunify/hostnic-cni
DOCKER_IMAGE_NAME?= dockerhub.qingcloud.com/qingcloud/hostnic-cni

# Generate vars to be included from external script
# Allows using bash to generate complex vars, such as project versions
Expand Down Expand Up @@ -50,8 +51,15 @@ GO_VAR_BUILD_LABEL := $(BUILD_LABEL)
GO_LDFLAGS = $(foreach v,$(filter $(GO_VARIABLE_PREFIX)%, $(.VARIABLES)),-X github.com/yunify/hostnic-cni/pkg.$(patsubst $(GO_VARIABLE_PREFIX)%,%,$(v))=$(value $(value v)))
GO_BUILD_FLAGS = -a -tags netgo -installsuffix nocgo -ldflags "$(GO_LDFLAGS)"

# Define targets
#src
hostnic_pkg = $(subst $(GIT_REPOSITORY)/,,$(shell go list -f '{{ join .Deps "\n" }}' $(GIT_REPOSITORY)/cmd/hostnic | grep "^$(GIT_REPOSITORY)" |grep -v "^$(GIT_REPOSITORY)/vendor/" ))
hostnic_pkg += cmd/hostnic

daemon_pkg = $(subst $(GIT_REPOSITORY)/,,$(shell go list -f '{{ join .Deps "\n" }}' $(GIT_REPOSITORY)/cmd/daemon | grep "^$(GIT_REPOSITORY)" |grep -v "^$(GIT_REPOSITORY)/vendor/" ))
daemon_pkg += cmd/daemon

# Define targets
TEST_PACKAGES?=cmd pkg
# default just build binary
default : go-build

Expand All @@ -60,10 +68,28 @@ print-% :
@echo '$*=$($*)'

# perform go build on project
go-build :
go-build : bin/hostnic bin/daemon

bin/hostnic : $(foreach dir,$(hostnic_pkg),$(wildcard $(dir)/*.go))
go build -o bin/hostnic $(GO_BUILD_FLAGS) $(GIT_REPOSITORY)/cmd/hostnic/

bin/hostnic.tar.gz : bin/hostnic
tar -C bin/ -czf bin/hostnic.tar.gz hostnic

bin/daemon : $(foreach dir,$(daemon_pkg),$(wildcard $(dir)/*.go))
go build -o bin/daemon $(GO_BUILD_FLAGS) $(GIT_REPOSITORY)/cmd/daemon/

bin/.docker-images-build-timestamp : bin/daemon
cp -u Dockerfile bin
docker build -q -t $(DOCKER_IMAGE_NAME):$(BUILD_LABEL) bin/ > bin/.docker-images-build-timestamp

release : test bin/hostnic.tar.gz bin/.docker-images-build-timestamp

install : release
docker push $(DOCKER_IMAGE_NAME):$(BUILD_LABEL)

clean :
docker rmi `cat bin/.docker-images-build-timestamp`
rm -rf bin/

.PHONY : default all go-build
.PHONY : default all go-build clean release install test
24 changes: 0 additions & 24 deletions release

This file was deleted.

0 comments on commit 89dae0f

Please sign in to comment.