forked from crossplane/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (75 loc) · 2.91 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
# ====================================================================================
# Colors
BLACK := $(shell printf "\033[30m")
BLACK_BOLD := $(shell printf "\033[30;1m")
RED := $(shell printf "\033[31m")
RED_BOLD := $(shell printf "\033[31;1m")
GREEN := $(shell printf "\033[32m")
GREEN_BOLD := $(shell printf "\033[32;1m")
YELLOW := $(shell printf "\033[33m")
YELLOW_BOLD := $(shell printf "\033[33;1m")
BLUE := $(shell printf "\033[34m")
BLUE_BOLD := $(shell printf "\033[34;1m")
MAGENTA := $(shell printf "\033[35m")
MAGENTA_BOLD := $(shell printf "\033[35;1m")
CYAN := $(shell printf "\033[36m")
CYAN_BOLD := $(shell printf "\033[36;1m")
WHITE := $(shell printf "\033[37m")
WHITE_BOLD := $(shell printf "\033[37;1m")
CNone := $(shell printf "\033[0m")
# ====================================================================================
# Logger
TIME_LONG = `date +%Y-%m-%d' '%H:%M:%S`
TIME_SHORT = `date +%H:%M:%S`
TIME = $(TIME_SHORT)
INFO = echo ${TIME} ${BLUE}[ .. ]${CNone}
WARN = echo ${TIME} ${YELLOW}[WARN]${CNone}
ERR = echo ${TIME} ${RED}[FAIL]${CNone}
OK = echo ${TIME} ${GREEN}[ OK ]${CNone}
FAIL = (echo ${TIME} ${RED}[FAIL]${CNone} && false)
# ====================================================================================
# System Info
# Set the host's OS. Only linux and darwin supported for now.
HOSTOS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifeq ($(filter darwin linux,$(HOSTOS)),)
$(error build only supported on linux and darwin host currently)
endif
# Set the host's arch.
HOSTARCH ?= $(shell uname -m)
# Automatically translate x86_64 to amd64.
ifeq ($(HOSTARCH),x86_64)
HOSTARCH := amd64
endif
# Automatically translate aarch64 to arm64.
ifeq ($(HOSTARCH),aarch64)
HOSTARCH := arm64
endif
# If OS is darwin then hugo uses universal prefix.
ifeq ($(HOSTOS),darwin)
HOSTARCH := universal
endif
# ====================================================================================
# Tools
HUGO_VERSION ?= 0.107.0
HUGO := ./hugo-$(HUGO_VERSION)
$(HUGO):
@$(INFO) installing hugo $(HUGO_VERSION)
@curl -fsSLo $(HUGO).tar.gz https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_extended_$(HUGO_VERSION)_$(HOSTOS)-$(HOSTARCH).tar.gz || $(FAIL)
@tar -zxf $(HUGO).tar.gz hugo || $(FAIL)
@mv hugo $(HUGO) && chmod +x $(HUGO)
@$(OK) finished installing hugo $(HUGO_VERSION)
# ====================================================================================
# Targets
# Run local development server.
run: $(HUGO)
@$(INFO) starting hugo development server
@$(HUGO) server
# Build hugo site.
build: $(HUGO)
@$(INFO) building hugo site
@$(HUGO) --minify --baseURL https://crossplane.io || $(FAIL)
@$(OK) successfully built hugo site
# Validate that hugo builds successfully.
# NOTE(hasheddan): this target exists so that validation can expand to inlude
# other actions rather than just building.
validate: build