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 _
<<<"$rfcTagCriticismsOld"
42 else rfcRevCriticisms
=0; rfcTagCriticismsOld
=init
44 rfcBranchRevision
="${rfcBranch}v${rfcRevAdvocacy}"
45 rfcTag
="${rfcBranch}c$rfcRevCriticisms"
49 local templateFile metaFile
50 templateFile
=$(mktemp --suffix ".md")
51 metaFile
=$(mktemp --suffix ".md")
52 removeAtExit
+=("$templateFile" "$metaFile")
53 # \${rfcOrga} <[RFC\${rfcTag}](mailto:\${rfcList}+\${rfcTag}@\${rfcDomain})>
54 # — « *\${title}* » — \${rfcDate} — série *Requests for Criticisms*
55 # — \${RFC-Category} « \` \${rfcBranch}\` »,
56 # plaidoirie « \` \${rfcRevisionAdvocacy}\` »,
57 # critiques « \` \${rfcRevisionCriticisms}\` »
58 # — \${for(RFC-Compasses)}boussole \${it}\${sep} & \${endfor}
59 # — <<\${rfcGitweb}/blob_plain/\${rfcTag}:/rfcs/\${rfcBranch}/index.html>>.
60 cat >"$templateFile" <<EOF
63 "id": "\${rfcOrga}RFC\${rfcBranchRevision}",
64 "title": "RFC\${rfcBranchRevision} — \${title}",
65 "title-short": "RFC\${rfcBranchRevision}",
66 "type": "article-journal",
67 "publisher": "\${rfcOrga}",
68 "genre": "Requests for Criticisms",
69 "collection-title": "\${RFC-Category}",
70 "volume": "\${rfcBranch}",
71 "issue": "v\${rfcRevAdvocacy}",
72 "issued": { "date-parts": [ [ \${rfcYear} ] ] },
73 "URL": "\${rfcGitweb}/blob_plain/\${rfcBranchRevision}:/rfcs/\${rfcBranch}/index.html",
77 "non-dropping-particle": "boussole",
78 "family": "\${it.boussole}",
79 "given": "\${it.nom}",
80 "email": "\${it.email}"
88 mkdir -p "$rfcRoot/rfcs/$rfcBranch/citation"
92 --template "$templateFile" \
93 "$sourceFile" >"$rfcRoot/rfcs/$rfcBranch/citation/v${rfcRevAdvocacy}.script.csl.json"
97 if test ! "${rfcNoAdvocacy:+set}"; then
98 cat - "$rfcDir"/advocacy.md
<<EOF
100 Ce document est publié sous licence
101 [\${SPDX-License-Identifier}](https://spdx.org/licenses/\${SPDX-License-Identifier}.html).
105 > \${rfcOrga} <[RFC\${rfcTag}](mailto:\${rfcList}+\${rfcTag}@\${rfcDomain})>
106 > — « *\${title}* » — \${rfcDate} — série *Requests for Criticisms*
107 > — \${RFC-Category} « \` \${rfcBranch}\` »,
108 > plaidoirie « \` \${rfcRevisionAdvocacy}\` »,
109 > critiques « \` \${rfcRevisionCriticisms}\` »
110 > — \${for(RFC-Authors)}boussole \${it.boussole} ([\${it.nom}](mailto:\${it.email}))\${sep} & \${endfor}
111 > — <<\${rfcGitweb}/blob_plain/\${rfcTag}:/rfcs/\${rfcBranch}/index.html>>.
113 Vous _devriez_ consulter en priorité sa dernière version
114 qui est disponible en ligne à l'adresse :
115 <<\${rfcGitweb}/blob_plain/\${rfcBranch}:/rfcs/\${rfcBranch}/index.html>>
117 - Statut de cette révision : « \${RFC-Phase} »
123 if test ! "${rfcNoHistory:+set}"; then
124 cat "$rfcDir"/history.md
127 if test ! "${rfcNoCriticisms:+set}"; then
128 cat "$rfcDir"/criticisms.md
141 printf ' --metadata %s' \
142 rfcBranch
="$rfcBranch" \
145 rfcDomain
="$rfcDomain" \
146 rfcGitweb
="$rfcGitweb" \
150 rfcBranchRevision
="$rfcBranchRevision" \
151 rfcRevAdvocacy
="$rfcRevAdvocacy" \
152 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
153 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
156 # --metadata-file provides defaults,
157 # its metadata do not override the document's metadata.
158 printf ' --metadata-file %s' "$metaFile"
159 cat >"$metaFile" <<EOF
161 title: "[RFC${rfcBranch}]"
167 local sourceFile metaFile
168 sourceFile
=$(mktemp --suffix ".md")
169 metaFile
=$(mktemp --suffix ".md")
170 removeAtExit
+=("$sourceFile" "$metaFile")
171 rfcSource
>"$sourceFile"
176 --template "$sourceFile" \
182 pandoc
--from markdown
+emoji
--to plain \
184 --csl "$rfcRoot"/styles
/rfc.csl \
185 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
186 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
187 --lua-filter "$rfcRoot"/styles
/rfc.lua \
188 --variable lang
=fr
-FR \
194 pandoc
--from markdown
+emoji
--to markdown
+emoji \
195 --table-of-contents \
199 --csl "$rfcRoot"/styles
/rfc.csl \
200 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
201 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
202 --lua-filter "$rfcRoot"/styles
/rfc.lua \
203 --variable lang
=fr
-FR \
209 pandoc
--from markdown
+emoji
--to html5 \
212 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
213 --table-of-contents \
217 --csl "$rfcRoot"/styles
/rfc.csl \
218 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
219 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
220 --lua-filter "$rfcRoot"/styles
/rfc.lua \
221 --variable lang
=fr
-FR \
227 pandoc
--from markdown
+emoji
--to pdf \
228 --pdf-engine lualatex \
229 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
232 --table-of-contents \
236 --csl "$rfcRoot"/styles
/rfc.csl \
237 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
238 --lua-filter "$rfcRoot"/styles
/rfc.lua \
239 --variable colorlinks
=true \
240 --variable lang
=fr
-FR \
241 --variable links
-as-notes=true \
247 git
diff --exit-code -- "$rfcDir" :'!*.html'
249 : "Check if \$rfcRevAdvocacy must be increased."
250 rfcNoCriticisms
="set" \
252 rfcHTML
-o "$rfcDir"/advocacy.html
253 git add
"$rfcDir"/advocacy.html
254 rfcRevAdvocacyIncrement
=0
255 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
256 rfcRevAdvocacyIncrement
=1
257 # Note that $rfcRevCriticisms is not reset:
258 # criticisms have their own independant revisions
259 # because, in practice, criticisms to an old $rfcRevAdvocacy
260 # can be received and added after a new $rfcRevAdvocacy has been tagged.
263 : "Check if \$rfcRevCriticisms must be increased."
265 rfcNoAdvocacy
="set" \
267 rfcHTML
-o "$rfcDir"/criticisms.html
268 git add
"$rfcDir"/criticisms.html
269 rfcRevCriticismsIncrement
=0
270 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
271 rfcRevCriticismsIncrement
=1
274 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
275 test "$rfcRevCriticismsIncrement" -gt 0
277 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
278 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
279 rfcBranchRevision
="${rfcBranch}v$rfcRevAdvocacy"
280 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms"
281 rfcNoCriticisms
="set" \
283 rfcHTML
-o "$rfcDir"/advocacy.html
285 rfcNoAdvocacy
="set" \
287 rfcHTML
-o "$rfcDir"/criticisms.html
288 rfcHTML
-o "$rfcDir"/index.html
289 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
290 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
291 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
292 git
diff --cached --quiet ||
293 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
294 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"