-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
113 lines (87 loc) · 3.28 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
113
# Recipes for building release artifacts
#
# Expects the artifact to be in the format
#
# `apie-VERSION-ARCH.EXT
#
# Where VERSION matches the current git tag (like `v0.0.1-SNAPSHOT`)
#
# And ARCH.EXT is some reasonable combination, like
# `linux-amd64.tar.gz`, `standalone.jar` or `windows-amd64.zip`
#
# Standalone binaries are supported for every platform supported by
# babashka (variants of linux, windows and macos), see
# https://github.com/babashka/babashka/releases
#
# In other words, `make apie-$VERSION-windows-amd64.zip`
# and `make apie-$VERSION-macos-aarch64.tar.gz` will do
# what you expect as long as $VERSION is the currently tagged version
BB:=bb
version:=$(shell git describe --tags)
baked_version:=$(shell cat "src/nl/jomco/apie/version.txt")
# need latest snapshot for standalone executables
BABASHKA_VERSION:=1.3.188
.PHONY: uberjar bake-version
exec_base_name=apie
release_name=$(exec_base_name)-$(version)
source_files=$(shell find src assets -type f)
current_arch=$(shell bb dev/current_arch.clj)
# uberjar is the babashka uberjar (not a java-compatible jar)
uberjar=$(exec_base_name)-$(version)-standalone.jar
uberjar: $(uberjar)
$(uberjar): deps.edn bb.edn $(source_files) bake-version
rm -f $@
$(BB) uberjar $@ -m nl.jomco.apie.main
bake-version:
if [ "$(version)" != "$(baked_version)" ]; then echo "$(version)" >src/nl/jomco/apie/version.txt; fi
release: $(binary_release)
# for unixy systems
$(release_name)-%/$(exec_base_name): babashka-$(BABASHKA_VERSION)-%.tar.gz $(uberjar)
mkdir -p $(dir $@)
tar -zxO <$< >$@
cat $(uberjar) >>$@
chmod 755 $@
# for windows
$(release_name)-%/$(exec_base_name).exe: babashka-$(BABASHKA_VERSION)-%.zip $(uberjar)
mkdir -p $(dir $@)
unzip -p $< >$@
cat $(uberjar) >>$@
babashka-$(BABASHKA_VERSION)-%:
curl -sL https://github.com/babashka/babashka-dev-builds/releases/download/v$(BABASHKA_VERSION)/$@ -o $@
# for unixy systems
$(release_name)-%.tar.gz: $(release_name)-%/$(exec_base_name)
tar -rf tmp.tar $<
gzip <tmp.tar >$@
rm tmp.tar
# for windows
$(release_name)-%.zip: $(release_name)-%/$(exec_base_name).exe
zip -r $@ $(basename $@)
# build for local use, on windows
$(exec_base_name).exe: $(release_name)-$(current_arch)/$(exec_base_name).exe
cp $< $@
# build for local use, non-windows
$(exec_base_name): $(uberjar)
cat $(shell which bb) $(uberjar) >$@
chmod 755 $@
usage.txt.generated: $(exec_base_name)
echo "\`\`\`" >$@
"./$(exec_base_name)" --help |sed -n '/^Usage:/,/\Z/p' >>$@
echo "\`\`\`" >>$@
README.md: usage.txt.generated README.src.md
echo "<!-- WARNING! THIS FILE IS GENERATED, EDIT README.src.md INSTEAD -->" >$@
sed "/<!-- INCLUDE USAGE HERE -->/r $<" README.src.md >>$@
# This regenerates README to make sure it's in sync with committed version
working_tree_clean_check: README.md
# git-status --porcelain should print 0 lines. wc -l counts lines
# tee /dev/fd/2 prints any uncommitted changes to stderr for logging in CI
exit $$(git status --porcelain |tee /dev/fd/2| wc -l)
test:
clojure -M:test
bb -Sdeps '{:deps {lambdaisland/kaocha {:mvn/version "RELEASE"}}}' -m kaocha.runner/-main
lint:
clojure -M:clj-kondo --lint src test
check: test lint
release_check: working_tree_clean_check check outdated
outdated:
clojure -M:outdated
.PHONY: check lint outdated release_check test working_tree_clean_check