Skip to content

Commit 98c08ed

Browse files
committed
feat(devbook): add help and auto requirement check to bump version script
1 parent 87d4523 commit 98c08ed

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

docs/devbook/bump-versions/bump_versions.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,38 @@ set +a -u -o pipefail
33

44
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
55

6-
# Check crates, js packages, and openapi changes against `origin/main` and update their version.
7-
# At the end of the script, the commit message to used is displayed.
6+
display_help() {
7+
echo "Check crates, js packages, and openapi changes against 'origin/main' and update their versions"
8+
echo
9+
echo "By default, no changes are made (dry-run mode), use '--run' to apply the changes."
10+
echo "At the end of the script, the commit message to used is displayed, use '--commit' to commit the changes."
11+
echo
12+
echo "Usage: $0 [OPTIONS]"
13+
echo
14+
echo "Options:"
15+
echo " --run: to apply the changes (default is dry-run)"
16+
echo " --commit: to commit the changes"
17+
echo
18+
echo "Prerequisites:"
19+
echo " 'cargo-get' needs to be installed ('cargo install cargo-get')."
20+
echo
21+
exit 0;
22+
}
823

9-
# Usage:
10-
# update_crate_versions.sh --run: to execute the changes (default is dry-run)
11-
# update_crate_versions.sh: to display the changes without executing them (dry-run mode)
24+
check_requirements() {
25+
cargo get --version 2> /dev/null 1> /dev/null ||
26+
error "It seems 'cargo-get' is not installed or not in the path (to install run: 'cargo install cargo-get').";
27+
}
1228

13-
# Prerequisites:
14-
# `cargo-get` needs to be installed (`cargo install cargo-get`).
29+
error() {
30+
echo "ERROR: $1";
31+
exit 1;
32+
}
1533

1634
# NOTE
1735
# `cargo get workspace.members` display the list of path to crates in the workspace.
1836
# for the `cargo set-version` command, we need the name of the module (last element of the path).
37+
1938
readonly ORANGE="\e[1;33m"
2039
readonly GREEN="\e[1;32m"
2140
readonly RESET="\e[0m"
@@ -123,11 +142,14 @@ update_openapi_version() {
123142
}
124143

125144
################
145+
check_requirements
146+
126147
declare DRY_RUN=true
127148
declare COMMIT=false
128149
readonly COMMIT_REF="HEAD"
129150
while [[ "$#" -gt 0 ]]; do
130151
case $1 in
152+
-h|--help) display_help ;;
131153
--run) DRY_RUN=false ;;
132154
--commit) COMMIT=true ;;
133155
esac

0 commit comments

Comments
 (0)