summaryrefslogtreecommitdiff
path: root/release.sh
blob: 8e843f56c31ac40011ae1e21747d5c951a6a48ff (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
#!/bin/sh -eu

build_dir=build-release

if ! type glab >/dev/null; then
	echo "glab is needed to create a release"
	exit 1
fi

case "$(git rev-parse --abbrev-ref HEAD)" in
main | [0-9]*.[0-9]*)
	;;
*)
	echo "Not on the main or a stable branch"
	exit 1
esac

if [ -n "$(git log @{upstream}..)" ]; then
	echo "The main branch has unpushed commits"
	exit 1
fi

meson_options=""
if [ -e "$build_dir" ]; then
	meson_options="$meson_options --wipe"
fi
meson setup "$build_dir" $meson_options

prev_version="$(git describe --tags --abbrev=0)"
version="$(meson introspect "$build_dir" --projectinfo | jq -r .version)"
if [ "$version" = "$prev_version" ]; then
	echo "Version not bumped"
	exit 1
fi

name="$(meson introspect "$build_dir" --projectinfo | jq -r .descriptive_name)"
if [ "$name" = "" ]; then
	echo "Cannot determine project name"
	exit 1
fi

ninja -C "$build_dir" dist

archive_name="$name-$version.tar.xz"
archive_path="$build_dir/meson-dist/$archive_name"
gpg --detach-sig "$archive_path"

sha256="$(cd $build_dir/meson-dist && sha256sum $archive_name)"
sha512="$(cd $build_dir/meson-dist && sha512sum $archive_name)"
archive_url="https://gitlab.freedesktop.org/wayland/$name/-/releases/$version/downloads/$archive_name"
announce_path="$build_dir/meson-dist/$name-$version-announce.eml"
current_branch=$(git branch --show-current)
remote_name=$(git config --get branch.${current_branch}.remote)

cat >"$announce_path" <<EOF
To: <wayland-devel@lists.freedesktop.org>
Subject: [ANNOUNCE] $name $version

`git shortlog --no-merges "$prev_version.."`

git tag: $version

$archive_url
SHA256: $sha256
SHA512: $sha512
PGP:    $archive_url.sig
EOF

echo "Release announcement written to $announce_path"

echo -n "Release $name $version? [y/N] "
read answer
if [ "$answer" != "y" ]; then
	exit 1
fi

git tag -s -m "$version" "$version"
git push "$remote_name" "$version"
glab release create "$version" "$archive_path"* --notes ""