-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (32 loc) · 1.34 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
-include .env
VERSION=v0.1.2
BUILD_OS=linux # darwin windows
BUILD_ARCH=amd64 arm64
BUILD_OA=$(foreach os,$(BUILD_OS),$(addprefix $(os).,$(BUILD_ARCH)))
BUILD=$(addprefix build.,$(BUILD_OA))
PUBLISH=$(addprefix publish.,$(BUILD_OA))
ARCH=$(subst .,,$(suffix $@))
OS=$(subst .,,$(suffix $(basename $@)))
$(BUILD):
@echo "building $(OS) $(ARCH)"
@mkdir -p bin
@GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags="-w -s -X main.Version=$(VERSION)" -o bin/subcommander-$(OS)-$(ARCH)-$(VERSION) cmd/main.go
@cd bin && sha256sum subcommander-$(OS)-$(ARCH)-$(VERSION) > subcommander-$(OS)-$(ARCH)-$(VERSION).sha256sum
build: $(BUILD)
# publish: upload to s3 the same version in both archs
# run with infra-prod user
publish: $(PUBLISH)
$(PUBLISH):
@echo "publish $(OS) $(ARCH)"
@echo "upload binaries/subcommander/subcommander-$(OS)-$(ARCH)-$(VERSION)"
@aws s3api put-object \
--cache-control max-age=31536000 \
--bucket $(BUCKET) \
--key binaries/subcommander/subcommander-$(OS)-$(ARCH)-$(VERSION)\
--body bin/subcommander-$(OS)-$(ARCH)-$(VERSION)
@echo "upload binaries/subcommander/subcommander-$(OS)-$(ARCH)-$(VERSION).sha256sum"
@aws s3api put-object \
--cache-control max-age=31536000 \
--bucket $(BUCKET) \
--key binaries/subcommander/subcommander-$(OS)-$(ARCH)-$(VERSION).sha256sum \
--body bin/subcommander-$(OS)-$(ARCH)-$(VERSION).sha256sum