-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_release.sh
121 lines (100 loc) · 3.25 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/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_build_publish() {
echo "#######################################"
echo "# switching to $1 #"
echo "#######################################"
pushd $1
echo "#######################################"
echo "# bump version #"
echo "#######################################"
poetry version $version_bump
git add pyproject.toml
# 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
popd # switch back to previous directory
}
# go through all project directories
bump_build_publish "."
# (it's currently only one)
# commit changes
git commit -m "Bump version"
# get the version from ranzen
# pushd ranzen
new_tag=v$(poetry version -s)
# popd
# create tag and push
echo "#######################################"
echo "# new tag: $new_tag #"
echo "#######################################"
git tag $new_tag
git push origin release $new_tag
# clean up
echo "#######################################"
echo "# go back to main branch #"
echo "#######################################"
git checkout main
echo "#######################################"
echo "# create release #"
echo "#######################################"
gh release create $new_tag --generate-notes