#!/usr/bin/env bash set -e usage() { cat </dev/null; then badTomls+=("$Cargo_toml") fi done if [[ ${#badTomls[@]} -ne 0 ]]; then echo "Error: Incorrect crate version specified in: ${badTomls[*]}" exit 1 fi exit 0 ;; -*) if [[ $1 =~ ^-[A-Za-z0-9]*$ ]]; then SPECIAL="$1" else echo "Error: Unsupported characters found in $1" exit 1 fi ;; *) echo "Error: unknown argument: $1" usage ;; esac # Version bumps should occur in their own commit. Disallow bumping version # in dirty working trees. Gate after arg parsing to prevent breaking the # `check` subcommand. ( set +e if ! git diff --exit-code; then echo -e "\nError: Working tree is dirty. Commit or discard changes before bumping version." 1>&2 exit 1 fi ) newVersion="$MAJOR.$MINOR.$PATCH$SPECIAL" # Update all the Cargo.toml files for Cargo_toml in "${Cargo_tomls[@]}"; do # Set new crate version ( set -x sed -i "$Cargo_toml" -e "0,/^version =/{s/^version = \"[^\"]*\"$/version = \"$newVersion\"/}" ) # Fix up the version references to other internal crates for crate in "${crates[@]}"; do ( set -x sed -i "$Cargo_toml" -e " s/^$crate = { *path *= *\"\([^\"]*\)\" *, *version *= *\"[^\"]*\"\(.*\)} *\$/$crate = \{ path = \"\1\", version = \"=$newVersion\"\2\}/ " ) done done # Update cargo lock files scripts/cargo-for-all-lock-files.sh tree >/dev/null echo "$currentVersion -> $newVersion" exit 0