1#!/bin/bash
2
3set -eu
4
5build_dir=build-release
6
7case "$(git rev-parse --abbrev-ref HEAD)" in
8master | [0-9]*.[0-9]*)
9	;;
10*)
11	echo "Not on the master or a stable branch"
12	exit 1
13esac
14
15if [[ -n "$(git log origin..)" ]]; then
16	echo "The main branch has unpushed commits"
17	exit 1
18fi
19
20meson_options=""
21if [[ -e "$build_dir" ]]; then
22	meson_options="$meson_options --wipe"
23fi
24meson setup "$build_dir" $meson_options
25
26prev_version="$(git describe --tags --abbrev=0)"
27version="$(meson introspect "$build_dir" --projectinfo | jq -r .version)"
28if [[ "pixman-$version" == "$prev_version" ]]; then
29	echo "Version not bumped"
30	exit 1
31fi
32
33cairo_dest=cairographics.org:/srv/cairo.freedesktop.org/www/releases
34xorg_dest=xorg.freedesktop.org:/srv/xorg.freedesktop.org/archive/individual/lib
35
36cairo_url=https://cairographics.org/releases
37xorg_url=https://www.x.org/releases/individual/lib
38
39tar_gz="pixman-$version.tar.gz"
40sha512_tgz="$tar_gz.sha512"
41pgp_sig_tgz="$sha512_tgz.asc"
42
43tar_xz="pixman-$version.tar.xz"
44sha512_txz="$tar_xz.sha512"
45pgp_sig_txz="$sha512_txz.asc"
46
47announce="pixman-$version.eml"
48
49distdir="${build_dir}/meson-dist"
50
51git tag -s -m "pixman $version release" "pixman-$version"
52
53meson setup "${build_dir}"
54meson dist -C "${build_dir}" --formats xztar,gztar
55pushd "$distdir" >&/dev/null
56sha512sum "$tar_gz" >"$sha512_tgz"
57sha512sum "$tar_xz" >"$sha512_txz"
58gpg --armor --sign "$sha512_tgz"
59gpg --armor --sign "$sha512_txz"
60
61cat >"$announce" <<EOF
62To: cairo-announce@cairographics.org, xorg-announce@lists.freedesktop.org, pixman@lists.freedesktop.org
63Subject: [ANNOUNCE] pixman release $version now available
64
65A new pixman release $version is now available.
66
67tar.gz:
68	$cairo_url/$tar_gz
69	$xorg_url/$tar_gz
70
71tar.xz:
72	$cairo_url/$tar_xz
73	$xorg_url/$tar_xz
74
75Hashes:
76	SHA512: $(sha512sum "$tar_gz")
77	SHA512: $(sha512sum "$tar_xz")
78
79PGP signature:
80	$cairo_url/$pgp_sig_tgz
81	$cairo_url/$pgp_sig_txz
82	$xorg_url/$pgp_sig_tgz
83	$xorg_url/$pgp_sig_txz
84
85Git:
86	https://gitlab.freedesktop.org/pixman/pixman.git
87	tag: pixman-$version
88
89Log:
90$(git log --no-merges "${prev_version}..pixman-${version}" | git shortlog | awk '{ printf "\t"; print ; }' | cut -b1-80)
91EOF
92
93scp "$tar_gz" "$sha512_tgz" "$pgp_sig_tgz" "$tar_xz" "$sha512_txz" "$pgp_sig_txz" "$cairo_dest"
94scp "$tar_gz" "$sha512_tgz" "$pgp_sig_tgz" "$tar_xz" "$sha512_txz" "$pgp_sig_txz" "$xorg_dest"
95popd >& /dev/null
96
97git push --follow-tags
98
99echo "[ANNOUNCE] template generated in \"$distdir/$announce\" file."
100echo "      Please pgp sign and send it."
101