Skip to content

Commit 08bf1c5

Browse files
committed
Update scripts.
1 parent 86bd7c1 commit 08bf1c5

File tree

5 files changed

+90
-66
lines changed

5 files changed

+90
-66
lines changed

scripts/bump_version.sh

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
#! /usr/bin/env bash
22

33
#
4-
# Bumps the version number from <current> to <next> on all libraries.
4+
# Bumps the version number to ${1}.
55
#
66

77
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
88
source "${SCRIPT_DIR}/config.sh"
99

10-
if [ -z "${1}" ] || [ -z "${2}" ]; then
11-
echo "Usage: $0 <current> <next>"
12-
echo "Example: $0 0.1.1 0.1.2"
10+
if [ -z "${1}" ] ; then
11+
echo "Usage: $0 <new-version>"
12+
echo "Example: $0 0.6.1"
1313
exit 1
1414
fi
1515

16-
if ! git grep -c "${1}" > /dev/null; then
17-
echo "The version '${1}' doesn't appear to be correct."
18-
echo "Exiting."
19-
exit 1
20-
fi
21-
22-
function major() {
23-
echo "${1}" | cut -d'.' -f1-2
16+
function do_replace_docs() {
17+
sd "${1}" "${2}" $(fd -t f -e toml -E '/news/*' . "${PROJECT_ROOT}")
18+
sd "${1}" "${2}" $(fd -t f -e md -E '/news/*' . "${SITE_ROOT}")
2419
}
2520

26-
function do_replace() {
27-
find "${PROJECT_ROOT}" -name "*.rs" | xargs sed -i.bak "s/${1}/${2}/g"
28-
find "${PROJECT_ROOT}" -name "*.toml" | xargs sed -i.bak "s/${1}/${2}/g"
29-
find "${SITE_ROOT}" -name "*.md" | xargs sed -i.bak "s/${1}/${2}/g"
30-
sed -i.bak "s/${1}/${2}/g" "${SCRIPT_DIR}/config.sh"
31-
sed -i.bak "s/${1}/${2}/g" "${PROJECT_ROOT}/README.md"
21+
function do_replace_all() {
22+
sd "${1}" "${2}" $(fd -t f -e rs . "${PROJECT_ROOT}")
23+
do_replace_docs "${1}" "${2}"
3224
}
3325

34-
do_replace "v$(major ${1})" "v$(major ${2})"
35-
do_replace "${1}" "${2}"
36-
37-
today=$(date "+%b %d, %Y")
38-
sed -i.bak "s/^date.*/date = \"$today\"/" "${SITE_ROOT}/index.toml"
26+
NEW_VERSION="${1}"
27+
TODAY=$(date "+%b %d, %Y")
28+
29+
if $PRE_RELEASE; then
30+
do_replace_all "/${PHYSICAL_CODENAME}" "/${CODENAME}"
31+
do_replace_docs "${PHYSICAL_CODENAME}" "${CODENAME}"
32+
else
33+
NEW_CODENAME="v$(echo "${NEW_VERSION}" | cut -d'.' -f1-2)"
34+
do_replace_all "/${VIRTUAL_CODENAME}" "/${CODENAME}"
35+
do_replace_all "/${CODENAME}" "/${NEW_CODENAME}"
36+
do_replace_docs "${VIRTUAL_CODENAME}" "${CODENAME}"
37+
do_replace_docs "${CODENAME}" "${NEW_CODENAME}"
38+
fi
3939

40-
find ${PROJECT_ROOT} -name "*.bak" | xargs rm
40+
do_replace_all "${VERSION}" "${NEW_VERSION}"
41+
sd "^date.*" "date = \"${TODAY}\"" "${SITE_ROOT}/index.toml"

scripts/config.sh

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@ function future_date() {
3535
fi
3636
}
3737

38-
# Versioning information. These are toggled as versions change.
39-
CURRENT_RELEASE=true
40-
PRE_RELEASE=false
41-
42-
# A generated codename for this version. Use the git branch for pre-releases.
43-
case $PRE_RELEASE in
44-
true)
45-
VERSION_CODENAME="$(git branch --show-current)"
46-
ROCKET_VERSION="${VERSION_CODENAME}-$(future_date)"
47-
;;
48-
false)
49-
ROCKET_VERSION="0.4.5"
50-
VERSION_CODENAME="$(echo "v${ROCKET_VERSION}" | cut -d'.' -f1-2)"
51-
;;
52-
esac
53-
5438
# Root of workspace-like directories.
5539
PROJECT_ROOT=$(relative "") || exit $?
5640
CORE_ROOT=$(relative "core") || exit $?
@@ -68,6 +52,26 @@ CONTRIB_CODEGEN_ROOT=$(relative "contrib/codegen") || exit $?
6852
EXAMPLES_DIR=$(relative "examples") || exit $?
6953
DOC_DIR=$(relative "target/doc") || exit $?
7054

55+
# Versioning information. These are changed as versions change.
56+
VERSION=$(git grep -h "^version" "${CORE_LIB_ROOT}" | head -n 1 | cut -d '"' -f2)
57+
MAJOR_VERSION=$(echo "${VERSION}" | cut -d'.' -f1-2)
58+
VIRTUAL_CODENAME="$(git branch --show-current)"
59+
PHYSICAL_CODENAME="v${MAJOR_VERSION}"
60+
CURRENT_RELEASE=true
61+
PRE_RELEASE=false
62+
63+
# A generated codename for this version. Use the git branch for pre-releases.
64+
case $PRE_RELEASE in
65+
true)
66+
CODENAME="${VIRTUAL_CODENAME}"
67+
DOC_VERSION="${CODENAME}-$(future_date)"
68+
;;
69+
false)
70+
CODENAME="${PHYSICAL_CODENAME}"
71+
DOC_VERSION="${VERSION}"
72+
;;
73+
esac
74+
7175
ALL_PROJECT_DIRS=(
7276
"${CORE_HTTP_ROOT}"
7377
"${CORE_CODEGEN_ROOT}"
@@ -76,23 +80,29 @@ ALL_PROJECT_DIRS=(
7680
"${CONTRIB_LIB_ROOT}"
7781
)
7882

83+
function print_environment() {
84+
echo " VERSION: ${VERSION}"
85+
echo " MAJOR_VERSION: ${MAJOR_VERSION}"
86+
echo " CODENAME: ${CODENAME}"
87+
echo " DOC_VERSION: ${DOC_VERSION}"
88+
echo " CURRENT_RELEASE: ${CURRENT_RELEASE}"
89+
echo " PRE_RELEASE: ${PRE_RELEASE}"
90+
echo " SCRIPT_DIR: ${SCRIPT_DIR}"
91+
echo " PROJECT_ROOT: ${PROJECT_ROOT}"
92+
echo " CORE_ROOT: ${CORE_ROOT}"
93+
echo " CONTRIB_ROOT: ${CONTRIB_ROOT}"
94+
echo " SITE_ROOT: ${SITE_ROOT}"
95+
echo " CORE_LIB_ROOT: ${CORE_LIB_ROOT}"
96+
echo " CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}"
97+
echo " CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}"
98+
echo " CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}"
99+
echo " CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}"
100+
echo " EXAMPLES_DIR: ${EXAMPLES_DIR}"
101+
echo " DOC_DIR: ${DOC_DIR}"
102+
echo " ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}"
103+
echo " date(): $(future_date)"
104+
}
105+
79106
if [ "${1}" = "-p" ]; then
80-
echo "ROCKET_VERSION: ${ROCKET_VERSION}"
81-
echo "CURRENT_RELEASE: ${CURRENT_RELEASE}"
82-
echo "PRE_RELEASE: ${PRE_RELEASE}"
83-
echo "VERSION_CODENAME: ${VERSION_CODENAME}"
84-
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
85-
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
86-
echo "CORE_ROOT: ${CORE_ROOT}"
87-
echo "CONTRIB_ROOT: ${CONTRIB_ROOT}"
88-
echo "SITE_ROOT: ${SITE_ROOT}"
89-
echo "CORE_LIB_ROOT: ${CORE_LIB_ROOT}"
90-
echo "CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}"
91-
echo "CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}"
92-
echo "CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}"
93-
echo "CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}"
94-
echo "EXAMPLES_DIR: ${EXAMPLES_DIR}"
95-
echo "DOC_DIR: ${DOC_DIR}"
96-
echo "ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}"
97-
echo "date(): $(future_date)"
107+
print_environment
98108
fi

scripts/mk-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fi
1919
# Generate the rustdocs for all of the crates.
2020
echo ":::: Generating the docs..."
2121
pushd "${PROJECT_ROOT}" > /dev/null 2>&1
22-
RUSTDOCFLAGS="-Z unstable-options --crate-version ${ROCKET_VERSION}" \
22+
RUSTDOCFLAGS="-Z unstable-options --crate-version ${DOC_VERSION}" \
2323
cargo doc -p rocket -p rocket_contrib --no-deps --all-features
2424
popd > /dev/null 2>&1
2525

scripts/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function restore_dev_dependencies() {
1818
}
1919

2020
if ! [ -z "$(git status --porcelain)" ]; then
21-
echo "There are uncommited changes! Aborting."
21+
echo "There are uncommitted changes! Aborting."
2222
exit 1
2323
fi
2424

scripts/test.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ source "${SCRIPT_DIR}/config.sh"
77

88
# Add Cargo to PATH.
99
export PATH=${HOME}/.cargo/bin:${PATH}
10+
export CARGO_INCREMENTAL=0
11+
CARGO="cargo"
1012

1113
# Checks that the versions for Cargo projects $@ all match
1214
function check_versions_match() {
@@ -49,6 +51,15 @@ function ensure_trailing_whitespace_free() {
4951
fi
5052
}
5153

54+
if [[ $1 == +* ]]; then
55+
CARGO="$CARGO $1"
56+
shift
57+
fi
58+
59+
echo ":: Preparing. Environment is..."
60+
print_environment
61+
echo " CARGO: $CARGO"
62+
5263
echo ":: Ensuring all crate versions match..."
5364
check_versions_match "${ALL_PROJECT_DIRS[@]}"
5465

@@ -59,7 +70,9 @@ echo ":: Checking for trailing whitespace..."
5970
ensure_trailing_whitespace_free
6071

6172
echo ":: Updating dependencies..."
62-
cargo update
73+
if ! $CARGO update ; then
74+
echo " WARNING: Update failed! Proceeding with possibly outdated deps..."
75+
fi
6376

6477
if [ "$1" = "--contrib" ]; then
6578
FEATURES=(
@@ -84,11 +97,11 @@ if [ "$1" = "--contrib" ]; then
8497
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
8598

8699
echo ":: Building and testing contrib [default]..."
87-
CARGO_INCREMENTAL=0 cargo test
100+
$CARGO test
88101

89102
for feature in "${FEATURES[@]}"; do
90103
echo ":: Building and testing contrib [${feature}]..."
91-
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}"
104+
$CARGO test --no-default-features --features "${feature}"
92105
done
93106

94107
popd > /dev/null 2>&1
@@ -101,15 +114,15 @@ elif [ "$1" = "--core" ]; then
101114
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
102115

103116
echo ":: Building and testing core [no features]..."
104-
CARGO_INCREMENTAL=0 cargo test --no-default-features
117+
$CARGO test --no-default-features
105118

106119
for feature in "${FEATURES[@]}"; do
107120
echo ":: Building and testing core [${feature}]..."
108-
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}"
121+
$CARGO test --no-default-features --features "${feature}"
109122
done
110123

111124
popd > /dev/null 2>&1
112125
else
113126
echo ":: Building and testing libraries..."
114-
CARGO_INCREMENTAL=0 cargo test --all-features --all $@
127+
$CARGO test --all-features --all $@
115128
fi

0 commit comments

Comments
 (0)