Debian Codegraph @

third_party/rust/prost/prepare-release.sh

raw
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
7 set -ex
8
9 if [ "$#" -ne 1 ]
10 then
11 echo "Usage: $0 <version>"
12 exit 1
13 fi
14
15 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
16 VERSION="$1"
17 MINOR="$( echo ${VERSION} | cut -d\. -f1-2 )"
18
19 VERSION_MATCHER="([a-z0-9\\.-]+)"
20 PROST_CRATE_MATCHER="(prost|prost-[a-z]+)"
21
22 # Update the README.md.
23 sed -i -E "s/${PROST_CRATE_MATCHER} = \"${VERSION_MATCHER}\"/\1 = \"${MINOR}\"/" "$DIR/README.md"
24
25 # Update html_root_url attributes.
26 sed -i -E "s~html_root_url = \"https://docs\.rs/${PROST_CRATE_MATCHER}/$VERSION_MATCHER\"~html_root_url = \"https://docs.rs/\1/${VERSION}\"~" \
27 "$DIR/src/lib.rs" \
28 "$DIR/prost-derive/src/lib.rs" \
29 "$DIR/prost-build/src/lib.rs" \
30 "$DIR/prost-types/src/lib.rs"
31
32 # Update Cargo.toml version fields.
33 sed -i -E "s/^version = \"${VERSION_MATCHER}\"$/version = \"${VERSION}\"/" \
34 "$DIR/Cargo.toml" \
35 "$DIR/prost-derive/Cargo.toml" \
36 "$DIR/prost-build/Cargo.toml" \
37 "$DIR/prost-types/Cargo.toml"
38
39 # Update Cargo.toml dependency versions.
40 sed -i -E "s/^${PROST_CRATE_MATCHER} = \{ version = \"${VERSION_MATCHER}\"/\1 = { version = \"${VERSION}\"/" \
41 "$DIR/Cargo.toml" \
42 "$DIR/prost-derive/Cargo.toml" \
43 "$DIR/prost-build/Cargo.toml" \
44 "$DIR/prost-types/Cargo.toml"
45
46 git commit -a -m "release ${VERSION}"
47 git tag -a "v${VERSION}" -m "release ${VERSION}"