Rocket/scripts/publish.sh

52 lines
1.3 KiB
Bash
Raw Normal View History

2016-12-24 21:05:32 +00:00
#! /usr/bin/env bash
set -e
#
# Publishes the current versions of all Rocket crates to crates.io.
2016-12-24 21:05:32 +00:00
#
# Brings in _ROOT, _DIR, _DIRS globals.
2016-12-24 21:05:32 +00:00
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPT_DIR}/config.sh"
2016-12-24 21:05:32 +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"
}
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
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
bash "${SCRIPT_DIR}/test.sh"
bash "${SCRIPT_DIR}/test.sh" --contrib
bash "${SCRIPT_DIR}/test.sh" --release
2016-12-24 21:05:32 +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.
for dir in "${ALL_PROJECT_DIRS[@]}"; do
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
# Restore dev-dependencies.
echo ":::: Restoring [dev-dependencies]..."
for dir in "${ALL_PROJECT_DIRS[@]}"; do
restore_dev_dependencies "${dir}"
done