Skip to content

Commit 5820c8c

Browse files
dwsuseigaw
authored andcommitted
scripts: Sync release script
Sync with the nvme-cli release script. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 4416fa2 commit 5820c8c

1 file changed

Lines changed: 55 additions & 14 deletions

File tree

scripts/release.sh

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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"
910
echo ""
1011
echo "Note: The version number needs to be exactly"
1112
echo " '^v[\d]+.[\d]+(.[\d\]+(-rc[0-9]+)?$'"
@@ -16,12 +17,16 @@ usage() {
1617
}
1718

1819
build_doc=true
20+
dry_run=false
1921

20-
while getopts "d" o; do
22+
while getopts "dn" o; do
2123
case "${o}" in
2224
d)
2325
build_doc=false
2426
;;
27+
n)
28+
dry_run=true
29+
;;
2530
*)
2631
usage
2732
;;
@@ -36,21 +41,45 @@ if [ -z "$VERSION" ] ; then
3641
exit 1
3742
fi
3843

39-
ver=""
40-
44+
# expected version regex
4145
re='^v([0-9]+\.[0-9]+(\.[0-9]+)?)(-rc[0-9]+)?$'
42-
if [[ "$VERSION" =~ $re ]]; then
43-
echo "Valid version $VERSION string"
46+
47+
# use the version string provided from the command line
48+
if [[ "$VERSION" =~ ${re} ]]; then
49+
echo "valid version $VERSION string"
50+
4451
# remove the leading 'v'
45-
ver=${VERSION#v}
52+
ver="${VERSION#v}"
4653
else
47-
echo "Invalid version string $VERSION"
54+
echo "invalid version string $VERSION"
4855
exit 1
4956
fi
5057

58+
cd "$(git rev-parse --show-toplevel)" || exit 1
59+
60+
if [[ -f subprojects/libnvme.wrap ]]; then
61+
git -C subprojects/libnvme fetch --all
62+
63+
# extract the vesion string from libnvme by using the ref
64+
# defined in libnvme.wrap.
65+
libnvme_ref=$(sed -n "s/revision = \([0-9a-z]\+\)/\1/p" subprojects/libnvme.wrap)
66+
libnvme_VERSION=$(git -C subprojects/libnvme describe "${libnvme_ref}")
67+
if [[ "${libnvme_VERSION}" =~ ${re} ]]; then
68+
echo "libnvme: valid version ${libnvme_VERSION} string"
69+
70+
# remove the leading 'v'
71+
libnvme_ver="${libnvme_VERSION#v}"
72+
else
73+
echo "libnvme: invalid version string ${libnvme_VERSION}"
74+
exit 1
75+
fi
76+
fi
77+
5178
if [[ -n $(git status -s) ]]; then
52-
echo "tree is dirty. abort."
53-
exit 1
79+
echo "tree is dirty."
80+
if [[ "${dry_run}" = false ]]; then
81+
exit 1
82+
fi
5483
fi
5584

5685
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
@@ -71,14 +100,26 @@ fi
71100

72101
# update meson.build
73102
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$ver\',/" meson.build
74-
git add meson.build
75-
git commit -s -m "build: Update version to $VERSION"
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
76111

77112
if [ "$build_doc" = true ]; then
78113
# update documentation
79-
./$doc_dir/update-docs.sh
80-
git add $doc_dir
81-
git commit -s -m "doc: Regenerate all docs for $VERSION"
114+
./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
119+
fi
120+
121+
if [[ "${dry_run}" = true ]]; then
122+
exit 0
82123
fi
83124

84125
git tag -s -m "Release $VERSION" "$VERSION"

0 commit comments

Comments
 (0)