-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmakefile
More file actions
119 lines (103 loc) · 3.67 KB
/
makefile
File metadata and controls
119 lines (103 loc) · 3.67 KB
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
113
114
115
116
117
118
119
# Masterblaster makefile
#
# Based around the auto-documented Makefile:
# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
BIN_NAME := mb
VERSION ?= $(shell git describe --tags --always --dirty)
COMMIT ?= $(shell git rev-parse HEAD)
BUILDTIME ?= $(shell date -u '+%Y-%m-%d %H:%M:%S')
POSTHOG_API_KEY ?=
LDFLAGS := -s -w \
-X 'github.com/papercomputeco/masterblaster/pkg/utils.Version=$(VERSION)' \
-X 'github.com/papercomputeco/masterblaster/pkg/utils.Sha=$(COMMIT)' \
-X 'github.com/papercomputeco/masterblaster/pkg/utils.Buildtime=$(BUILDTIME)' \
-X 'github.com/papercomputeco/masterblaster/pkg/telemetry.PostHogAPIKey=$(POSTHOG_API_KEY)'
.PHONY: build
build: ## Builds all cross-platform release artifacts via Dagger
dagger call \
build-release \
--version $(VERSION) \
--commit $(COMMIT) \
--post-hog-public-key="$(POSTHOG_API_KEY)" \
export \
--path ./build
.PHONY: build-local
build-local: ## Builds local artifacts with local toolchain
$(call print-target)
@mkdir -p ./build/local
go build -ldflags "$(LDFLAGS)" -o ./build/local/$(BIN_NAME) .
.PHONY: apple-build
apple-build: ## Apple: builds darwin/arm64 binary with codesign
$(call print-target)
@if [ "$$(uname -s)" != "Darwin" ]; then \
echo "Error: apple-build requires macOS (got $$(uname -s))"; \
exit 1; \
fi
@mkdir -p ./build/darwin/arm64
go build -ldflags "$(LDFLAGS)" -o ./build/darwin/arm64/$(BIN_NAME) .
codesign --entitlements vz.entitlements -s - ./build/darwin/arm64/$(BIN_NAME)
.PHONY: apple-install
apple-install: build-local ## Apple: builds, installs to GOBIN, and codesigns binary
$(call print-target)
@if [ "$$(uname -s)" != "Darwin" ]; then \
echo "Error: apple-install requires macOS (got $$(uname -s))"; \
exit 1; \
fi
rm -f $(shell go env GOBIN)/$(BIN_NAME)
cp ./build/local/$(BIN_NAME) $(shell go env GOBIN)
codesign --entitlements vz.entitlements -s - $(shell go env GOBIN)/$(BIN_NAME)
.PHONY: upload-darwin-artifacts
upload-darwin-artifacts: ## Uploads the install script
dagger call \
upload-darwin-artifacts \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--binary=./build/darwin/arm64/mb \
--bucket=env://BUCKET_NAME \
--checksum=./build/darwin/arm64/mb.sha256 \
--endpoint=env://BUCKET_ENDPOINT \
--prefixes="${VERSION}/darwin/arm64" \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
.PHONY: upload-install-script
upload-install-script: ## Uploads the install script
dagger call \
upload-install-sh \
--endpoint=env://BUCKET_ENDPOINT \
--bucket=env://BUCKET_NAME \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
.PHONY: release
release: ## Builds and releases mb artifacts
dagger call \
release-latest \
--version=${VERSION} \
--commit=${COMMIT} \
--post-hog-public-key="$(POSTHOG_API_KEY)" \
--endpoint=env://BUCKET_ENDPOINT \
--bucket=env://BUCKET_NAME \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
.PHONY: nightly
nightly: ## Builds and releases mb artifacts with the nightly tag
dagger call \
release-nightly \
--commit=${COMMIT} \
--post-hog-public-key="$(POSTHOG_API_KEY)" \
--endpoint=env://BUCKET_ENDPOINT \
--bucket=env://BUCKET_NAME \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
check:
dagger check
fmt:
go fmt ./...
vet:
go vet ./...
clean:
rm -rf ./build/
.PHONY: help
.DEFAULT_GOAL := help
help: ## Prints this help message
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef