-
Notifications
You must be signed in to change notification settings - Fork 3
/
make_release.sh
103 lines (86 loc) · 2.87 KB
/
make_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
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
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# fail on error
set -e
# confirm the supplied version bump is valid
version_bump=$1
case $version_bump in
"patch" | "minor" | "major" | "prepatch" | "preminor" | "premajor" | "prerelease")
echo "valid version bump: $version_bump"
;;
*)
echo "invalid version bump: \"$version_bump\""
echo "Usage:"
echo ""
echo " bash make_release.sh <version bump>"
echo ""
echo "List of valid version bumps: patch, minor, major, prepatch, preminor, premajor, prerelease"
exit 1
;;
esac
if [ -n "$(git status --untracked-files=no --porcelain)" ]; then
echo "The repository has uncommitted changes."
echo "This will lead to problems with git checkout."
exit 2
fi
if [ $(git symbolic-ref --short -q HEAD) != "main" ]; then
echo "not on main branch"
exit 3
fi
echo ""
echo "######################################"
echo "# ensure main branch is up-to-date #"
echo "######################################"
git pull
echo ""
echo "######################################"
echo "# checkout release branch #"
echo "######################################"
git checkout release
echo ""
echo "#######################################"
echo "# ensure release branch is up-to-date #"
echo "#######################################"
git pull
echo ""
echo "#######################################"
echo "# merge main into release branch #"
echo "#######################################"
git merge --no-ff main --no-edit
# bump version
poetry version $version_bump
# commit change
git add pyproject.toml
git commit -m "Bump version"
# create tag and push
new_tag=v$(poetry version -s)
echo "#######################################"
echo "# new tag: $new_tag #"
echo "#######################################"
git tag $new_tag
git push origin release $new_tag
# clean previous build and build
echo "#######################################"
echo "# clean up old builds #"
echo "#######################################"
rm -rf build dist
echo "#######################################"
echo "# do new build #"
echo "#######################################"
poetry build
echo ""
echo "#######################################"
echo "# publish package #"
echo "#######################################"
# to use this, set up an API token with
# `poetry config pypi-token.pypi <api token>`
poetry publish
# clean up
echo "#######################################"
echo "# go back to main branch #"
echo "#######################################"
git checkout main
echo "#####################################################"
echo "# all done! now go to #"
echo "# https://github.com/predictive-analytics-lab/EthicML/releases/tag/$new_tag"
echo "# and click on \"Edit Tag\" to write release notes #"
echo "#####################################################"