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