Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: release script to update versions #48

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#! /bin/bash

PLATFORM_DIR="$(realpath "$(dirname $0)/../../platform")"

function help() {
cat <<EOF
This script is used to release a new version of the project.
It will do the following:
- update the version in the Cargo.toml files
- if $PLATFORM_DIR exists, it will update the references to tenderdash-abci / tenderdash-proto in the Cargo.toml files
to use the new version

Usage:
./scripts/release.sh [--help|-h] [-t|--tenderdash] <tenderdash_version> [-a|--abci] <library_version>

Arguments:
<tenderdash_version> - the version of Tenderdash to use
<library_version> - the version of this library (rs-tenderdash-abci)

Examples:

./scripts/release.sh -t 0.14.0-dev.2 -a 0.14.0-dev.6
./scripts/release.sh -t 0.14.5 -a 0.14.12


EOF
}

# Parse arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h | --help)
help
exit 0
;;
-t | --tenderdash)
shift
if [ -z "$1" ]; then
echo "Please specify the version of Tenderdash."
exit 1
fi
td_version=$1
shift
;;
-a | --abci)
shift
if [ -z "$1" ]; then
echo "Please specify the version of the library."
exit 1
fi
rs_tenderdash_abci_version=$1
shift
;;
*)
break
;;
esac
done

# Check if the versions are passed.
if [ -z "$td_version" ]; then
echo "Please specify the version of Tenderdash."
exit 1
fi

if [ -z "$rs_tenderdash_abci_version" ]; then
echo "Please specify the version of the library."
exit 1
fi

set -ex
# Update the version in the Cargo.toml files.
sed -i "s/^version = .*/version = \"$rs_tenderdash_abci_version\"/" ./*/Cargo.toml
# sed -i "s/^\s*const DEFAULT_VERSION.*;/const DEFAULT_VERSION: &str = \"$td_version\";/g" ./proto/build.rs
sed -i "s/^\s*const DEFAULT_VERSION: &str = \".*\";/const DEFAULT_VERSION: \&str = \"$td_version\";/" ./proto/build.rs
cargo fmt -- ./proto/build.rs 2>/dev/null

if [ -d "$PLATFORM_DIR" ]; then
rs_tenderdash="git = \"https:\/\/github.com\/dashpay\/rs-tenderdash-abci\", version = \"$rs_tenderdash_abci_version\" "
echo "INFO: Updating references to tenderdash-abci / tenderdash-proto in $PLATFORM_DIR"

sed -i "s/^tenderdash-abci = { git = .* }/tenderdash-abci = { $rs_tenderdash }/" ${PLATFORM_DIR}/packages/*/Cargo.toml
sed -i "s/^tenderdash-proto = { git = .* }/tenderdash-proto = { $rs_tenderdash }/" ${PLATFORM_DIR}/packages/*/Cargo.toml
else
echo WARN: Dash Platform not found in $PLATFORM_DIR, skipping
fi
Loading