Skip to content

Commit

Permalink
Port over the more optimized release script from tendermint-rs (infor…
Browse files Browse the repository at this point in the history
  • Loading branch information
romac authored Oct 28, 2021
1 parent 69e3c4c commit 65baa48
Showing 1 changed file with 10 additions and 43 deletions.
53 changes: 10 additions & 43 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
#!/bin/bash

# release.sh will hopefully allow us to publish all of the necessary crates in
# this repo in the right order, along with a few checks and balances to try to
# avoid mistakes. It is assumed that only one person will be releasing all
# crates at the same time.
#
# For each crate, it will:
# 1. List all files in the package with `cargo package --list`
# 2. Prompt the user as to whether to publish or not
# 3. Publish the package with `cargo publish`
# 4. Wait for the crate to be published before moving on to the next crate
# this repo in the right order. It is assumed that only one person will be
# releasing all crates at the same time.
#
# It has a default set of crates it will publish, which can be overridden by
# way of command line arguments:
#
# # Release all packages, prompting for each package as to whether to publish
# ./release.sh
# ./scripts/release.sh
#
# # Just release the ibc-proto and ibc crates, but nothing else
# ./release.sh ibc-proto ibc
#
# Once it publishes a crate, it will create a file at
# /tmp/ibc-rs-release/${TODAY}/${CRATE}, where ${TODAY} is today's date
# and ${CRATE} is the name of the crate that was successfully published.
#
# Prior to publishing a crate, it checks whether this file is present before
# attempting to publish it. If it's present, it will ask if you really want to
# publish it again. Of course, this is pretty dumb, and doesn't cater for
# instances where multiple people could publish the crates on the same day, and
# instances where someone reboots their machine or wipes their /tmp folder
# between runs.
# ./scripts/release.sh ibc-proto ibc

set -e

Expand Down Expand Up @@ -59,29 +41,25 @@ publish() {
echo ""
}

list_package_files() {
cargo package --list --manifest-path "$(get_manifest_path "${1}")"
}

wait_until_available() {
echo "Waiting for crate ${1} to become available via crates.io..."
for retry in {1..5}; do
sleep 5
ONLINE_DATE="$(check_version_online "${1}" "${2}")"
if [ -n "${ONLINE_DATE}" ]; then
echo "Crate ${crate} is now available online"
echo "Waiting 20 more seconds to be sure it's available..."
sleep 20
break
else
if [ "${retry}" == 5 ]; then
echo "ERROR: Crate should have become available by now"
exit 1
else
echo "Not available just yet. Waiting a few seconds..."
sleep 10
fi
fi
done
echo "Waiting an additional 10 seconds for crate to propagate through CDN..."
sleep 10
}

echo "Attempting to publish crate(s): ${CRATES}"
Expand All @@ -91,21 +69,10 @@ for crate in ${CRATES}; do
ONLINE_DATE="$(check_version_online "${crate}" "${VERSION}")"
echo "${crate} version number: ${VERSION}"
if [ -n "${ONLINE_DATE}" ]; then
echo "${crate} ${VERSION} has already been published at ${ONLINE_DATE}."
read -rp "Do you want to publish again? (type YES to publish, anything else to skip) " answer
case $answer in
YES ) ;;
* ) echo "Skipping"; continue;;
esac
echo "${crate} ${VERSION} has already been published at ${ONLINE_DATE}, skipping"
continue
fi

list_package_files "${crate}"
echo ""
read -rp "Are you sure you want to publish crate \"${crate}\"? (type YES to publish, anything else to exit) " answer
case $answer in
YES ) publish "${crate}";;
* ) echo "Terminating"; exit;;
esac

publish "${crate}"
wait_until_available "${crate}" "${VERSION}"
done

0 comments on commit 65baa48

Please sign in to comment.