forked from libp2p/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (63 loc) · 1.74 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
SHELL=/bin/bash
DOMAIN="docs.libp2p.io"
IPFSLOCAL="http://localhost:8080/ipfs/"
IPFSGATEWAY="https://ipfs.io/ipfs/"
NPM=npm
NPMBIN=./node_modules/.bin
OUTPUTDIR=public
PKGDIR=content/reference/pkg
PORT=1313
ifeq ($(DEBUG), true)
PREPEND=
APPEND=
else
PREPEND=@
APPEND=1>/dev/null
endif
# Where Hugo should be installed locally
HUGO_LOCAL=./bin/hugo
# Path to Hugo binary to use when building the site
HUGO_BINARY=$(HUGO_LOCAL)
HUGO_VERSION=0.54.0
PLATFORM:=$(shell uname)
ifeq ('$(PLATFORM)', 'Darwin')
PLATFORM=macOS
endif
MACH:=$(shell uname -m)
ifeq ('$(MACH)', 'x86_64')
MACH=64bit
else
MACH=32bit
endif
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_$(HUGO_VERSION)_$(PLATFORM)-$(MACH).tar.gz"
bin/hugo:
@echo "Installing Hugo to $(HUGO_LOCAL)..."
$(PREPEND)mkdir -p tmp_hugo $(APPEND)
$(PREPEND)curl --location "$(HUGO_URL)" | tar -xzf - -C tmp_hugo && chmod +x tmp_hugo/hugo && mv tmp_hugo/hugo $(HUGO_LOCAL) $(APPEND)
$(PREPEND)rm -rf tmp_hugo $(APPEND)
install: bin/hugo
build: clean install
$(PREPEND)$(HUGO_BINARY) && \
echo "" && \
echo "Site built out to ./$(OUTPUTDIR)"
dev: bin/hugo
$(PREPEND)( \
$(HUGO_BINARY) server -w --port $(PORT) --bind 0.0.0.0 \
)
serve:
$(PREPEND)$(HUGO_BINARY) server
deploy:
export hash=`ipfs add -r -Q $(OUTPUTDIR)`; \
echo ""; \
echo "published website:"; \
echo "- $(IPFSLOCAL)$$hash"; \
echo "- $(IPFSGATEWAY)$$hash"; \
echo ""; \
echo "next steps:"; \
echo "- ipfs pin add -r /ipfs/$$hash"; \
echo "- make publish-to-domain"
clean:
$(PREPEND)[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
$(PREPEND)[ ! -d $(PKGDIR) ] || rm -rf $(PKGDIR)/*/
$(PREPEND)[ ! -d build/assets ] || rm -rf build/assets/*
.PHONY: build help deploy publish-to-domain clean