-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrelease.sh
executable file
·59 lines (49 loc) · 1.56 KB
/
release.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
#!/bin/bash
# SPDX-FileCopyrightText: © 2022 Matt Williams <[email protected]>
# SPDX-License-Identifier: BSD
set -euo pipefail
IFS=$'\n\t'
version_spec=${1:-}
if [[ -z "${version_spec}" ]]
then
echo "This script must be called with an argument of the version number or a \"bump spec\"."
echo "See \`poetry version --help\`"
echo "For example, pass in \"patch\", \"minor\" or \"major\" to bump that segment."
exit 1
fi
if ! git diff-index --quiet HEAD -- pyproject.toml
then
echo "There are uncomitted changes to \`pyproject.toml\`."
echo "Commit or restore them before continuing."
exit 1
fi
if ! git diff --cached --quiet
then
echo "There are uncomitted changes in the staging area."
echo "Commit or restore them before continuing."
exit 1
fi
if ! poetry build -q
then
echo "Poetry build failed:"
poetry build
fi
echo "Are you sure you want to release the next ${version_spec} version?"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit 1;;
esac
done
# Bump version in pyproject.toml
poetry version "${version_spec}"
new_version=$(poetry version --short)
git add pyproject.toml
date=$(date --iso-8601)
sed --in-place "s/__version__ = \".*\"/__version__ = \"${new_version}\"/" sphinxcontrib/doxylink/__init__.py
git add sphinxcontrib/doxylink/__init__.py
sed --in-place "s/## \[Unreleased\]/## [Unreleased]\\n\\n## [${new_version}] - ${date}/" CHANGELOG.md
git add CHANGELOG.md
git commit -m "Update to version ${new_version}"
git tag "${new_version}"
git push --atomic --tags origin HEAD