forked from src-d/landing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
116 lines (96 loc) · 2.7 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
114
115
116
# Config
PROJECT := landing
COMMANDS := api
CODECOV_TOKEN ?=
DESTINATION ?= public
PORT ?= 8181
DOCKERFILES = Dockerfile:landing Dockerfile.api:landing-api Dockerfile.slackin:landing-slackin
HUGO_VERSION := 0.21
OS := Linux
HUGO_TAR_FILE_NAME = hugo_$(HUGO_VERSION)_$(OS)-64bit.tar.gz
HUGO_URL = https://github.com/spf13/hugo/releases/download/v$(HUGO_VERSION)/$(HUGO_TAR_FILE_NAME)
# Including devops Makefile
MAKEFILE_CI := Makefile.main
CI_REPOSITORY := https://github.com/src-d/ci.git
CI_FOLDER := .ci
$(MAKEFILE_CI):
@git clone --quiet $(CI_REPOSITORY) $(CI_FOLDER); \
cp $(CI_FOLDER)/$(MAKEFILE_CI) .;
-include $(MAKEFILE_CI)
# Including doc-site-generator Makefile
MAKEFILE_DOC_SITE_GEN := doc-site-generator/Makefile
-include $(MAKEFILE_DOC_SITE_GEN)
# CI
TAG := master
ifneq ($(origin TRAVIS_TAG), undefined)
ifneq ($(TRAVIS_TAG),)
TAG := $(TRAVIS_TAG)
endif
endif
# Environment
UNAME_S := $(shell uname -s)
BASE_PATH := $(shell pwd)
HUGO_PATH := $(BASE_PATH)/.hugo
HUGO_NAME := hugo
WORKDIR := $(PWD)
BUILD_PATH := $(WORKDIR)/build
LANDING_ARTIFACT := landing_$(TAG).tar.gz
# System
ifneq ($(UNAME_S),Linux)
ifeq ($(UNAME_S),Darwin)
OS := macOS
else
$(error "error Unexpected OS; Only Linux or Darwin supported.")
endif
endif
# Tools
CURL := curl -L
HUGO := $(HUGO_PATH)/$(HUGO_NAME)
MKDIR := mkdir -p
GIT := git
JS_PACKAGE_MANAGER := yarn
CGO_ENABLED := 0
MOVE := mv -f
REMOVE := rm -rf
COMPRESS := tar -zcf
UNCOMPRESS := tar -zxf
COPY := cp -R
export CGO_ENABLED
## Lists all recipes
list:
@grep '^##' Makefile -A 1
# Updates hugo dependencies
hugo-dependencies:
@if [[ ! -f $(HUGO) ]]; then \
$(MKDIR) $(HUGO_PATH); \
cd $(HUGO_PATH); \
echo "Downloading $(HUGO_URL)"; \
$(CURL) $(HUGO_URL) -o $(HUGO_TAR_FILE_NAME); \
$(UNCOMPRESS) $(HUGO_TAR_FILE_NAME); \
fi;
# Prepares yarn
js-dependencies:
$(JS_PACKAGE_MANAGER) install --force
$(JS_PACKAGE_MANAGER) run build
## Builds project
build: project-dependencies hugo-build
## Serves the project and the API with Hugo and Webpack watchers
serve: hugo-clean project-dependencies
$(JS_PACKAGE_MANAGER) run serve
# Serves the project with Hugo and Webpack watchers
serve-without-api: hugo-clean project-dependencies
$(JS_PACKAGE_MANAGER) run serve-without-api
# Prepares project dependencies
project-dependencies: hugo-dependencies js-dependencies
# Deletes the hugo folder
hugo-clean:
$(REMOVE) $(HUGO_PATH)
# Builds hugo
hugo-build:
$(HUGO) --config=hugo.config.yaml --destination=$(DESTINATION)
# Runs hugo server
hugo-server:
$(HUGO) server --config=hugo.config.yaml --destination=public --port=$(PORT) --watch --buildDrafts
# Packages the landing artifact in the build directory
package-hugo-generated:
$(COMPRESS) $(BUILD_PATH)/$(LANDING_ARTIFACT) public