Skip to content

Commit dc1b740

Browse files
authored
Merge pull request #11 from j-fuentes/master
Add ci-test and ci-build and ci-publish targets
2 parents 0e6b75e + a13ddb1 commit dc1b740

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

Makefile

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
22

3-
VERSION:=$(shell $(ROOT_DIR)/scripts/getversion.sh)
3+
VERSION:=$(shell $(ROOT_DIR)/hack/getversion)
44
COMMIT:=$(shell git rev-list -1 HEAD)
55
DATE:=$(shell date -uR)
66
GOVERSION:=$(shell go version | awk '{print $$3 " " $$4}')
77

8-
IMAGE_NAME?=preflight:latest
9-
OVERLAY?=sample
8+
DOCKER_IMAGE?=quay.io/jetstack/preflight
9+
DOCKER_IMAGE_TAG?=$(DOCKER_IMAGE):$(VERSION)
1010

1111
define LDFLAGS
1212
-X "github.com/jetstack/preflight/cmd.PreflightVersion=$(VERSION)" \
@@ -22,6 +22,11 @@ export GO111MODULE=on
2222

2323
.PHONY: build
2424

25+
clean:
26+
cd $(ROOT_DIR) && rm -rf ./builds ./bundles
27+
28+
# Golang cli
29+
2530
build:
2631
cd $(ROOT_DIR) && $(GO_BUILD) -o builds/preflight .
2732

@@ -34,11 +39,44 @@ vet:
3439
lint: vet
3540
cd $(ROOT_DIR) && golint
3641

37-
clean:
38-
cd $(ROOT_DIR) && rm -rf ./builds
42+
./builds/preflight-$(GOOS)-$(GOARCH):
43+
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ./builds/preflight-$(GOOS)-$(GOARCH) .
44+
45+
build-all-platforms:
46+
$(MAKE) GOOS=linux GOARCH=amd64 ./builds/preflight-linux-amd64
47+
$(MAKE) GOOS=darwin GOARCH=amd64 ./builds/preflight-darwin-amd64
48+
$(MAKE) GOOS=windows GOARCH=amd64 ./builds/preflight-windows-amd64
49+
50+
# Bundles
51+
52+
./bundles/preflight-bundle-$(GOOS)-$(GOARCH).tgz: ./builds/preflight-$(GOOS)-$(GOARCH)
53+
cd $(ROOT_DIR) && \
54+
mkdir -p ./bundles && \
55+
tar --transform "s/assets\/packages/preflight-packages/" -cvf $@.tmp ./preflight-packages/ && \
56+
tar --transform "s/examples\/pods.preflight.yaml/preflight.yaml/" -rvf $@.tmp examples/pods.preflight.yaml && \
57+
tar --transform "s/builds\/preflight-$(GOOS)-$(GOARCH)/preflight/" -rvf $@.tmp $< && \
58+
gzip < $@.tmp > $@ && \
59+
rm $@.tmp
60+
61+
bundle-all-platforms:
62+
$(MAKE) GOOS=linux GOARCH=amd64 ./bundles/preflight-bundle-linux-amd64.tgz
63+
$(MAKE) GOOS=darwin GOARCH=amd64 ./bundles/preflight-bundle-darwin-amd64.tgz
64+
$(MAKE) GOOS=windows GOARCH=amd64 ./bundles/preflight-bundle-windows-amd64.tgz
65+
66+
# Docker image
3967

4068
build-docker-image:
41-
docker build -t $(IMAGE_NAME) .
69+
docker build --tag $(DOCKER_IMAGE_TAG) .
4270

4371
push-docker-image:
44-
docker push $(IMAGE_NAME)
72+
docker tag $(DOCKER_IMAGE_TAG) $(DOCKER_IMAGE):latest
73+
docker push $(DOCKER_IMAGE_TAG)
74+
docker push $(DOCKER_IMAGE):latest
75+
76+
# CI
77+
78+
ci-test: test lint
79+
80+
ci-build: ci-test build build-docker-image build-all-platforms bundle-all-platforms
81+
82+
ci-publish: ci-build push-docker-image

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ require (
99
github.com/gookit/color v1.2.0
1010
github.com/open-policy-agent/opa v0.15.0
1111
github.com/pkg/errors v0.8.1
12+
github.com/sergi/go-diff v1.0.0 // indirect
1213
github.com/spf13/cobra v0.0.5
1314
github.com/spf13/viper v1.5.0
1415
github.com/yudai/gojsondiff v1.0.0
16+
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
1517
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
1618
google.golang.org/api v0.13.0
1719
gopkg.in/yaml.v2 v2.2.5

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
189189
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
190190
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
191191
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
192+
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
193+
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
192194
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
193195
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
194196
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
@@ -226,6 +228,8 @@ github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vV
226228
github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b/go.mod h1:HptNXiXVDcJjXe9SqMd0v2FsL9f8dz4GnXgltU6q/co=
227229
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
228230
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
231+
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
232+
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
229233
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
230234
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
231235
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
File renamed without changes.

0 commit comments

Comments
 (0)