forked from awslabs/amazon-ecr-credential-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (91 loc) · 3.49 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
ROOT := $(shell pwd)
all: build
SOURCEDIR=./ecr-login
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
VERSION := $(shell cat VERSION)
GITFILES := $(shell test -d .git && find ".git/" -type f)
BINARY_NAME=docker-credential-ecr-login
LOCAL_BINARY=bin/local/$(BINARY_NAME)
LINUX_AMD64_BINARY=bin/linux-amd64/$(BINARY_NAME)
LINUX_ARM64_BINARY=bin/linux-arm64/$(BINARY_NAME)
DARWIN_AMD64_BINARY=bin/darwin-amd64/$(BINARY_NAME)
DARWIN_ARM64_BINARY=bin/darwin-arm64/$(BINARY_NAME)
WINDOWS_AMD64_BINARY=bin/windows-amd64/$(BINARY_NAME).exe
.PHONY: docker
docker: Dockerfile GITCOMMIT_SHA
mkdir -p bin
docker run --rm \
-e TARGET_GOOS=$(TARGET_GOOS) \
-e TARGET_GOARCH=$(TARGET_GOARCH) \
-v '$(shell pwd)/bin':/go/src/github.com/awslabs/amazon-ecr-credential-helper/bin \
$(shell docker build -q .)
.PHONY: build
build: $(LOCAL_BINARY)
$(LOCAL_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_binary.sh ./bin/local $(VERSION) $(shell cat GITCOMMIT_SHA)
@echo "Built ecr-login"
.PHONY: test
test:
cd $(SOURCEDIR) && go test -v -timeout 30s -short -cover ./...
.PHONY: all-variants
all-variants: linux-amd64 linux-arm64 darwin-amd64 darwin-arm64 windows-amd64
.PHONY: linux-amd64
linux-amd64: $(LINUX_AMD64_BINARY)
$(LINUX_AMD64_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_variant.sh linux amd64 $(VERSION) $(shell cat GITCOMMIT_SHA)
.PHONY: linux-arm64
linux-arm64: $(LINUX_ARM64_BINARY)
$(LINUX_ARM64_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_variant.sh linux arm64 $(VERSION) $(shell cat GITCOMMIT_SHA)
.PHONY: darwin-amd64
darwin-amd64: $(DARWIN_AMD64_BINARY)
$(DARWIN_AMD64_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_variant.sh darwin amd64 $(VERSION) $(shell cat GITCOMMIT_SHA)
.PHONY: darwin-arm64
darwin-arm64: $(DARWIN_ARM64_BINARY)
$(DARWIN_ARM64_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_variant.sh darwin arm64 $(VERSION) $(shell cat GITCOMMIT_SHA)
.PHONY: windows-amd64
windows-amd64: $(WINDOWS_AMD64_BINARY)
$(WINDOWS_AMD64_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_variant.sh windows amd64 $(VERSION) $(shell cat GITCOMMIT_SHA)
@mv ./bin/windows-amd64/$(BINARY_NAME) ./$(WINDOWS_AMD64_BINARY)
GITCOMMIT_SHA: $(GITFILES)
git rev-parse --short=7 HEAD > GITCOMMIT_SHA
release.tar: GITCOMMIT_SHA
git archive -o release.tar HEAD
tar -f release.tar --append GITCOMMIT_SHA --owner 0 --group 0
.PHONY: release-tarball
release-tarball: release.tar.gz
release.tar.gz: release.tar
gzip release.tar
.PHONY: release-tarball-no-vendor
release-tarball-no-vendor: release-novendor.tar.gz
release-novendor.tar.gz: release.tar
mv release.tar release-novendor.tar
tar -f release-novendor.tar --wildcards --delete 'ecr-login/vendor/*'
gzip release-novendor.tar
.PHONY: gogenerate
gogenerate:
./scripts/gogenerate
.PHONY: get-deps
get-deps:
go install golang.org/x/tools/cmd/goimports@698251aaa532d49ac69d2c416b0241afb2f65ea5
.PHONY: clean
clean:
- rm -rf ./bin
- rm -f GITCOMMIT_SHA
- rm -f release.tar.gz
- rm -f release-novendor.tar.gz