@@ -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
1819build_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
3742fi
3843
39- ver=" "
40-
44+ # expected version regex
4145re=' ^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} "
4653else
47- echo " Invalid version string $VERSION "
54+ echo " invalid version string $VERSION "
4855 exit 1
4956fi
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+
5178if [[ -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
5483fi
5584
5685if [ " $( git rev-parse --abbrev-ref HEAD) " != " master" ] ; then
71100
72101# update meson.build
73102sed -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
77112if [ " $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
82123fi
83124
84125git tag -s -m " Release $VERSION " " $VERSION "
0 commit comments