2 # SPDX-FileCopyrightText: 2024 Julien Moutinho (adh14) <julm+rezine@autogeree.net>
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 # shellcheck disable=SC2034
5 # shellcheck disable=SC2046
6 # shellcheck disable=SC2086
7 # shellcheck disable=SC2119
8 # shellcheck disable=SC2154
13 # FIXME: host it on rezine.org?
14 rfcGitweb
="https://git.sourcephile.fr/julm/$rfcRepo.git"
18 rm -rf "${removeAtExit[@]}"
23 rfcRoot
=$(realpath --relative-to . "${0%/*}"/..)
24 rfcDir
=$(realpath --relative-to "$rfcRoot" "$rfcDir")
25 rfcBranch
=$(realpath --relative-to "$rfcRoot"/rfcs "$rfcDir")
26 rfcYearAdvocacy
=$(git log -1 --pretty=%cd --date=format:%Y "$rfcDir/advocacy.md")
27 rfcDateAdvocacy
=$(git log -1 --pretty=%cd --date=short "$rfcDir/advocacy.md")
28 rfcDateCriticisms
=$(git log -1 --pretty=%cd --date=short "$rfcDir/criticisms.yaml")
32 local advocacyLatestCommit criticismsLatestCommit
33 advocacyLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/advocacy.html")
34 criticismsLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/criticisms.html")
35 rfcTagAdvocacyOld
="$(git describe --tags "$advocacyLatestCommit")" || true
36 rfcTagCriticismsOld
="$(git describe --tags "$criticismsLatestCommit")" || true
37 if test "${rfcTagAdvocacyOld#"${rfcBranch}v"}" != "$rfcTagAdvocacyOld"
38 then IFS
=psvc
read -r _ _num rfcRevAdvocacy _
<<<"$rfcTagAdvocacyOld"
39 else rfcRevAdvocacy
=0; rfcTagAdvocacyOld
=init
41 if test "${rfcTagCriticismsOld#"${rfcBranch}v"}" != "$rfcTagCriticismsOld"
42 then IFS
=psvc
- read -r _ _num _rfcRevAdvocacy rfcRevCriticisms rfcRevWIP
<<<"$rfcTagCriticismsOld"
43 else rfcRevCriticisms
=0; rfcTagCriticismsOld
=init
45 rfcBranchRevision
="${rfcBranch}v${rfcRevAdvocacy}"
46 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms${rfcRevWIP:+-$rfcRevWIP}"
50 mkdir -p "$rfcRoot/rfcs/$rfcBranch/citation"
51 pandoc
>"$rfcRoot/rfcs/$rfcBranch/citation/v${rfcRevAdvocacy}.csl.json" \
54 --template "$rfcRoot/styles/rfc.csl.json" \
62 --template "$rfcRoot"/styles
/rfc.metadata.yaml \
64 if test ! "${rfcNoAdvocacy:+set}"; then
66 cat "$rfcRoot/styles/rfc.information.md"
68 cat "$rfcDir"/advocacy.md
71 if test ! "${rfcNoThanks:+set}"; then
75 --template "$rfcRoot"/styles
/rfc.thanks.md \
79 if test ! "${rfcNoHistory:+set}"; then
83 --template "$rfcRoot"/styles
/rfc.
history.md \
84 "$rfcDir"/history.yaml
87 if test ! "${rfcNoCriticisms:+set}"; then
91 --template "$rfcRoot"/styles
/rfc.criticisms.md \
92 "$rfcDir"/criticisms.yaml
95 cat "$rfcRoot"/styles
/rfc.references.md
99 printf ' --metadata %s' \
100 rfcBranch
="$rfcBranch" \
101 rfcDateAdvocacy
="$rfcDateAdvocacy" \
102 rfcDateCriticisms
="$rfcDateCriticisms" \
104 rfcDomain
="$rfcDomain" \
105 rfcGitweb
="$rfcGitweb" \
109 rfcBranchRevision
="$rfcBranchRevision" \
110 rfcRevAdvocacy
="$rfcRevAdvocacy" \
111 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
112 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
114 rfcYearAdvocacy
="$rfcYearAdvocacy"
118 local sourceFile metaFile
119 sourceFile
=$(mktemp --suffix ".md")
120 metaFile
=$(mktemp --suffix ".md")
121 removeAtExit
+=("$sourceFile" "$metaFile")
122 rfcSource
>"$sourceFile"
123 if test ! "${rfcNoAdvocacy:+set}" && test ! "${rfcNoCriticisms:+set}"; then
129 --template "$sourceFile" \
135 pandoc
--from markdown
+emoji
--to plain \
137 --csl "$rfcRoot"/styles
/rfc.csl \
138 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
139 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
140 --lua-filter "$rfcRoot"/styles
/rfc.lua \
141 --variable lang
=fr
-FR \
147 pandoc
--from markdown
+emoji
--to markdown
+emoji \
148 --table-of-contents \
152 --csl "$rfcRoot"/styles
/rfc.csl \
153 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
154 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
155 --lua-filter "$rfcRoot"/styles
/rfc.lua \
156 --variable lang
=fr
-FR \
162 pandoc
--from markdown
+emoji
--to html5 \
165 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
166 --table-of-contents \
170 --csl "$rfcRoot"/styles
/rfc.csl \
171 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
172 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
173 --lua-filter "$rfcRoot"/styles
/rfc.lua \
174 --variable lang
=fr
-FR \
180 pandoc
--from markdown
+emoji
--to pdf \
181 --pdf-engine lualatex \
182 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
185 --table-of-contents \
189 --csl "$rfcRoot"/styles
/rfc.csl \
190 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
191 --lua-filter "$rfcRoot"/styles
/rfc.lua \
192 --variable colorlinks
=true \
193 --variable lang
=fr
-FR \
194 --variable links
-as-notes=true \
200 git
diff --exit-code -- "$rfcDir" :'!*.html' ||
202 cat >&2 <<<"ERROR: you have changes to commit"
206 : "Check if \$rfcRevAdvocacy must be increased."
207 rfcNoCriticisms="set" \
210 rfcHTML -o "$rfcDir"/advocacy.html
211 git add "$rfcDir"/advocacy.html
212 rfcRevAdvocacyIncrement=0
213 if ! git diff --cached --quiet "$rfcDir"/advocacy.html; then
214 rfcRevAdvocacyIncrement=1
215 # Note that $rfcRevCriticisms is not reset:
216 # criticisms have their own independant revisions
217 # because, in practice, criticisms to an old $rfcRevAdvocacy
218 # can be received and added after a new $rfcRevAdvocacy has been tagged.
221 : "Check if \$rfcRevCriticisms must be increased."
223 rfcNoAdvocacy="set" \
226 rfcHTML -o "$rfcDir"/criticisms.html
227 git add "$rfcDir"/criticisms.html
228 rfcRevCriticismsIncrement=0
229 if ! git diff --cached --quiet "$rfcDir"/criticisms.html; then
230 rfcRevCriticismsIncrement=1
233 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
234 test "$rfcRevCriticismsIncrement" -gt 0
236 rfcRevAdvocacy=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
237 rfcRevCriticisms=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
238 rfcBranchRevision="${rfcBranch}v$rfcRevAdvocacy"
239 rfcTag="${rfcBranchRevision}c$rfcRevCriticisms"
240 rfcNoCriticisms="set" \
243 rfcHTML -o "$rfcDir"/advocacy.html
245 rfcNoAdvocacy="set" \
248 rfcHTML -o "$rfcDir"/criticisms.html
249 rfcHTML -o "$rfcDir"/index.html
250 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
251 git add "$rfcDir"/{advocacy,criticisms,index}.html
252 git add "$rfcDir/citation/v${rfcRevAdvocacy}.csl.json"
253 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
254 git diff --cached --quiet ||
255 git commit -m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
256 git tag --force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"