Skip to content

Commit 4893724

Browse files
committed
build: reorder release commits
Previously, we updated the docs after the commit so that any version string in the docs are correct. But there are none, thus we can update the docs before doing the release. This makes the release look a bit more natural. Signed-off-by: Daniel Wagner <dwagner@suse.de>
1 parent afb10e6 commit 4893724

File tree

1 file changed

+51
-31
lines changed

1 file changed

+51
-31
lines changed

scripts/release.sh

+51-31
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ usage() {
66
echo "The script does all necessary steps to create a new release."
77
echo ""
88
echo " -d: no documentation update"
9-
echo " -n: dry run"
9+
echo " -f: disable all sanity checks and just do the release"
10+
echo " -l: do not update library dependency"
1011
echo ""
1112
echo "Note: The version number needs to be exactly"
1213
echo " '^v[\d]+.[\d]+(.[\d\]+(-rc[0-9]+)?$'"
@@ -17,15 +18,19 @@ usage() {
1718
}
1819

1920
build_doc=true
20-
dry_run=false
21+
update_lib_dep=true
22+
force=false
2123

22-
while getopts "dn" o; do
24+
while getopts "dfl" o; do
2325
case "${o}" in
2426
d)
2527
build_doc=false
2628
;;
27-
n)
28-
dry_run=true
29+
f)
30+
force=true
31+
;;
32+
l)
33+
update_lib_dep=false
2934
;;
3035
*)
3136
usage
@@ -41,6 +46,26 @@ if [ -z "$VERSION" ] ; then
4146
exit 1
4247
fi
4348

49+
cleanup() {
50+
if [ -z "${OLD_HEAD}" ] ; then
51+
exit
52+
fi
53+
git tag -d "Release $VERSION" "$VERSION"
54+
git reset --hard "${OLD_HEAD}"
55+
}
56+
57+
register_cleanup() {
58+
OLD_HEAD="$(git rev-parse HEAD)"
59+
}
60+
61+
unregister_cleanup() {
62+
OLD_HEAD=""
63+
}
64+
65+
trap cleanup EXIT
66+
67+
register_cleanup
68+
4469
# expected version regex
4570
re='^v([0-9]+\.[0-9]+(\.[0-9]+)?)(-rc[0-9]+)?$'
4671

@@ -57,7 +82,7 @@ fi
5782

5883
cd "$(git rev-parse --show-toplevel)" || exit 1
5984

60-
if [[ -f subprojects/libnvme.wrap ]]; then
85+
if [ "$update_lib_dep" = true ] && [[ -f subprojects/libnvme.wrap ]]; then
6186
git -C subprojects/libnvme fetch --all
6287

6388
# extract the version string from libnvme by using the ref
@@ -75,16 +100,18 @@ if [[ -f subprojects/libnvme.wrap ]]; then
75100
fi
76101
fi
77102

78-
if [[ -n $(git status -s) ]]; then
79-
echo "tree is dirty."
80-
if [[ "${dry_run}" = false ]]; then
81-
exit 1
103+
if [ "$force" = false ] ; then
104+
if [[ -n $(git status -s) ]]; then
105+
echo "tree is dirty."
106+
if [[ "${dry_run}" = false ]]; then
107+
exit 1
108+
fi
82109
fi
83-
fi
84110

85-
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
86-
echo "currently not on master branch. abort."
87-
exit 1
111+
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
112+
echo "currently not on master branch. abort."
113+
exit 1
114+
fi
88115
fi
89116

90117
# update all docs
@@ -98,35 +125,28 @@ else
98125
exit 1
99126
fi
100127

101-
# update meson.build
102-
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$ver\',/" meson.build
103-
if [[ -f subprojects/libnvme.wrap ]]; then
104-
sed -i -e "s/\(dependency('libnvme', version: '>=\)\([\.1-9]\+\)/\1$libnvme_ver/" meson.build
105-
fi
106-
107-
if [[ "${dry_run}" = false ]]; then
108-
git add meson.build
109-
git commit -s -m "build: Update version to $VERSION"
110-
fi
111-
112128
if [ "$build_doc" = true ]; then
113129
# update documentation
114130
./scripts/update-docs.sh
115-
if [[ "${dry_run}" = false ]]; then
116-
git add $doc_dir
117-
git commit -s -m "doc: Regenerate all docs for $VERSION"
118-
fi
131+
git add $doc_dir
132+
git commit -s -m "doc: Regenerate all docs for $VERSION"
119133
fi
120134

121-
if [[ "${dry_run}" = true ]]; then
122-
exit 0
135+
# update meson.build
136+
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$ver\',/" meson.build
137+
if [[ -n "$libnvme_VERSION" ]] && [[ -f subprojects/libnvme.wrap ]]; then
138+
sed -i -e "s/\(dependency('libnvme', version: '>=\)\([\.1-9]\+\)/\1$libnvme_ver/" meson.build
123139
fi
124140

141+
git add meson.build
142+
git commit -s -m "Release $VERSION"
143+
125144
git tag -s -m "Release $VERSION" "$VERSION"
126145
git push --dry-run origin "$VERSION"^{}:master tag "$VERSION"
127146

128147
read -p "All good? Ready to push changes to remote? [Yy]" -n 1 -r
129148
echo
130149
if [[ $REPLY =~ ^[Yy]$ ]]; then
131150
git push origin "$VERSION"^{}:master tag "$VERSION"
151+
unregister_cleanup
132152
fi

0 commit comments

Comments
 (0)