forked from BattModels/BattModels.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (98 loc) · 3.71 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
# targets that aren't filenames
.PHONY: all clean deploy-publish deploy-preview deploy-github build serve test
all: build
clean:
$(RM) -r _site _site-publish $(BIB_FILES)
# Build the site
build: _site/
BIBBLE = bibble
# Delete targets that fail to build
.DELETE_ON_ERROR:
# Install Gemfiles
TOOLS := Gemfile.lock pip.install
Gemfile.lock: Gemfile
bundle install
touch $@
# Install Python dependencies
pip.install: requirements.txt
python -m pip install --user -r requirements.txt 2>&1 | tee $@
# Source Files
# This builds a list of files that make up the website
# Files in the root directory are only added if *.html/*.md and are tracked by
# git.
dirs := _data _includes _layouts _posts _projects bib css img js
SRC := $(foreach dir, $(dirs), $(wildcard $(dir)/*))
SRC += $(shell git ls-tree -r --name-only HEAD -- *.md)
SRC += $(shell git ls-tree -r --name-only HEAD -- *.html)
SRC += _config.yml
# Generate HTML files for publications
.DELETE_ON_ERROR: _includes/%.html
BIB_FILES := _includes/pubs.html _includes/patents.html
_includes/%.html: bib/%.bib bib/publications.tmpl
mkdir -p _includes
$(BIBBLE) $+ > $@
# Build target for previewing on AWPS
PREVIEW_DIR ?= /collections/venkatgroup
_site/ : $(BIB_FILES) $(SRC) $(TOOLS)
rm -rf $@
bundle exec jekyll build -d $(join $@, $(PREVIEW_DIR)) -b $(PREVIEW_DIR)
touch $@
# Build target for publishing to AWPS
PUBLISH_DIR ?= /me/venkatgroup
_site-publish/ : $(BIB_FILES) $(SRC) $(TOOLS)
rm -rf $@
JEKYLL_ENV=production \
bundle exec jekyll build -d $(join $@, $(PUBLISH_DIR)) -b $(PUBLISH_DIR)
touch $@
# Build and serve the site for viewing locally
# Note: This will update most pages as you edit them, except for ones generated
# externally to Jekyll. (Think Biblography pages). You can regenerate those, but
# running `make build` in a seperate shell. Jeykell then reload with the updated
# pages
# you can configure these at the shell, e.g.:
# SERVE_PORT=5001 make serve
SERVE_HOST ?= 127.0.0.1
SERVE_PORT ?= 5000
serve: _site/ Gemfile.lock
bundle exec jekyll serve -l -I \
-b $(PREVIEW_DIR) -d $<$(PREVIEW_DIR) \
--port $(SERVE_PORT) --host $(SERVE_HOST)
# Deploy Recipes
# deploy-publish: Copies the locally build publishable site to AWPS (Not Recommended)
# deploy-preview: Copies the locally built preview site to AWPS (DO NOT PUBLISH)
# deploy-github: Copies the latest released version of the site to AWPS (Recommended)
#
# Configuration Options (Set on CLI)
# DEPLOY_HOST rclone host for AWPS
# RELEASE_URL Location of the released zip file on github. Correctly set if cloned via https
# PREVIEW_DIR Folder on AWPS where files are copied
DEPLOY_HOST ?= cmu-awps
RELEASE_URL ?= https://github.com/BattModels/group-website/releases/download/latest/site-publish.zip
deploy-publish: _site-publish/
rclone sync -P $<$(PUBLISH_DIR) $(DEPLOY_HOST):$(PREVIEW_DIR)
deploy-preview: _site/
rclone sync -P $<$(PREVIEW_DIR) $(DEPLOY_HOST):$(PREVIEW_DIR)
deploy-github:
curl -L $(RELEASE_URL) -o github-publish.zip
unzip -o -d github-publish github-publish
rclone sync -P -v --sftp-disable-hashcheck github-publish $(DEPLOY_HOST):$(PREVIEW_DIR)
rm -rf github-publish github-publish.zip
# Run test on the website using htmlproofer
test: _site/ _site-publish/ $(TOOLS)
@echo "Running pre-commit"
pre-commit run -a
@echo "Checking _data/people.yml"
python3 dev/check_people.py
@echo "Checking preview version"
bundle exec htmlproofer \
--disable-external \
--check-html --check-img-http --enforce-https \
_site
@echo "Checking published version"
bundle exec htmlproofer \
--disable-external \
--check-html --check-img-http --enforce-https \
_site-publish/
# Archive Site for Publishing
site-publish.zip: _site-publish/
cd _site-publish/$(PUBLISH_DIR) && zip -r $(abspath site-publish.zip) .