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
65 cat "$rfcRoot/styles/rfc.information.md"
67 cat "$rfcDir"/advocacy.md
70 if test ! "${rfcNoHistory:+set}"; then
74 --template "$rfcRoot"/styles
/rfc.
history.md \
75 "$rfcDir"/history.yaml
78 if test ! "${rfcNoCriticisms:+set}"; then
82 --template "$rfcRoot"/styles
/rfc.criticisms.md \
83 "$rfcDir"/criticisms.yaml
86 cat "$rfcRoot"/styles
/rfc.references.md
90 printf ' --metadata %s' \
91 rfcBranch
="$rfcBranch" \
94 rfcDomain
="$rfcDomain" \
95 rfcGitweb
="$rfcGitweb" \
99 rfcBranchRevision
="$rfcBranchRevision" \
100 rfcRevAdvocacy
="$rfcRevAdvocacy" \
101 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
102 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
108 local sourceFile metaFile
109 sourceFile
=$(mktemp --suffix ".md")
110 metaFile
=$(mktemp --suffix ".md")
111 removeAtExit
+=("$sourceFile" "$metaFile")
112 rfcSource
>"$sourceFile"
117 --template "$sourceFile" \
123 pandoc
--from markdown
+emoji
--to plain \
125 --csl "$rfcRoot"/styles
/rfc.csl \
126 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
127 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
128 --lua-filter "$rfcRoot"/styles
/rfc.lua \
129 --variable lang
=fr
-FR \
135 pandoc
--from markdown
+emoji
--to markdown
+emoji \
136 --table-of-contents \
140 --csl "$rfcRoot"/styles
/rfc.csl \
141 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
142 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
143 --lua-filter "$rfcRoot"/styles
/rfc.lua \
144 --variable lang
=fr
-FR \
150 pandoc
--from markdown
+emoji
--to html5 \
153 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
154 --table-of-contents \
158 --csl "$rfcRoot"/styles
/rfc.csl \
159 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
160 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
161 --lua-filter "$rfcRoot"/styles
/rfc.lua \
162 --variable lang
=fr
-FR \
168 pandoc
--from markdown
+emoji
--to pdf \
169 --pdf-engine lualatex \
170 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
173 --table-of-contents \
177 --csl "$rfcRoot"/styles
/rfc.csl \
178 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
179 --lua-filter "$rfcRoot"/styles
/rfc.lua \
180 --variable colorlinks
=true \
181 --variable lang
=fr
-FR \
182 --variable links
-as-notes=true \
188 git
diff --exit-code -- "$rfcDir" :'!*.html' ||
189 echo >&2 "ERROR: you have changes to commit"
191 : "Check if \$rfcRevAdvocacy must be increased."
192 rfcNoCriticisms
="set" \
194 rfcHTML
-o "$rfcDir"/advocacy.html
195 git add
"$rfcDir"/advocacy.html
196 rfcRevAdvocacyIncrement
=0
197 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
198 rfcRevAdvocacyIncrement
=1
199 # Note that $rfcRevCriticisms is not reset:
200 # criticisms have their own independant revisions
201 # because, in practice, criticisms to an old $rfcRevAdvocacy
202 # can be received and added after a new $rfcRevAdvocacy has been tagged.
205 : "Check if \$rfcRevCriticisms must be increased."
207 rfcNoAdvocacy
="set" \
209 rfcHTML
-o "$rfcDir"/criticisms.html
210 git add
"$rfcDir"/criticisms.html
211 rfcRevCriticismsIncrement
=0
212 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
213 rfcRevCriticismsIncrement
=1
216 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
217 test "$rfcRevCriticismsIncrement" -gt 0
219 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
220 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
221 rfcBranchRevision
="${rfcBranch}v$rfcRevAdvocacy"
222 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms"
223 rfcNoCriticisms
="set" \
225 rfcHTML
-o "$rfcDir"/advocacy.html
227 rfcNoAdvocacy
="set" \
229 rfcHTML
-o "$rfcDir"/criticisms.html
230 rfcHTML
-o "$rfcDir"/index.html
231 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
232 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
233 git add
"$rfcDir/citation/v${rfcRevAdvocacy}.csl.json"
234 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
235 git
diff --cached --quiet ||
236 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
237 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"