Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change commit order on release #847

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions doc/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ copyright = '2020, Keith Busch'
author = 'Keith Busch <kbusch@kernel.org>'
master_doc = 'index'

release = '@VERSION@'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down
86 changes: 53 additions & 33 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ usage() {
echo "The script does all necessary steps to create a new release."
echo ""
echo " -d: no documentation update"
echo " -n: dry run"
echo " -f: disable all sanity checks and just do the release"
echo " -l: do not update library dependency"
echo ""
echo "Note: The version number needs to be exactly"
echo " '^v[\d]+.[\d]+(.[\d\]+(-rc[0-9]+)?$'"
Expand All @@ -17,15 +18,19 @@ usage() {
}

build_doc=true
dry_run=false
update_lib_dep=true
force=false

while getopts "dn" o; do
while getopts "dfl" o; do
case "${o}" in
d)
build_doc=false
;;
n)
dry_run=true
f)
force=true
;;
l)
update_lib_dep=false
;;
*)
usage
Expand All @@ -41,6 +46,26 @@ if [ -z "$VERSION" ] ; then
exit 1
fi

cleanup() {
if [ -z "${OLD_HEAD}" ] ; then
exit
fi
git tag -d "Release $VERSION" "$VERSION"
git reset --hard "${OLD_HEAD}"
}

register_cleanup() {
OLD_HEAD="$(git rev-parse HEAD)"
}

unregister_cleanup() {
OLD_HEAD=""
}

trap cleanup EXIT

register_cleanup

# expected version regex
re='^v([0-9]+\.[0-9]+(\.[0-9]+)?)(-rc[0-9]+)?$'

Expand All @@ -57,10 +82,10 @@ fi

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

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

# extract the vesion string from libnvme by using the ref
# extract the version string from libnvme by using the ref
# defined in libnvme.wrap.
libnvme_ref=$(sed -n "s/revision = \([0-9a-z]\+\)/\1/p" subprojects/libnvme.wrap)
libnvme_VERSION=$(git -C subprojects/libnvme describe "${libnvme_ref}")
Expand All @@ -75,16 +100,18 @@ if [[ -f subprojects/libnvme.wrap ]]; then
fi
fi

if [[ -n $(git status -s) ]]; then
echo "tree is dirty."
if [[ "${dry_run}" = false ]]; then
exit 1
if [ "$force" = false ] ; then
if [[ -n $(git status -s) ]]; then
echo "tree is dirty."
if [[ "${dry_run}" = false ]]; then
exit 1
fi
fi
fi

if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
echo "currently not on master branch. abort."
exit 1
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
echo "currently not on master branch. abort."
exit 1
fi
fi

# update all docs
Expand All @@ -94,39 +121,32 @@ if [ -d "Documentation" ]; then
elif [ -d "doc" ]; then
doc_dir="doc"
else
echo "documenation directory not found"
echo "documentation directory not found"
exit 1
fi

# update meson.build
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$ver\',/" meson.build
if [[ -f subprojects/libnvme.wrap ]]; then
sed -i -e "s/\(dependency('libnvme', version: '>=\)\([\.1-9]\+\)/\1$libnvme_ver/" meson.build
fi

if [[ "${dry_run}" = false ]]; then
git add meson.build
git commit -s -m "build: Update version to $VERSION"
fi

if [ "$build_doc" = true ]; then
# update documentation
./scripts/update-docs.sh
if [[ "${dry_run}" = false ]]; then
git add $doc_dir
git commit -s -m "doc: Regenerate all docs for $VERSION"
fi
git add $doc_dir
git commit -s -m "doc: Regenerate all docs for $VERSION"
fi

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

git add meson.build
git commit -s -m "Release $VERSION"

git tag -s -m "Release $VERSION" "$VERSION"
git push --dry-run origin "$VERSION"^{}:master tag "$VERSION"

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