-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·56 lines (44 loc) · 1.26 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
#!/bin/bash
set -euo pipefail
# read version + ensure non-empty
VERSION="$1"
[ -z "$VERSION" ] && echo "Error: No version specified" && exit 1
# ensure work tree is clean (aside from CHANGELOG.md)
if [[ ! $(git status --porcelain | grep -vc "CHANGELOG.md") -eq 0 ]]; then
echo "Error: Uncommitted changes in work tree"
exit 1
fi
# ensure we're on default branch
if [[ ! "$(git branch --show-current)" =~ ^(main|master)$ ]]; then
echo "Error: Not on default branch"
exit 1
fi
# ensure the changelog is up-to-date
if ! (grep -q "$VERSION" CHANGELOG.md)
then
echo "Error: CHANGELOG.md is not up to date"
exit 1
fi
if ! type "flit" > /dev/null;
then
echo "Flit is not installed"
exit 1
fi
# confirm
read -r -p "Bump version from $(cut -d '"' -f2 < pip_abandoned/__version__.py) to $VERSION. Are you sure? [y/n] " response
response=${response,,} # tolower
if [[ ! "$response" =~ ^(yes|y)$ ]]; then
exit 1
fi
# checks done, now publish the release...
# bump version
echo '__version__ = "'"$VERSION"'"' > pip_abandoned/__version__.py
# commit
git add pyproject.toml
git add pip_abandoned/__version__.py
git add CHANGELOG.md
git commit -m "version $VERSION"
# tag
git tag "$VERSION"
# push to GitHub
git push origin "$(git branch --show-current)" --tags