mirror of https://github.com/rwf2/Rocket.git
Improve doc building scripts.
Also removes unused 'bump_version' script.
This commit is contained in:
parent
f75fb63689
commit
ee59f26ec8
|
@ -1,41 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
#
|
||||
# Bumps the version number to ${1}.
|
||||
#
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "${SCRIPT_DIR}/config.sh"
|
||||
|
||||
if [ -z "${1}" ] ; then
|
||||
echo "Usage: $0 <new-version>"
|
||||
echo "Example: $0 0.6.1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function do_replace_docs() {
|
||||
sd "${1}" "${2}" $(fd -t f -e toml -E '/news/*' . "${PROJECT_ROOT}")
|
||||
sd "${1}" "${2}" $(fd -t f -e md -E '/news/*' . "${SITE_ROOT}")
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
do_replace_all "${VERSION}" "${NEW_VERSION}"
|
||||
sd "^date.*" "date = \"${TODAY}\"" "${SITE_ROOT}/index.toml"
|
|
@ -56,19 +56,18 @@ 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=false
|
||||
PRE_RELEASE=true
|
||||
GIT_BRANCH="$(git branch --show-current)"
|
||||
GIT_BRANCH=${GIT_BRANCH:-$BRANCH}
|
||||
IS_RELEASE_BRANCH=$( [[ $GIT_BRANCH == "v"* ]]; echo $? )
|
||||
|
||||
# A generated codename for this version. Use the git branch for pre-releases.
|
||||
case $PRE_RELEASE in
|
||||
true)
|
||||
CODENAME="${VIRTUAL_CODENAME}"
|
||||
DOC_VERSION="${VERSION}-$(future_date)"
|
||||
case $IS_RELEASE_BRANCH in
|
||||
1)
|
||||
CODENAME="${GIT_BRANCH}"
|
||||
DOC_VERSION="${GIT_BRANCH}-$(future_date)"
|
||||
;;
|
||||
false)
|
||||
CODENAME="${PHYSICAL_CODENAME}"
|
||||
*)
|
||||
CODENAME="${MAJOR_VERSION}"
|
||||
DOC_VERSION="${VERSION}"
|
||||
;;
|
||||
esac
|
||||
|
@ -104,12 +103,10 @@ ALL_CRATE_ROOTS=(
|
|||
function print_environment() {
|
||||
echo " VERSION: ${VERSION}"
|
||||
echo " MAJOR_VERSION: ${MAJOR_VERSION}"
|
||||
echo " GIT_BRANCH: ${GIT_BRANCH}"
|
||||
echo " IS_RELEASE_BRANCH: ${IS_RELEASE_BRANCH}"
|
||||
echo " CODENAME: ${CODENAME}"
|
||||
echo " PHYSICAL_CODENAME: ${PHYSICAL_CODENAME}"
|
||||
echo " VIRTUAL_CODENAME: ${VIRTUAL_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}"
|
||||
|
|
|
@ -17,7 +17,7 @@ if [ "${1}" != "-d" ]; then
|
|||
fi
|
||||
|
||||
# Generate the rustdocs for all of the crates.
|
||||
echo ":::: Generating the docs..."
|
||||
echo ":::: Generating docs (${DOC_VERSION})..."
|
||||
pushd "${PROJECT_ROOT}" > /dev/null 2>&1
|
||||
# Set the crate version and fill in missing doc URLs with docs.rs links.
|
||||
RUSTDOCFLAGS="-Z unstable-options \
|
||||
|
@ -31,5 +31,19 @@ pushd "${PROJECT_ROOT}" > /dev/null 2>&1
|
|||
-p rocket_ws
|
||||
popd > /dev/null 2>&1
|
||||
|
||||
# Blank index, for redirection.
|
||||
touch "${DOC_DIR}/index.html"
|
||||
# Generating redirection list: from to.
|
||||
echo ":::: Generating redirects..."
|
||||
REDIRECTS="
|
||||
/ /v0.5/rocket/ 302!
|
||||
/v0.4 https://docs.rs/rocket/0.4/rocket/
|
||||
/v0.4/:crate/* https://docs.rs/:crate/0.4/:crate/:splat
|
||||
/:v /:v/rocket/
|
||||
/v0.5/* https://v0-5--rocket-docs.netlify.app/:splat 200
|
||||
/:v/* https://:v--rocket-docs.netlify.app/:splat 200
|
||||
"
|
||||
|
||||
if [ "${GIT_BRANCH}" = "master" ]; then
|
||||
echo "${REDIRECTS}" | tee "${DOC_DIR}/_redirects"
|
||||
else
|
||||
echo "-> '${GIT_BRANCH}' branch does not require redirects"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue