forked from ResearchObject/ro-crate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (115 loc) · 7.25 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
## See RELEASE_PROCEDURE.md
# Where to copy from
DRAFT=1.2-DRAFT
# Official release
RELEASE=1.1
# Semantic versioning
TAG=1.1.1
NEXT=1.2-DRAFT
# Prepare (but do not Publish!) the next version of https://zenodo.org/record/3541888
# then copy its DOI here so it can be included in generated HTML/PDF
DOI=10.5281/zenodo.4541002
all: dependencies release
# Check dependencies before we do the rest
dependencies: node_modules/.bin/makehtml
scripts/schema-context.py --version
node_modules/.bin/makehtml --version
pandoc --version
xelatex --version
clean:
rm -rf release "docs/${RELEASE}/"
release: release/ro-crate-${TAG}.html release/ro-crate-${TAG}.pdf release/ro-crate-context-${TAG}.jsonld release/ro-crate-metadata.json release/ro-crate-preview.html
# Install dependencies for node
node_modules/.bin/makehtml:
npm install lodash
npm install ro-crate
docs/${RELEASE}/:
mkdir -p docs/${RELEASE}/
docs/${RELEASE}/_metadata.liquid: docs/${RELEASE}/ docs/${DRAFT}/_metadata.liquid
sed s/${DRAFT}/${RELEASE}/g < docs/${DRAFT}/_metadata.liquid > docs/${RELEASE}/_metadata.liquid
sed -i s/TAG/${TAG}/g docs/${RELEASE}/_metadata.liquid
sed -i "/^<!-- NOTE: Before release.*/ d" docs/${RELEASE}/_metadata.liquid
sed -i "/^END NOTE -->/ d" docs/${RELEASE}/_metadata.liquid
sed -i "s/^* Status:.*/* Status: Recommendation/" docs/${RELEASE}/_metadata.liquid
sed -i "s/^* Published:.*/* Published: `date -I`/" docs/${RELEASE}/_metadata.liquid
sed -i "s,^* Cite as:.*,* Cite as: <https://doi.org/${DOI}> (this version)," docs/${RELEASE}/_metadata.liquid
docs/${RELEASE}/.references.md: docs/${RELEASE}/ docs/_includes/references.liquid
echo "---\ntitle: References\n---\n\n" > docs/${RELEASE}/.references.md
echo "# References" >> docs/${RELEASE}/.references.md
sed 's,^\[,* \\[,' < docs/_includes/references.liquid | \
sed 's,\]: ,\\]: <,' |\
sed 's,^\*.*$$,\0>,' \
>> docs/${RELEASE}/.references.md
docs/${RELEASE}/*.md: docs/${RELEASE}/ docs/${DRAFT}/README.md docs/${DRAFT}/*.md docs/${DRAFT}/_metadata.liquid docs/${RELEASE}/.references.md
for f in docs/${DRAFT}/*.md ; do \
sed s/${DRAFT}/${RELEASE}/g < $$f > docs/${RELEASE}/`basename $$f`;\
done
sed -i "/^exclude:/ d" docs/${RELEASE}/README.md
docs/${RELEASE}/appendix/:
mkdir -p docs/${RELEASE}/appendix/
docs/${RELEASE}/appendix/*.md: docs/${RELEASE}/appendix/ docs/${DRAFT}/appendix/*.md
for f in docs/${DRAFT}/appendix/*.md ; do \
sed s/${DRAFT}/${RELEASE}/g < $$f > docs/${RELEASE}/appendix/`basename $$f` ;\
done
docs/${RELEASE}/ro-crate-metadata.json: docs/${DRAFT}/ro-crate-metadata.json
sed s/${DRAFT}/${RELEASE}/g < docs/${DRAFT}/ro-crate-metadata.json > docs/${RELEASE}/ro-crate-metadata.json
sed -i "s/UNPUBLISHED/`date -I`/g" docs/${RELEASE}/ro-crate-metadata.json
sed -i "s/TAG/${TAG}/g" docs/${RELEASE}/ro-crate-metadata.json
sed -i "s,DOI,${DOI},g" docs/${RELEASE}/ro-crate-metadata.json
sed -i "s;ZENODO;`echo ${DOI}|sed s,10.5281/zenodo.,,`;g" docs/${RELEASE}/ro-crate-metadata.json
rm -f docs/${RELEASE}/ro-crate-metadata.jsonld
ln -s ro-crate-metadata.json docs/${RELEASE}/ro-crate-metadata.jsonld
docs/${RELEASE}/ro-crate-preview.html: dependencies docs/${RELEASE}/ro-crate-metadata.json
node_modules/.bin/makehtml docs/${RELEASE}/ro-crate-metadata.json
docs/${RELEASE}/context.jsonld: dependencies docs/${RELEASE}/ scripts/schema-context.py
scripts/schema-context.py ${RELEASE} ${TAG} > docs/${RELEASE}/context.jsonld
release/:
mkdir -p release
release/ro-crate-${TAG}.md: dependencies release/ docs/${RELEASE}/_metadata.liquid docs/${RELEASE}/.references.md docs/${RELEASE}/*.md docs/${RELEASE}/appendix/*.md docs/_includes/references.liquid
cp docs/${RELEASE}/_metadata.liquid docs/${RELEASE}/.metadata.md
pandoc --from=markdown+gfm_auto_identifiers --to=markdown+gfm_auto_identifiers \
docs/${RELEASE}/.metadata.md \
`grep ^sort: docs/${RELEASE}/*.md | sort -n -k 2 | grep -v README.md| grep -v about.md | sed s/:.*//` \
docs/${RELEASE}/appendix/*.md docs/_includes/references.liquid docs/${RELEASE}/.references.md |\
grep -v '{%' > release/ro-crate-${TAG}.md
# Fix internal links to work in single-page
sed -i -E 's,]\(([^:)]*/)*([^:)]*)\.md\),](#\2),g' release/ro-crate-${TAG}.md
sed -i -E 's,]\([^):]*\.md#([^)]*)\),](#\1),g' release/ro-crate-${TAG}.md
release/ro-crate-${TAG}.html: dependencies release/ release/ro-crate-${TAG}.md
egrep -v '^{:(\.no_)?toc}' release/ro-crate-${TAG}.md | \
pandoc --standalone --number-sections --toc --section-divs \
--filter scripts/pandoc-admonition.py \
--metadata pagetitle="RO-Crate Metadata Specification ${RELEASE}" \
--from=markdown+gfm_auto_identifiers -o release/ro-crate-${TAG}.html
release/ro-crate-${TAG}.pdf: dependencies release/ release/ro-crate-${TAG}.md
egrep -v '^{:(\.no_)?toc}' release/ro-crate-${TAG}.md | \
pandoc --pdf-engine xelatex --variable=hyperrefoptions:colorlinks=true,allcolors=blue \
--variable papersize=a4 --filter scripts/pandoc-admonition.py \
--number-sections --toc --metadata pagetitle="RO-Crate Metadata Specification ${RELEASE}" \
--from=markdown+gfm_auto_identifiers -o release/ro-crate-${TAG}.pdf
release/ro-crate-context-${TAG}.jsonld: dependencies release/ docs/${RELEASE}/context.jsonld
cp docs/${RELEASE}/context.jsonld release/ro-crate-context-${TAG}.jsonld
release/ro-crate-metadata.json: dependencies release/ docs/${RELEASE}/ro-crate-metadata.json
cp docs/${RELEASE}/ro-crate-metadata.json release/ro-crate-metadata.json
release/ro-crate-preview.html: dependencies release/ docs/${RELEASE}/ro-crate-preview.html
cp docs/${RELEASE}/ro-crate-preview.html release/ro-crate-preview.html
# From https://stackoverflow.com/a/18137056
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_absdir := $(dir $(mkfile_path))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
podman-pre:
chmod go+w "${mkfile_absdir}/docs" "${mkfile_absdir}/docs/Gemfile.lock"
docker-fix-permissions:
docker run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" jekyll/jekyll chown -R $(shell id -u):$(shell id -g) /srv/jekyll
jekyll-podman-serve: podman-pre
podman run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" -p 4000:4000 jekyll/jekyll jekyll serve --incremental
jekyll-podman-oneshot: podman-pre
podman run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" jekyll/jekyll jekyll build
jekyll-docker-serve:
docker run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" -p 4000:4000 jekyll/jekyll jekyll serve --incremental
# Next one fixes permissions
docker run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" jekyll/jekyll chown -R $(shell id -u):$(shell id -g) /srv/jekyll
jekyll-docker-oneshot:
docker run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" jekyll/jekyll jekyll build
# Next one fixes permissions
docker run -it --rm --name jekyll-ro-crate -e PAGES_REPO_NWO=researchobject/ro-crate --volume="${mkfile_absdir}/docs:/srv/jekyll" jekyll/jekyll chown -R $(shell id -u):$(shell id -g) /srv/jekyll