forked from asciidoctor/docker-asciidoctor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (42 loc) · 1.99 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
export DOCKER_BUILDKIT=1
GIT_TAG = $(shell git describe --exact-match --tags HEAD 2>/dev/null)
ifeq ($(strip $(GIT_TAG)),)
GIT_REF = $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
else
GIT_REF = $(GIT_TAG)
endif
PANDOC_VERSION ?= 2.10.1
all: build test README
build: asciidoctor-minimal.build build-haskell.build asciidoctor.build
%.build:
docker buildx bake $(*) --load --set '*.cache-to=""' --print
docker buildx bake $(*) --load --set '*.cache-to=""'
docker-cache: asciidoctor-minimal.docker-cache build-haskell.docker-cache asciidoctor.docker-cache
%.docker-cache:
docker buildx bake $(*) --print
docker buildx bake $(*)
test: asciidoctor.test
%.test:
bats $(CURDIR)/tests/$(*).bats
deploy: asciidoctor.deploy
%.deploy:
docker buildx bake $(*) --push --print
docker buildx bake $(*) --push
clean:
rm -rf "$(CURDIR)/cache"
cache:
mkdir -p "$(CURDIR)/cache"
cache/pandoc-$(PANDOC_VERSION)-linux.tar.gz: cache
curl -sSL -o "$(CURDIR)/cache/pandoc-$(PANDOC_VERSION)-linux.tar.gz" \
https://github.com/jgm/pandoc/releases/download/$(PANDOC_VERSION)/pandoc-$(PANDOC_VERSION)-linux-amd64.tar.gz
cache/pandoc-$(PANDOC_VERSION)/bin/pandoc: cache/pandoc-$(PANDOC_VERSION)-linux.tar.gz
tar xzf "$(CURDIR)/cache/pandoc-$(PANDOC_VERSION)-linux.tar.gz" -C "$(CURDIR)/cache"
# GitHub renders asciidoctor but DockerHub requires markdown.
# This recipe creates README.md from README.adoc
README: asciidoctor.build cache/pandoc-$(PANDOC_VERSION)/bin/pandoc
docker run --rm -t -v $(CURDIR):/documents --entrypoint bash asciidoctor \
-c "asciidoctor -b docbook -a leveloffset=+1 -o - README.adoc | /documents/cache/pandoc-$(PANDOC_VERSION)/bin/pandoc --atx-headers --wrap=preserve -t gfm -f docbook - > README.md"
deploy-README: README
git add README.adoc README.md && git commit -s -m "Updating README files using 'make README command'" \
&& git push origin $(shell git rev-parse --abbrev-ref HEAD) || echo 'No changes to README files'
.PHONY: all build test deploy clean README deploy-README docker-cache