Rocket/scripts/bump_version.sh

40 lines
1.0 KiB
Bash
Raw Normal View History

2016-12-24 20:41:30 +00:00
#! /usr/bin/env bash
#
# Bumps the version number from <current> to <next> on all libraries.
#
2018-10-07 04:16:02 +00:00
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPT_DIR}/config.sh"
if [ -z "${1}" ] || [ -z "${2}" ]; then
2016-12-24 20:41:30 +00:00
echo "Usage: $0 <current> <next>"
echo "Example: $0 0.1.1 0.1.2"
exit 1
fi
2018-10-07 04:16:02 +00:00
if ! git grep -c "${1}" > /dev/null; then
echo "The version '${1}' doesn't appear to be correct."
echo "Exiting."
exit 1
fi
2018-10-27 04:20:12 +00:00
function major() {
echo "${1}" | cut -d'.' -f1-2
}
2018-10-27 04:20:12 +00:00
function do_replace() {
find "${PROJECT_ROOT}" -name "*.rs" | xargs sed -i.bak "s/${1}/${2}/g"
find "${PROJECT_ROOT}" -name "*.toml" | xargs sed -i.bak "s/${1}/${2}/g"
find "${SITE_ROOT}" -name "*.md" | xargs sed -i.bak "s/${1}/${2}/g"
sed -i.bak "s/${1}/${2}/g" "${SCRIPT_DIR}/config.sh"
sed -i.bak "s/${1}/${2}/g" "${PROJECT_ROOT}/README.md"
}
do_replace "v$(major ${1})" "v$(major ${2})"
do_replace "${1}" "${2}"
# today=$(date "+%b %d, %Y")
# sed -i.bak "s/^date.*/date = \"$today\"/" "${SITE_ROOT}/index.toml"
2018-10-07 04:16:02 +00:00
find ${PROJECT_ROOT} -name "*.bak" | xargs rm