xref: /tonic/prepare-release.sh (revision 8ee85fc4)
1#!/bin/bash
2
3# Script which automates modifying source version fields, and creating a release
4# commit and tag. The commit and tag are not automatically pushed, nor are the
5# crates published (see publish-release.sh).
6
7set -ex
8
9if [ "$#" -ne 1 ]
10then
11  echo "Usage: $0 <version>"
12  exit 1
13fi
14
15DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
16VERSION="$1"
17MINOR="$( echo ${VERSION} | cut -d\. -f1-2 )"
18
19VERSION_MATCHER="([a-z0-9\\.-]+)"
20TONIC_CRATE_MATCHER="(tonic|tonic-[a-z]+)"
21
22# Update the README.md.
23sed -i -E "s/${TONIC_CRATE_MATCHER} = \"${VERSION_MATCHER}\"/\1 = \"${MINOR}\"/" "$DIR/examples/helloworld-tutorial.md"
24sed -i -E "s/${TONIC_CRATE_MATCHER} = \"${VERSION_MATCHER}\"/\1 = \"${MINOR}\"/" "$DIR/examples/routeguide-tutorial.md"
25
26CRATES=( \
27  "tonic" \
28  "tonic-build" \
29  "tonic-types" \
30  "tonic-reflection" \
31  "tonic-health" \
32  "tonic-web" \
33)
34
35for CRATE in "${CRATES[@]}"; do
36  # Update documentation url in Cargo.toml
37  sed -i -E "s~documentation = \"https://docs\.rs/$CRATE/$VERSION_MATCHER\"~documentation = \"https://docs.rs/${CRATE}/${VERSION}\"~" \
38    "$DIR/$CRATE/Cargo.toml"
39
40  # Update Cargo.toml version fields.
41  sed -i -E "s/^version = \"${VERSION_MATCHER}\"$/version = \"${VERSION}\"/" \
42    "$DIR/$CRATE/Cargo.toml"
43done
44