Rocket/scripts/publish.sh

51 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2016-12-24 21:05:32 +00:00
#! /usr/bin/env bash
set -e
#
2018-10-29 08:48:33 +00:00
# Publishes the current versions of all Rocket crates to crates.io.
2016-12-24 21:05:32 +00:00
#
2016-12-29 04:33:56 +00:00
# Brings in: ROOT_DIR, EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, CONTRIB_DIR, DOC_DIR
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
2016-12-24 23:33:43 +00:00
if ! [ -z "$(git status --porcelain)" ]; then
echo "There are uncommited changes! Aborting."
exit 1
fi
2018-10-29 08:48:33 +00:00
function strip_dev_dependencies() {
perl -i.bak -p0e 's/\[dev-dependencies\][^\[]*//smg' "${1}/Cargo.toml"
}
function restore_dev_dependencies() {
mv "${1}/Cargo.toml.bak" "${1}/Cargo.toml"
}
2016-12-24 21:05:32 +00:00
# Ensure everything passes before trying to publish.
2018-10-29 08:48:33 +00:00
echo ":::: Running test suite..."
2016-12-24 21:05:32 +00:00
cargo clean
bash "${SCRIPT_DIR}/test.sh"
2018-10-29 08:48:33 +00:00
bash "${SCRIPT_DIR}/test.sh --release"
2018-10-29 08:48:33 +00:00
# Temporarily remove dev-dependencies so crates.io verifies.
echo ":::: Stripping [dev-dependencies]..."
for dir in "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}"; do
strip_dev_dependencies "${dir}"
done
2016-12-24 21:05:32 +00:00
# Publish all the things.
for dir in "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}"; do
pushd "${dir}"
2016-12-24 21:05:32 +00:00
echo ":::: Publishing '${dir}..."
# We already checked things ourselves. Don't spend time reverifying.
2016-12-24 23:33:43 +00:00
cargo publish --no-verify --allow-dirty
2016-12-24 21:05:32 +00:00
popd
done
2018-10-29 08:48:33 +00:00
# Restore dev-dependencies.
echo ":::: Restoring [dev-dependencies]..."
for dir in "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}"; do
restore_dev_dependencies "${dir}"
done