-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
release-prepare.sh
executable file
·91 lines (71 loc) · 2.34 KB
/
release-prepare.sh
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
#!/usr/bin/env bash
set -euo pipefail
set -o xtrace
# Prepare a release on the current branch.
#
# NOTE: You must have a release commit checked out to run this script
# successfully.
#
# NOTE: While this script can be run locally, is mainly desgined for use in our
# `prepare-release` CI workflow.
# Set to false to prevent posting release notes in pull request
POST_BODY=${POST_BODY:-'true'}
# The directory of this file
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# shellcheck source=./shared.sh
. "$DIR"/shared.sh
cd "$PROJ_ROOT"
# make sure that we do not release uncommited files
if ! (git diff --exit-code && git diff --cached --exit-code) >/dev/null
then
echo "error: Git directory is not clean. Remove changes to tracked files."
exit 255
fi
RELEASE_VERSION=${RELEASE_VERSION:-''}
# Set the new version in the source code
if [ -n "$RELEASE_VERSION" ]
then
# Explicitly set the release version
sbt "setVersion ${RELEASE_VERSION}"
else
# Derive the relesae version by removing the -SNAPSHOT suffix
sbt removeVersionSnapshot
RELEASE_VERSION=$("$DIR"/get-version.sh)
fi
# Prepare the release on a new branch
git checkout -b "release/${RELEASE_VERSION}"
# Generate the release notes
RELEASE_VERSION=$RELEASE_VERSION "$DIR"/release-notes.sh
# Make the release commit
commit_msg="[release] ${RELEASE_VERSION}"
git add --update
git add "$RELEASE_NOTES"
git commit -m "$commit_msg"
if [[ "$POST_BODY" == true ]]
then
body=$(cat "$RELEASE_NOTES")
else
body=''
fi
body=$(cat "$RELEASE_NOTES")
# Bump the version
"$DIR"/version-bump.sh
instructions="
# Reviewer instructions
- Check the changelog to ensure the version increment is consistent with https://semver.org/.
- If a different version should be released, follow [the instructions](https://github.com/informalsystems/apalache/blob/unstable/CONTRIBUTING.md#via-github).
- Review the changeset as a sanity check.
- Approve the PR, if it pases muster.
- **Merge** this branch (do not squash or rebase), but **DO NOT DELETE THE BRANCH**.
- After the release has been published to github, delete this branch.
---
# Release notes
"
# Open a pull request for the release
# See https://hub.github.com/hub-pull-request.1.html
hub pull-request \
--push \
--message="$commit_msg" \
--message="$instructions" \
--message="$body" \
--base="unstable"