-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (76 loc) · 2.07 KB
/
Copy pathMakefile
File metadata and controls
85 lines (76 loc) · 2.07 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
APP := github-grid-editor
DIST := dist
TARGETS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64
.PHONY: build build-all archives checksums print-tag release publish clean
build:
go build -o $(APP) .
build-all:
@mkdir -p $(DIST)
@set -e; \
for target in $(TARGETS); do \
os=$${target%/*}; \
arch=$${target#*/}; \
bin="$(DIST)/$(APP)-$$os-$$arch"; \
if [ "$$os" = "windows" ]; then \
bin="$$bin.exe"; \
fi; \
echo "building $$bin"; \
GOOS=$$os GOARCH=$$arch go build -o "$$bin" .; \
done
archives: build-all
@set -e; \
for target in $(TARGETS); do \
os=$${target%/*}; \
arch=$${target#*/}; \
bin="$(APP)-$$os-$$arch"; \
archive_base="$(APP)_$$os_$$arch"; \
if [ "$$os" = "windows" ]; then \
(cd "$(DIST)" && zip -q -j "$$archive_base.zip" "$$bin.exe"); \
else \
(cd "$(DIST)" && tar -czf "$$archive_base.tar.gz" "$$bin"); \
fi; \
done
checksums: archives
@(cd "$(DIST)" && shasum -a 256 *.tar.gz *.zip > checksums.txt)
print-tag:
@git fetch --tags --quiet >/dev/null 2>&1 || true; \
tag="$(TAG)"; \
if [ -z "$$tag" ]; then \
latest=$$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | sed -n '1p'); \
if [ -n "$$latest" ]; then \
major=$${latest#v}; \
major=$${major%%.*}; \
rest=$${latest#v$$major.}; \
minor=$${rest%%.*}; \
tag="v$$major.$$((minor + 1)).0"; \
else \
tag="v0.1.0"; \
fi; \
fi; \
printf '%s\n' "$$tag"
release: checksums
@gh auth status >/dev/null
@git fetch --tags --quiet >/dev/null 2>&1 || true; \
tag="$(TAG)"; \
if [ -z "$$tag" ]; then \
latest=$$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | sed -n '1p'); \
if [ -n "$$latest" ]; then \
major=$${latest#v}; \
major=$${major%%.*}; \
rest=$${latest#v$$major.}; \
minor=$${rest%%.*}; \
tag="v$$major.$$((minor + 1)).0"; \
else \
tag="v0.1.0"; \
fi; \
fi; \
echo "creating release $$tag"; \
gh release create "$$tag" \
"$(DIST)"/*.tar.gz \
"$(DIST)"/*.zip \
"$(DIST)"/checksums.txt \
--title "$$tag" \
--generate-notes
publish: release
clean:
rm -rf $(DIST) $(APP)