two utility scripts for updating version and publishing

This commit is contained in:
Niko Matsakis 2015-07-27 05:35:17 -04:00
parent d8a47a7345
commit 86a221bbb0
2 changed files with 62 additions and 0 deletions

47
publish.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
#
# A script to bump the version number on all Cargo.toml files etc in
# an atomic fashion.
VERSION=$(
ls lalrpop*/Cargo.toml | \
xargs grep "# LALRPOP$" | \
perl -p -i -e 's/.*version = "([0-9.]+)" # LALRPOP$/$1/' |
sort |
uniq)
if [ $(echo $VERSION | wc -w) != 1 ]; then
echo "Error: inconsistent versions detected across Cargo.toml files!"
echo "$VERSION"
exit 1
fi
echo "Found consistent version $VERSION"
BASE_DIR="$PWD"
function publish_fail {
printf "ERROR\n"
cat $TMPDIR/publish-log
exit 1
}
function publish {
printf "Publishing %s..." "$1"
cd $1
cargo publish >& $TMPDIR/publish-log || publish_fail $1
cd $BASE_DIR
printf "OK\n"
}
publish lalrpop-util
publish lalrpop-snap
publish lalrpop
printf "Updated README version..."
perl -p -i -e 's/^version = "[0-9.]+"$/version = "'$VERSION'"/' \
README.md >& $TMPDIR/publish-log || publish_fail
git add README.md >& $TMPDIR/publish-log || publish_fail
printf "OK\n"
printf "\nAll set. Do not forget to commit new README.md.\n"

15
version.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
#
# A script to bump the version number on all Cargo.toml files etc in
# an atomic fashion.
if [ "$1" == "" ]; then
echo "Usage: version.sh <new-version-number>"
exit 1
fi
perl -p -i -e 's/version *= *"[0-9.]+" # LALRPOP$/version = "'$1'" # LALRPOP/' \
$(ls lalrpop*/Cargo.toml)
perl -p -i -e 's/^version = "[0-9.]+"$/version = "'$1'"/' \
README.md