forked from trustoverip/TIP0028-saturn-v
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (100 loc) · 5 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
117
118
119
120
121
122
123
124
125
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
# DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
# LIMITATIONS UNDER THE LICENSE.
# -----------------------------------------------------------------------------
# Makefile
#
# setup: Prepare Development and Publication environments
# rebase: Rebase local machine environment with upstream repo
# merge: Rebase local machine environment with template repo
# devenv: Prepare development environemnt
# pubenv: Prepare publication environemnt
# dev: Generates HTML content derived from markdown docs
# test: Runs test server using current HTML content
# combine: Generate a standalone document from multiple markdown files
# publish: Generate HTML and PDF versions of content
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Special targets
# -----------------------------------------------------------------------------
.PHONY: help clean
.DEFAULT_GOAL: help
# -----------------------------------------------------------------------------
# Variables
# -----------------------------------------------------------------------------
# Repo Instance Specific
REPO_NAME ?= TIP0028-saturn-v
UPSTREAM_REPO ?= https://github.com/trustoverip/TIP0028-saturn-v.git
DEV_SITE_PORT ?= 7528
# Template Repo Defaults
TEMPLATE_REPO ?= https://github.com/trustoverip/mkdocs-material.git
DEV_IMAGE ?= trustoverip/mkdocs-material-devenv
PANDOCS_IMAGE ?= trustoverip/pandocs-devenv
DEV_HOST_DIR ?= host_mkdocs
PUB_HOST_DIR ?= host_pandocs
PUBLISH_DIR ?= publish
# -----------------------------------------------------------------------------
# All Purpose Commands
# -----------------------------------------------------------------------------
help:
@echo "\n"$(REPO_NAME)"\n"
@(grep -h "##" Makefile | tail -9) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# -----------------------------------------------------------------------------
# Targets
# -----------------------------------------------------------------------------
# Clean all build files
clean:
rm -rf $(PUBLISH_DIR)
# Prepare Git environment
prepare_git:
git remote remove upstream; git remote add upstream $(UPSTREAM_REPO); git remote -v
git remote remove template; git remote add template $(TEMPLATE_REPO); git remote -v
# Build all required Docker images
build_images: ./docker/mkdocs/Dockerfile ./docker/pandocs/Dockerfile
docker build -t $(DEV_IMAGE) - < ./docker/mkdocs/Dockerfile
docker build -t $(PANDOCS_IMAGE) - < ./docker/pandocs/Dockerfile
docker images | grep -h "trustoverip"
# Publication directory
prepare_pandocs:
mkdir -p $(PUBLISH_DIR)
# -----------------------------------------------------------------------------
# Local Environment (Docker Host) Commands
# -----------------------------------------------------------------------------
setup: prepare_git build_images ## Prepare Development and Publication environments
chmod +x ./scripts/combine.sh; ls -la ./scripts/
chmod +x ./scripts/combine/preprocess.py; ls -la scripts/combine/
rebase: ## Rebase local machine environment with upstream repo
git fetch upstream
git rebase upstream/master; git rebase upstream/main
merge: ## Merge local machine environment with template repo
git fetch template
git merge template/main --allow-unrelated-histories
devenv: ## Prepare development environemnt
docker run -ti -v ${PWD}:/$(DEV_HOST_DIR) -p $(DEV_SITE_PORT):8000 --entrypoint=/bin/bash $(DEV_IMAGE)
pubenv: clean prepare_pandocs ## Prepare print environemnt
docker run -ti -v ${PWD}:/$(PUB_HOST_DIR) --entrypoint=/bin/bash $(PANDOCS_IMAGE)
# -----------------------------------------------------------------------------
# MkDocs Container Commands
# -----------------------------------------------------------------------------
dev : ## Generates HTML content derived from markdown files
mkdocs build
test : ## Run test server using current HTML content
@echo "Launching Test Server for access via http://localhost:"$(DEV_SITE_PORT)
mkdocs serve --dev-addr=0.0.0.0:8000
# -----------------------------------------------------------------------------
# PanDoc Container Commands
# -----------------------------------------------------------------------------
combine: mkdocs.yml $(shell find docs -name "*.md") ## Generate standalone document
./scripts/combine.sh > $(PUBLISH_DIR)/$(REPO_NAME).md
publish: combine ## Generate publication formats (HTML, PDF)
pandoc $(PUBLISH_DIR)/$(REPO_NAME).md -o $(PUBLISH_DIR)/$(REPO_NAME).html
pandoc $(PUBLISH_DIR)/$(REPO_NAME).md --pdf-engine=xelatex -o $(PUBLISH_DIR)/$(REPO_NAME).pdf
ls -la $(PUBLISH_DIR)