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