Skip to content

Commit

Permalink
build: release script to update versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Feb 2, 2024
1 parent 701ba0f commit a2151d4
Showing 1 changed file with 87 additions and 0 deletions.
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

0 comments on commit a2151d4

Please sign in to comment.