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 rfcYear
=$(git log -1 --pretty=%cd --date=format:%Y "$rfcDir/advocacy.md")
27 rfcDate
=$(git log -1 --pretty=%cd --date=short "$rfcDir/advocacy.md")
31 local advocacyLatestCommit criticismsLatestCommit
32 advocacyLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/advocacy.html")
33 criticismsLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/criticisms.html")
34 rfcTagAdvocacyOld
="$(git describe --tags "$advocacyLatestCommit")" || true
35 rfcTagCriticismsOld
="$(git describe --tags "$criticismsLatestCommit")" || true
36 if test "${rfcTagAdvocacyOld#"${rfcBranch}v"}" != "$rfcTagAdvocacyOld"
37 then IFS
=psvc
read -r _ _num rfcRevAdvocacy _
<<<"$rfcTagAdvocacyOld"
38 else rfcRevAdvocacy
=0; rfcTagAdvocacyOld
=init
40 if test "${rfcTagCriticismsOld#"${rfcBranch}v"}" != "$rfcTagCriticismsOld"
41 then IFS
=psvc
- read -r _ _num _rfcRevAdvocacy rfcRevCriticisms _ rfcRevGit
<<<"$rfcTagCriticismsOld"
42 else rfcRevCriticisms
=0; rfcTagCriticismsOld
=init
44 rfcBranchRevision
="${rfcBranch}v${rfcRevAdvocacy}"
45 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms"
49 mkdir -p "$rfcRoot/rfcs/$rfcBranch/citation"
50 pandoc
>"$rfcRoot/rfcs/$rfcBranch/citation/v${rfcRevAdvocacy}.csl.json" \
53 --template "$rfcRoot/styles/rfc.csl.json" \
61 --template "$rfcRoot"/styles
/rfc.metadata.yaml \
63 if test ! "${rfcNoAdvocacy:+set}"; then
64 cat "$rfcRoot/styles/rfc.information.md"
66 cat "$rfcDir"/advocacy.md
69 if test ! "${rfcNoHistory:+set}"; then
73 --template "$rfcRoot"/styles
/rfc.
history.md \
74 "$rfcDir"/history.yaml
77 if test ! "${rfcNoCriticisms:+set}"; then
81 --template "$rfcRoot"/styles
/rfc.criticisms.md \
82 "$rfcDir"/criticisms.yaml
85 cat "$rfcRoot"/styles
/rfc.references.md
89 printf ' --metadata %s' \
90 rfcBranch
="$rfcBranch" \
93 rfcDomain
="$rfcDomain" \
94 rfcGitweb
="$rfcGitweb" \
98 rfcBranchRevision
="$rfcBranchRevision" \
99 rfcRevAdvocacy
="$rfcRevAdvocacy" \
100 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
101 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
107 local sourceFile metaFile
108 sourceFile
=$(mktemp --suffix ".md")
109 metaFile
=$(mktemp --suffix ".md")
110 removeAtExit
+=("$sourceFile" "$metaFile")
111 rfcSource
>"$sourceFile"
116 --template "$sourceFile" \
122 pandoc
--from markdown
+emoji
--to plain \
124 --csl "$rfcRoot"/styles
/rfc.csl \
125 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
126 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
127 --lua-filter "$rfcRoot"/styles
/rfc.lua \
128 --variable lang
=fr
-FR \
134 pandoc
--from markdown
+emoji
--to markdown
+emoji \
135 --table-of-contents \
139 --csl "$rfcRoot"/styles
/rfc.csl \
140 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
141 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
142 --lua-filter "$rfcRoot"/styles
/rfc.lua \
143 --variable lang
=fr
-FR \
149 pandoc
--from markdown
+emoji
--to html5 \
152 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
153 --table-of-contents \
157 --csl "$rfcRoot"/styles
/rfc.csl \
158 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
159 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
160 --lua-filter "$rfcRoot"/styles
/rfc.lua \
161 --variable lang
=fr
-FR \
167 pandoc
--from markdown
+emoji
--to pdf \
168 --pdf-engine lualatex \
169 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
172 --table-of-contents \
176 --csl "$rfcRoot"/styles
/rfc.csl \
177 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
178 --lua-filter "$rfcRoot"/styles
/rfc.lua \
179 --variable colorlinks
=true \
180 --variable lang
=fr
-FR \
181 --variable links
-as-notes=true \
187 git
diff --exit-code -- "$rfcDir" :'!*.html'
189 : "Check if \$rfcRevAdvocacy must be increased."
190 rfcNoCriticisms
="set" \
192 rfcHTML
-o "$rfcDir"/advocacy.html
193 git add
"$rfcDir"/advocacy.html
194 rfcRevAdvocacyIncrement
=0
195 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
196 rfcRevAdvocacyIncrement
=1
197 # Note that $rfcRevCriticisms is not reset:
198 # criticisms have their own independant revisions
199 # because, in practice, criticisms to an old $rfcRevAdvocacy
200 # can be received and added after a new $rfcRevAdvocacy has been tagged.
203 : "Check if \$rfcRevCriticisms must be increased."
205 rfcNoAdvocacy
="set" \
207 rfcHTML
-o "$rfcDir"/criticisms.html
208 git add
"$rfcDir"/criticisms.html
209 rfcRevCriticismsIncrement
=0
210 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
211 rfcRevCriticismsIncrement
=1
214 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
215 test "$rfcRevCriticismsIncrement" -gt 0
217 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
218 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
219 rfcBranchRevision
="${rfcBranch}v$rfcRevAdvocacy"
220 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms"
221 rfcNoCriticisms
="set" \
223 rfcHTML
-o "$rfcDir"/advocacy.html
225 rfcNoAdvocacy
="set" \
227 rfcHTML
-o "$rfcDir"/criticisms.html
228 rfcHTML
-o "$rfcDir"/index.html
229 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
230 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
231 git add
"$rfcDir/citation/v${rfcRevAdvocacy}.csl.json"
232 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
233 git
diff --cached --quiet ||
234 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
235 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"