]> Git — Sourcephile - julm/rezine-rfcs.git/blob - scripts/send.sh
scripts: fix removeAtExit
[julm/rezine-rfcs.git] / scripts / send.sh
1 #!/usr/bin/env bash
2 # Usage: scripts/send.sh rfcs/p1
3 # SPDX-FileCopyrightText: 2024 Julien Moutinho (adh14) <julm+rezine@autogeree.net>
4 # SPDX-License-Identifier: AGPL-3.0-or-later
5 # shellcheck disable=SC2046
6 # shellcheck disable=SC2086
7 # shellcheck disable=SC2317
8 set -eux
9 . "${0%/*}"/lib.sh
10 rfcDir=$1; shift
11 test $# -le 0 || declare "$@"
12
13 coverLetter=$(mktemp)
14 removeAtExit+=("$coverLetter")
15 mimepart_alternative=$(uuidgen)
16 mimepart_related=$(uuidgen)
17
18 rfcDirMetadata
19 rfcRevision
20 rfcTag
21 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcTag}".pdf
22
23 git_push_remote=${git_push_remote-origin}
24
25 if test ! "${no_git_send_email:+set}"; then
26 { # coverLetter
27
28 rfcPlain \
29 $(rfcMetadata) \
30 --template "${0%/*}"/../styles/rfc.header.mail \
31 -o -
32
33 cat <<EOF
34 Content-Disposition: inline
35 Mime-Version: 1.0
36 Content-Type: multipart/alternative; boundary="--==_mimepart_alternative_$mimepart_alternative"
37 Content-Transfer-Encoding: UTF-8
38 EOF
39
40 cat <<EOF
41
42 ----==_mimepart_alternative_$mimepart_alternative
43 Content-Type: text/plain; charset=UTF-8
44 Content-Transfer-Encoding: UTF-8
45
46
47 ::: attention
48 Vous lisez actuellement ce mél dans son format de texte brut,
49 vous _devriez_ le lire dans son format HTML, qui est plus soigné.
50 :::
51
52 EOF
53
54 rfcMarkdown -o -
55 cat <<EOF
56
57 ----==_mimepart_alternative_$mimepart_alternative
58 Content-Type: multipart/related; boundary="--==_mimepart_related_$mimepart_related"
59 Content-Transfer-Encoding: UTF-8
60
61 ----==_mimepart_related_$mimepart_related
62 Content-Type: text/html; charset=UTF-8
63 Content-Transfer-Encoding: UTF-8
64
65 EOF
66 cat "$rfcDir"/index.html
67 cat <<EOF
68 ----==_mimepart_related_$mimepart_related
69
70 ----==_mimepart_alternative_$mimepart_alternative
71
72 EOF
73
74 # FIXME: the PDF rendition is not good
75 #cat <<EOF
76 #----==_mimepart_mixed_$mimepart_mixed
77 #Content-Type: application/pdf; name="RFC$rfcTag.pdf"
78 #Content-Transfer-Encoding: base64
79 #Content-Disposition: attachment; filename*0="RFC$rfcTag."; filename*1=pdf
80 #
81 #EOF
82 #base64 --wrap 76 "$rfcDir/$rfcRepo-$rfcTag".pdf
83
84 } >"$coverLetter"
85
86 patchesDir=$(mktemp -d)
87 removeAtExit+=("$patchesDir")
88 git format-patch "${git_push_remote}/${rfcBranch}..$rfcTag" \
89 --output-directory "$patchesDir" \
90 "$rfcDir" ':!*.html'
91
92 rfcAdvocacyMeta=$(mktemp --suffix ".json")
93 removeAtExit+=("$rfcAdvocacyMeta")
94 pandoc -o "$rfcAdvocacyMeta" --to plain \
95 --template "$rfcRoot"/styles/metadata.json \
96 "$rfcDir"/advocacy.md
97 git send-email ${git_send_email-} \
98 --to "$(jq -r .To <"$rfcAdvocacyMeta" | sed -e '/^null$/d')" \
99 --cc "$(jq -r .Cc <"$rfcAdvocacyMeta" | sed -e '/^null$/d')" \
100 --confirm cc \
101 --8bit-encoding UTF-8 \
102 --cover-letter "$coverLetter" \
103 "$patchesDir"
104 fi
105
106 if test ! "${no_git_push:+set}"; then
107 git push ${git_push-} --follow-tags "$git_push_remote" "$rfcTag"
108 git push ${git_push-} "$git_push_remote" "$(git rev-list "$rfcTag" -1):${rfcBranch}"
109 git push ${git_push-} "$git_push_remote"
110 fi