-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
52 lines (42 loc) · 1.86 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
VERSION ?= $(shell git describe --tags --always )
TARGET ?= $(shell basename `git rev-parse --show-toplevel`)
TEST ?= $(shell go list ./... | grep -v /vendor/)
REPOSITORY := mattdeboer/assert-aws-iam-permissions
DOCKER_IMAGE ?= ${REPOSITORY}:${VERSION}
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
REVISION ?= $(shell git rev-parse HEAD)
LD_FLAGS ?= -s -X github.com/matt-deboer/assert-aws-iam-permissions/pkg/version.Name=$(TARGET) \
-X github.com/matt-deboer/assert-aws-iam-permissions/pkg/version.Revision=$(REVISION) \
-X github.com/matt-deboer/assert-aws-iam-permissions/pkg/version.Branch=$(BRANCH) \
-X github.com/matt-deboer/assert-aws-iam-permissions/pkg/version.Version=$(VERSION)
default: test build
test:
go test -v -cover -run=$(RUN) $(TEST)
build: clean
@go build -v -o bin/$(TARGET) -ldflags "$(LD_FLAGS)+local_changes" ./pkg/cmd
release: clean
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build \
-a -tags netgo \
-a -installsuffix cgo \
-ldflags "$(LD_FLAGS)" \
-o bin/darwin-amd64-$(TARGET) ./pkg/cmd
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
-a -tags netgo \
-a -installsuffix cgo \
-ldflags "$(LD_FLAGS)" \
-o bin/linux-amd64-$(TARGET) ./pkg/cmd
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build \
-a -tags netgo \
-a -installsuffix cgo \
-ldflags "$(LD_FLAGS)" \
-o bin/windows-amd64-$(TARGET) ./pkg/cmd
ca-certificates.crt:
@-docker rm -f assert-aws-iam-permissions_cacerts
@docker run --name assert-aws-iam-permissions_cacerts debian:latest bash -c 'apt-get update && apt-get install -y ca-certificates'
@docker cp assert-aws-iam-permissions_cacerts:/etc/ssl/certs/ca-certificates.crt .
@docker rm -f assert-aws-iam-permissions_cacerts
docker: ca-certificates.crt
@echo "Building ${DOCKER_IMAGE}..."
@docker build -t ${DOCKER_IMAGE} -f Dockerfile .
clean:
@rm -rf bin/