summaryrefslogtreecommitdiffstats
path: root/scripts/announce-release.sh
blob: 4bb02b9bdb4b9dac043321002679e1e8b7e744d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh

FROM_NAME='Patrick McDermott'
FROM_EMAIL='patrick.mcdermott@libiquity.com'
SIG="$(cat <<-EOF
	Patrick McDermott, CEO
	Libiquity
	Putting customers in control of high-quality technologies
	http://www.libiquity.com/
	EOF
	)"
KEY='2250 31F0 47FF E516 63ED  516F 1A45 9ECD E4D6 04BE'
TO_EMAIL='proteanos-dev@lists.proteanos.com'

package="${1}"
version="${2}"
package_name="${3}"
srcdir="${0%/scripts/announce-release.sh}"

heading()
{
	local name="${1}"
	shift 1

	printf '%s\n' "${name}"
	printf '%s\n' "${name}" | sed 's/./=/g'
}

about="$(sed -n '
	H;
	${
		g;
		s/^\n*[^\n][^\n]*\n[=-][=-]*\n\n*//;
		s/\n*[^\n][^\n]*\n[=-][=-]*\n.*$//;
		p;
	};
	' "${srcdir}/README")"
news="$(sed -n '
	H;
	${
		g;
		s/^\n*[^\n][^\n]*\n[=-][=-]*\n\n*//;
		s/^Released: [^\n]*\n\n*//;
		s/\n*[^\n][^\n]*\n[=-][=-]*\n.*$//;
		p;
	};
	' "${srcdir}/NEWS")"
old_version="$(sed -n "/^${package_name} version /p;" "${srcdir}/NEWS" | \
	sed -n "2{ s/^${package_name} version //p; };")"
old_tag="$(git tag --sort=creatordate | tail -n 2 | head -n 1)"

export GIT_DIR="${srcdir}/.git"

message="$({ cat | sed 's/=/=3D/g; s/ $/=20/; s/\t$/=09/;'; } <<-EOF
	Content-Type: text/plain; charset=UTF-8
	Content-Transfer-Encoding: quoted-printable

	$(heading 'About')

	${about}

	$(heading 'Downloading')

	Source archives are available from the files site by HTTP or FTP:

	    http://files.proteanos.com/pub/${package}/${version}/
	    ftp://files.proteanos.com/pub/${package}/${version}/

	Here are the MD5 checksums:

	$(sed 's/^/    /' MD5SUMS)

	Here are the SHA-256 checksums:

	$(sed 's/^/    /' SHA256SUMS)

	The sources are maintained in a Git repository:

	    http://git.proteanos.com/${package}/${package}.git/
	    git://git.proteanos.com/${package}/${package}.git/

	This release is marked by the "${package}/${version}" tag.

	$(heading "NEWS for Version ${version}")

	${news}

	$(heading "Shortlog of Changes Since Version ${old_version}")

	$(git shortlog "${old_tag}..HEAD" | \
		sed '/^..*$/s/^/    /')

	$(heading "Diffstat of Changes Since Version ${old_version}")

	$(git diff --stat=69 --color=never --find-renames=50% \
		"${old_tag}..HEAD" | sed 's/^/   /')

	-- 
	${SIG}
	EOF
	)"

{ sed 's/$/\r/' | /usr/sbin/sendmail -f "${FROM_EMAIL}" \
	"${TO_EMAIL}"; } <<-EOF
	Date: $(LC_ALL='POSIX' date '+%a, %d %b %Y %H:%M:%S %z')
	From: ${FROM_NAME} <${FROM_EMAIL}>
	To: ${TO_EMAIL}
	Subject: ${package_name} ${version} released
	Message-ID: $(LC_ALL='POSIX' date \
		'+%Y%m%d%H%M%S').${FROM_EMAIL}
	MIME-Version: 1.0
	Content-Type: multipart/signed; micalg=pgp-sha256; boundary="=-=-=";
	 protocol="application/pgp-signature"

	--=-=-=
	${message}

	--=-=-=
	Content-Type: application/pgp-signature
	Content-Description: OpenPGP digital signature

	$(printf '%s\n' "${message}" | sed 's/$/\r/' | \
		gpg --local-user "${KEY}" --armor --output - \
		--digest-algo SHA256 --detach-sign)

	--=-=-=--
	EOF