mirror of https://github.com/rwf2/Rocket.git
Update scripts.
This commit is contained in:
parent
86bd7c1008
commit
08bf1c5bdb
|
@ -1,40 +1,41 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bumps the version number from <current> to <next> on all libraries.
|
# Bumps the version number to ${1}.
|
||||||
#
|
#
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
source "${SCRIPT_DIR}/config.sh"
|
source "${SCRIPT_DIR}/config.sh"
|
||||||
|
|
||||||
if [ -z "${1}" ] || [ -z "${2}" ]; then
|
if [ -z "${1}" ] ; then
|
||||||
echo "Usage: $0 <current> <next>"
|
echo "Usage: $0 <new-version>"
|
||||||
echo "Example: $0 0.1.1 0.1.2"
|
echo "Example: $0 0.6.1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! git grep -c "${1}" > /dev/null; then
|
function do_replace_docs() {
|
||||||
echo "The version '${1}' doesn't appear to be correct."
|
sd "${1}" "${2}" $(fd -t f -e toml -E '/news/*' . "${PROJECT_ROOT}")
|
||||||
echo "Exiting."
|
sd "${1}" "${2}" $(fd -t f -e md -E '/news/*' . "${SITE_ROOT}")
|
||||||
exit 1
|
}
|
||||||
|
|
||||||
|
function do_replace_all() {
|
||||||
|
sd "${1}" "${2}" $(fd -t f -e rs . "${PROJECT_ROOT}")
|
||||||
|
do_replace_docs "${1}" "${2}"
|
||||||
|
}
|
||||||
|
|
||||||
|
NEW_VERSION="${1}"
|
||||||
|
TODAY=$(date "+%b %d, %Y")
|
||||||
|
|
||||||
|
if $PRE_RELEASE; then
|
||||||
|
do_replace_all "/${PHYSICAL_CODENAME}" "/${CODENAME}"
|
||||||
|
do_replace_docs "${PHYSICAL_CODENAME}" "${CODENAME}"
|
||||||
|
else
|
||||||
|
NEW_CODENAME="v$(echo "${NEW_VERSION}" | cut -d'.' -f1-2)"
|
||||||
|
do_replace_all "/${VIRTUAL_CODENAME}" "/${CODENAME}"
|
||||||
|
do_replace_all "/${CODENAME}" "/${NEW_CODENAME}"
|
||||||
|
do_replace_docs "${VIRTUAL_CODENAME}" "${CODENAME}"
|
||||||
|
do_replace_docs "${CODENAME}" "${NEW_CODENAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function major() {
|
do_replace_all "${VERSION}" "${NEW_VERSION}"
|
||||||
echo "${1}" | cut -d'.' -f1-2
|
sd "^date.*" "date = \"${TODAY}\"" "${SITE_ROOT}/index.toml"
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
find ${PROJECT_ROOT} -name "*.bak" | xargs rm
|
|
||||||
|
|
|
@ -35,22 +35,6 @@ function future_date() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Versioning information. These are toggled as versions change.
|
|
||||||
CURRENT_RELEASE=true
|
|
||||||
PRE_RELEASE=false
|
|
||||||
|
|
||||||
# A generated codename for this version. Use the git branch for pre-releases.
|
|
||||||
case $PRE_RELEASE in
|
|
||||||
true)
|
|
||||||
VERSION_CODENAME="$(git branch --show-current)"
|
|
||||||
ROCKET_VERSION="${VERSION_CODENAME}-$(future_date)"
|
|
||||||
;;
|
|
||||||
false)
|
|
||||||
ROCKET_VERSION="0.4.5"
|
|
||||||
VERSION_CODENAME="$(echo "v${ROCKET_VERSION}" | cut -d'.' -f1-2)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Root of workspace-like directories.
|
# Root of workspace-like directories.
|
||||||
PROJECT_ROOT=$(relative "") || exit $?
|
PROJECT_ROOT=$(relative "") || exit $?
|
||||||
CORE_ROOT=$(relative "core") || exit $?
|
CORE_ROOT=$(relative "core") || exit $?
|
||||||
|
@ -68,6 +52,26 @@ CONTRIB_CODEGEN_ROOT=$(relative "contrib/codegen") || exit $?
|
||||||
EXAMPLES_DIR=$(relative "examples") || exit $?
|
EXAMPLES_DIR=$(relative "examples") || exit $?
|
||||||
DOC_DIR=$(relative "target/doc") || exit $?
|
DOC_DIR=$(relative "target/doc") || exit $?
|
||||||
|
|
||||||
|
# Versioning information. These are changed as versions change.
|
||||||
|
VERSION=$(git grep -h "^version" "${CORE_LIB_ROOT}" | head -n 1 | cut -d '"' -f2)
|
||||||
|
MAJOR_VERSION=$(echo "${VERSION}" | cut -d'.' -f1-2)
|
||||||
|
VIRTUAL_CODENAME="$(git branch --show-current)"
|
||||||
|
PHYSICAL_CODENAME="v${MAJOR_VERSION}"
|
||||||
|
CURRENT_RELEASE=true
|
||||||
|
PRE_RELEASE=false
|
||||||
|
|
||||||
|
# A generated codename for this version. Use the git branch for pre-releases.
|
||||||
|
case $PRE_RELEASE in
|
||||||
|
true)
|
||||||
|
CODENAME="${VIRTUAL_CODENAME}"
|
||||||
|
DOC_VERSION="${CODENAME}-$(future_date)"
|
||||||
|
;;
|
||||||
|
false)
|
||||||
|
CODENAME="${PHYSICAL_CODENAME}"
|
||||||
|
DOC_VERSION="${VERSION}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
ALL_PROJECT_DIRS=(
|
ALL_PROJECT_DIRS=(
|
||||||
"${CORE_HTTP_ROOT}"
|
"${CORE_HTTP_ROOT}"
|
||||||
"${CORE_CODEGEN_ROOT}"
|
"${CORE_CODEGEN_ROOT}"
|
||||||
|
@ -76,23 +80,29 @@ ALL_PROJECT_DIRS=(
|
||||||
"${CONTRIB_LIB_ROOT}"
|
"${CONTRIB_LIB_ROOT}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function print_environment() {
|
||||||
|
echo " VERSION: ${VERSION}"
|
||||||
|
echo " MAJOR_VERSION: ${MAJOR_VERSION}"
|
||||||
|
echo " CODENAME: ${CODENAME}"
|
||||||
|
echo " DOC_VERSION: ${DOC_VERSION}"
|
||||||
|
echo " CURRENT_RELEASE: ${CURRENT_RELEASE}"
|
||||||
|
echo " PRE_RELEASE: ${PRE_RELEASE}"
|
||||||
|
echo " SCRIPT_DIR: ${SCRIPT_DIR}"
|
||||||
|
echo " PROJECT_ROOT: ${PROJECT_ROOT}"
|
||||||
|
echo " CORE_ROOT: ${CORE_ROOT}"
|
||||||
|
echo " CONTRIB_ROOT: ${CONTRIB_ROOT}"
|
||||||
|
echo " SITE_ROOT: ${SITE_ROOT}"
|
||||||
|
echo " CORE_LIB_ROOT: ${CORE_LIB_ROOT}"
|
||||||
|
echo " CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}"
|
||||||
|
echo " CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}"
|
||||||
|
echo " CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}"
|
||||||
|
echo " CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}"
|
||||||
|
echo " EXAMPLES_DIR: ${EXAMPLES_DIR}"
|
||||||
|
echo " DOC_DIR: ${DOC_DIR}"
|
||||||
|
echo " ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}"
|
||||||
|
echo " date(): $(future_date)"
|
||||||
|
}
|
||||||
|
|
||||||
if [ "${1}" = "-p" ]; then
|
if [ "${1}" = "-p" ]; then
|
||||||
echo "ROCKET_VERSION: ${ROCKET_VERSION}"
|
print_environment
|
||||||
echo "CURRENT_RELEASE: ${CURRENT_RELEASE}"
|
|
||||||
echo "PRE_RELEASE: ${PRE_RELEASE}"
|
|
||||||
echo "VERSION_CODENAME: ${VERSION_CODENAME}"
|
|
||||||
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
|
|
||||||
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
|
|
||||||
echo "CORE_ROOT: ${CORE_ROOT}"
|
|
||||||
echo "CONTRIB_ROOT: ${CONTRIB_ROOT}"
|
|
||||||
echo "SITE_ROOT: ${SITE_ROOT}"
|
|
||||||
echo "CORE_LIB_ROOT: ${CORE_LIB_ROOT}"
|
|
||||||
echo "CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}"
|
|
||||||
echo "CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}"
|
|
||||||
echo "CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}"
|
|
||||||
echo "CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}"
|
|
||||||
echo "EXAMPLES_DIR: ${EXAMPLES_DIR}"
|
|
||||||
echo "DOC_DIR: ${DOC_DIR}"
|
|
||||||
echo "ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}"
|
|
||||||
echo "date(): $(future_date)"
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -19,7 +19,7 @@ fi
|
||||||
# Generate the rustdocs for all of the crates.
|
# Generate the rustdocs for all of the crates.
|
||||||
echo ":::: Generating the docs..."
|
echo ":::: Generating the docs..."
|
||||||
pushd "${PROJECT_ROOT}" > /dev/null 2>&1
|
pushd "${PROJECT_ROOT}" > /dev/null 2>&1
|
||||||
RUSTDOCFLAGS="-Z unstable-options --crate-version ${ROCKET_VERSION}" \
|
RUSTDOCFLAGS="-Z unstable-options --crate-version ${DOC_VERSION}" \
|
||||||
cargo doc -p rocket -p rocket_contrib --no-deps --all-features
|
cargo doc -p rocket -p rocket_contrib --no-deps --all-features
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ function restore_dev_dependencies() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! [ -z "$(git status --porcelain)" ]; then
|
if ! [ -z "$(git status --porcelain)" ]; then
|
||||||
echo "There are uncommited changes! Aborting."
|
echo "There are uncommitted changes! Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ source "${SCRIPT_DIR}/config.sh"
|
||||||
|
|
||||||
# Add Cargo to PATH.
|
# Add Cargo to PATH.
|
||||||
export PATH=${HOME}/.cargo/bin:${PATH}
|
export PATH=${HOME}/.cargo/bin:${PATH}
|
||||||
|
export CARGO_INCREMENTAL=0
|
||||||
|
CARGO="cargo"
|
||||||
|
|
||||||
# Checks that the versions for Cargo projects $@ all match
|
# Checks that the versions for Cargo projects $@ all match
|
||||||
function check_versions_match() {
|
function check_versions_match() {
|
||||||
|
@ -49,6 +51,15 @@ function ensure_trailing_whitespace_free() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ $1 == +* ]]; then
|
||||||
|
CARGO="$CARGO $1"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ":: Preparing. Environment is..."
|
||||||
|
print_environment
|
||||||
|
echo " CARGO: $CARGO"
|
||||||
|
|
||||||
echo ":: Ensuring all crate versions match..."
|
echo ":: Ensuring all crate versions match..."
|
||||||
check_versions_match "${ALL_PROJECT_DIRS[@]}"
|
check_versions_match "${ALL_PROJECT_DIRS[@]}"
|
||||||
|
|
||||||
|
@ -59,7 +70,9 @@ echo ":: Checking for trailing whitespace..."
|
||||||
ensure_trailing_whitespace_free
|
ensure_trailing_whitespace_free
|
||||||
|
|
||||||
echo ":: Updating dependencies..."
|
echo ":: Updating dependencies..."
|
||||||
cargo update
|
if ! $CARGO update ; then
|
||||||
|
echo " WARNING: Update failed! Proceeding with possibly outdated deps..."
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$1" = "--contrib" ]; then
|
if [ "$1" = "--contrib" ]; then
|
||||||
FEATURES=(
|
FEATURES=(
|
||||||
|
@ -84,11 +97,11 @@ if [ "$1" = "--contrib" ]; then
|
||||||
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
|
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
|
||||||
|
|
||||||
echo ":: Building and testing contrib [default]..."
|
echo ":: Building and testing contrib [default]..."
|
||||||
CARGO_INCREMENTAL=0 cargo test
|
$CARGO test
|
||||||
|
|
||||||
for feature in "${FEATURES[@]}"; do
|
for feature in "${FEATURES[@]}"; do
|
||||||
echo ":: Building and testing contrib [${feature}]..."
|
echo ":: Building and testing contrib [${feature}]..."
|
||||||
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}"
|
$CARGO test --no-default-features --features "${feature}"
|
||||||
done
|
done
|
||||||
|
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
|
@ -101,15 +114,15 @@ elif [ "$1" = "--core" ]; then
|
||||||
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
|
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
|
||||||
|
|
||||||
echo ":: Building and testing core [no features]..."
|
echo ":: Building and testing core [no features]..."
|
||||||
CARGO_INCREMENTAL=0 cargo test --no-default-features
|
$CARGO test --no-default-features
|
||||||
|
|
||||||
for feature in "${FEATURES[@]}"; do
|
for feature in "${FEATURES[@]}"; do
|
||||||
echo ":: Building and testing core [${feature}]..."
|
echo ":: Building and testing core [${feature}]..."
|
||||||
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}"
|
$CARGO test --no-default-features --features "${feature}"
|
||||||
done
|
done
|
||||||
|
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
echo ":: Building and testing libraries..."
|
echo ":: Building and testing libraries..."
|
||||||
CARGO_INCREMENTAL=0 cargo test --all-features --all $@
|
$CARGO test --all-features --all $@
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue