forked from rwf2/Rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·52 lines (43 loc) · 1.39 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env bash
set -e
#
# Publishes the current versions of all Rocket crates to crates.io.
#
# Brings in _ROOT, _DIR, _DIRS globals.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPT_DIR}/config.sh"
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"
}
if ! [ -z "$(git status --porcelain)" ]; then
echo "There are uncommitted changes! Aborting."
exit 1
fi
# Ensure everything passes before trying to publish.
echo ":::: Running complete test suite..."
cargo clean
bash "${SCRIPT_DIR}/test.sh" +stable --all
bash "${SCRIPT_DIR}/test.sh" +stable --all --release
# Temporarily remove dev-dependencies so crates.io verifies.
echo ":::: Stripping [dev-dependencies]..."
for dir in "${ALL_CRATE_ROOTS[@]}"; do
strip_dev_dependencies "${dir}"
done
# Publish all the things.
for dir in "${ALL_CRATE_ROOTS[@]}"; do
pushd "${dir}"
echo ":::: Publishing '${dir}'..."
# We already checked things ourselves. Don't spend time reverifying.
cargo publish --no-verify --allow-dirty ${@:1}
# Give the index some time to update so the deps are there if we need them.
sleep 5
popd
done
# Restore dev-dependencies.
echo ":::: Restoring [dev-dependencies]..."
for dir in "${ALL_CRATE_ROOTS[@]}"; do
restore_dev_dependencies "${dir}"
done