2016-12-24 21:05:32 +00:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
#
|
2018-06-07 13:34:47 +00:00
|
|
|
# Publishes the current versions of all Rocket crates to crates.io.
|
2016-12-24 21:05:32 +00:00
|
|
|
#
|
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Brings in _ROOT, _DIR, _DIRS globals.
|
2016-12-24 21:05:32 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2017-07-29 04:34:59 +00:00
|
|
|
source "${SCRIPT_DIR}/config.sh"
|
2016-12-24 21:05:32 +00:00
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
function strip_dev_dependencies() {
|
2018-12-01 04:58:20 +00:00
|
|
|
perl -i.bak -p0e 's/\[dev-dependencies\].*//smg' "${1}/Cargo.toml"
|
2018-06-07 13:34:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function restore_dev_dependencies() {
|
|
|
|
mv "${1}/Cargo.toml.bak" "${1}/Cargo.toml"
|
|
|
|
}
|
|
|
|
|
2018-10-29 11:55:18 +00:00
|
|
|
if ! [ -z "$(git status --porcelain)" ]; then
|
2020-11-10 07:08:51 +00:00
|
|
|
echo "There are uncommitted changes! Aborting."
|
2018-10-29 11:55:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-12-24 21:05:32 +00:00
|
|
|
# Ensure everything passes before trying to publish.
|
|
|
|
echo ":::: Running test suite..."
|
|
|
|
cargo clean
|
2017-07-29 04:34:59 +00:00
|
|
|
bash "${SCRIPT_DIR}/test.sh"
|
2018-12-01 05:00:10 +00:00
|
|
|
bash "${SCRIPT_DIR}/test.sh" --contrib
|
2018-05-31 18:28:54 +00:00
|
|
|
bash "${SCRIPT_DIR}/test.sh" --release
|
2016-12-24 21:05:32 +00:00
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Temporarily remove dev-dependencies so crates.io verifies.
|
|
|
|
echo ":::: Stripping [dev-dependencies]..."
|
|
|
|
for dir in "${ALL_PROJECT_DIRS[@]}"; do
|
|
|
|
strip_dev_dependencies "${dir}"
|
|
|
|
done
|
2016-12-24 21:05:32 +00:00
|
|
|
|
|
|
|
# Publish all the things.
|
2018-06-07 13:34:47 +00:00
|
|
|
for dir in "${ALL_PROJECT_DIRS[@]}"; do
|
2017-07-29 04:34:59 +00:00
|
|
|
pushd "${dir}"
|
2018-10-29 11:55:18 +00:00
|
|
|
echo ":::: Publishing '${dir}'..."
|
2016-12-24 21:05:32 +00:00
|
|
|
# We already checked things ourselves. Don't spend time reverifying.
|
2018-10-29 11:55:18 +00:00
|
|
|
cargo publish --no-verify --allow-dirty ${@:1}
|
2016-12-24 21:05:32 +00:00
|
|
|
popd
|
|
|
|
done
|
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Restore dev-dependencies.
|
|
|
|
echo ":::: Restoring [dev-dependencies]..."
|
|
|
|
for dir in "${ALL_PROJECT_DIRS[@]}"; do
|
|
|
|
restore_dev_dependencies "${dir}"
|
|
|
|
done
|