1#!/bin/bash 2 3set -o errexit 4set -o pipefail 5set -o nounset 6 7if ! [[ $# -eq 1 && $1 =~ ^[0-9](\.[0-9][0-9]*){2}$ ]]; then 8 (>&2 echo "Usage: ./publish-crate.sh [THRIFT_RELEASE_VERSION] ") 9 (>&2 echo " THRIFT_RELEASE_VERSION is in semantic versioning format, i.e. #.##.##") 10 exit 1 11fi 12 13THRIFT_RELEASE_VERSION=${1:-} 14 15echo "Updating Cargo.toml to ${THRIFT_RELEASE_VERSION}" 16sed -i.old -e "s/^version = .*$/version = \"${THRIFT_RELEASE_VERSION}\"/g" Cargo.toml 17rm Cargo.toml.old 18 19echo "Committing updated Cargo.toml" 20git add Cargo.toml 21git commit -m "Update thrift crate version to ${THRIFT_RELEASE_VERSION}" -m "Client: rs" 22 23echo "Packaging and releasing rust thrift crate with version ${THRIFT_RELEASE_VERSION}" 24cargo clean 25cargo package 26cargo publish 27