-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (44 loc) · 1.47 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
GO = go
LDFLAGS = -s -w
CNAMESFN = pkg/keyboard/colornames.csv.gz
APPNAME = $(shell awk '/^name:/{print $$2}' buildinfo/app.yml)
VERSION = $(strip $(shell git describe --tags --abbrev=0 --dirty --always))
COMMITHASH = $(strip $(shell git rev-parse --short HEAD))
BUILDTIME = $(strip $(shell date -u +%Y-%m-%dT%H:%M:%SZ))
test: build
./$(APPNAME) set list >/dev/null
build: $(CNAMESFN) $(APPNAME)
$(APPNAME): $(shell find -name '*.go')
$(RM) $@ # to make it obvious when watch fails
$(GO) generate ./...
$(GO) build -ldflags='$(LDFLAGS)' -o $@
watch: .reflex_installed build
reflex -r '\.(go)$$' -d fancy $(MAKE) build
tag: tag-patch
tag-%:
test $$(git rev-parse --abbrev-ref HEAD) = 'main'
git pull
git push
./scripts/bump.sh -p v $*
echo -n "git push --atomic origin main v$$(./scripts/bump.sh -p v -l)" | xclip -sel clip -i
appname:
@echo -n $(APPNAME)
define BUILDINFO
build_time: $(BUILDTIME)
commit_hash: $(COMMITHASH)
version: $(VERSION)
endef
export BUILDINFO
buildinfo:
echo "$$BUILDINFO" | tee buildinfo/build.yml
# grab the list of simple color names (the full list is quite large)
$(CNAMESFN):
curl -sS https://raw.githubusercontent.com/meodai/color-names/master/src/colornames.csv | \
awk -F, '$$1 ~ /^[a-zA-Z]+$$/' | \
gzip > $@
.reflex_installed:
which reflex >/dev/null 2>&1 || ( cd ~ && go install github.com/cespare/reflex@latest )
touch $@
clean:
$(RM) .reflex_installed $(APPNAME) buildinfo/build.yml $(CNAMESFN)
.PHONY: build appname buildinfo clean