2023-03-28 23:11:39 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Check that we can publish crates in their current form if there are changes on top of the tip of
|
|
|
|
# master that imply that we are about to do a release.
|
|
|
|
|
2024-03-26 23:08:57 +00:00
|
|
|
set -euox pipefail
|
2023-03-28 23:11:39 +00:00
|
|
|
|
|
|
|
main () {
|
|
|
|
for crate in "internals" "hashes" "bitcoin"; do
|
|
|
|
if release_changes $crate; then
|
|
|
|
echo "$crate has changes implying this is a release PR, checking if we can publish ..."
|
2023-04-10 20:15:25 +00:00
|
|
|
|
2023-12-05 04:03:38 +00:00
|
|
|
# Check if there is any mention of TBD which means the
|
2023-04-10 20:15:25 +00:00
|
|
|
# next version number should be filled in.
|
2023-12-01 02:26:12 +00:00
|
|
|
if grep -qr "since = \"TBD" ./$crate; then
|
2023-04-10 20:15:25 +00:00
|
|
|
echo Version number needs to be filled in following places:
|
2023-12-01 02:26:12 +00:00
|
|
|
grep -r "since = \"TBD" ./$crate
|
2023-04-10 20:15:25 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Then try to dry-run cargo publish
|
2023-03-28 23:11:39 +00:00
|
|
|
publish_dry_run $crate
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Returns 0 if crate ($1) contains changes since tip of master that imply this patch set is done in
|
|
|
|
# preparation for releasing the crate.
|
|
|
|
release_changes() {
|
|
|
|
local crate=$1
|
|
|
|
git log --patch --reverse master.. -- $crate/Cargo.toml | grep version
|
|
|
|
}
|
|
|
|
|
|
|
|
# Do a dry run publish to crates.io using the correct package name for crate ($1).
|
|
|
|
# We use `set -e` so this will fail the script if the dry-run fails.
|
|
|
|
publish_dry_run() {
|
|
|
|
local crate=$1
|
|
|
|
if [ "$crate" == "hashes" ]; then
|
|
|
|
cargo publish -p "bitcoin_hashes" --dry-run
|
|
|
|
elif [ "$crate" == "internals" ]; then
|
2023-05-26 19:45:25 +00:00
|
|
|
cargo publish -p "bitcoin-internals" --dry-run
|
2023-03-28 23:11:39 +00:00
|
|
|
elif [ "$crate" == "bitcoin" ]; then
|
|
|
|
cargo publish -p "bitcoin" --dry-run
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Main script.
|
|
|
|
#
|
|
|
|
main $@
|