Skip to content

Commit 468de2d

Browse files
authored
Merge pull request #2355 from input-output-hk/dlachaume/enhance-versions-bump-script
Chore: enhance versions bump script
2 parents 595cbe5 + 8c241bc commit 468de2d

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

docs/devbook/bump-versions/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cargo install cargo-get
2424
Just run the script without argument, by default no changes are made to the project.
2525

2626
```shell
27-
. ./docs/devbook/bump-versions/bump_versions.sh
27+
./docs/devbook/bump-versions/bump_versions.sh
2828
```
2929

3030
### Run
@@ -39,13 +39,13 @@ Run the script with the `--run` argument to bump the crates, js packages, and op
3939
The script will output a preformatted commit message that can be used to create a commit when it completes.
4040

4141
```shell
42-
. ./docs/devbook/bump-versions/bump_versions.sh --run
42+
./docs/devbook/bump-versions/bump_versions.sh --run
4343
```
4444

4545
If you want the script to do the commit for you, add the `--commit` argument.
4646

4747
```shell
48-
. ./docs/devbook/bump-versions/bump_versions.sh --run --commit
48+
./docs/devbook/bump-versions/bump_versions.sh --run --commit
4949
```
5050

5151
> [!NOTE]

docs/devbook/bump-versions/bump_versions.sh

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ readonly OPEN_API_FILE=openapi.yaml
3939
declare OPEN_API_UPDATE=""
4040
declare OPEN_API_UPDATE_MESSAGE=""
4141

42+
readonly INFRA_VERSION_FILE=mithril-infra/assets/infra.version
43+
declare INFRA_UPDATE=""
44+
declare INFRA_UPDATE_MESSAGE=""
45+
46+
readonly DEVNET_VERSION_FILE=mithril-test-lab/mithril-devnet/VERSION
47+
declare DEVNET_UPDATE=""
48+
declare DEVNET_UPDATE_MESSAGE=""
49+
50+
readonly BENCHMARK_VERSION_FILE=mithril-test-lab/benchmark/aggregator-prover/VERSION
51+
declare BENCHMARK_UPDATE=""
52+
declare BENCHMARK_UPDATE_MESSAGE=""
53+
4254
update_crate_versions() {
4355
# NOTE
4456
# `cargo get workspace.members` display the list of path to crates in the workspace.
@@ -141,6 +153,28 @@ update_openapi_version() {
141153
OPEN_API_UPDATE_MESSAGE=" and \`$OPEN_API_FILE\` version"
142154
}
143155

156+
update_plain_version_file() {
157+
local -r dry_run=$1
158+
local -r version_file=$2
159+
local -r var_name_prefix=$3
160+
161+
local -r version_line=$(head -n 1 "$version_file")
162+
local -r patch_number=$(echo "$version_line" | cut -d . -f 3)
163+
local -r next_patch_number=$((patch_number + 1))
164+
local -r new_version=$(echo "$version_line" | cut -d . -f 1-2).$next_patch_number
165+
166+
echo -e " ${GREEN}Upgrading${RESET} $version_file from ${version_line} to ${new_version}"
167+
if [ true = "$dry_run" ]
168+
then
169+
echo -e "${ORANGE}warning${RESET}: aborting $version_file update due to dry run"
170+
else
171+
echo -e "$new_version\n" > "$version_file"
172+
fi
173+
174+
eval "${var_name_prefix}_UPDATE=\"\n* $version_file from \\\`${version_line}\\\` to \\\`${new_version}\\\`\""
175+
eval "${var_name_prefix}_UPDATE_MESSAGE=\" and \\\`$version_file\\\` version\""
176+
}
177+
144178
################
145179
check_requirements
146180

@@ -169,6 +203,22 @@ then
169203
update_openapi_version $DRY_RUN
170204
fi
171205

206+
if [ "$(echo "${FILES_MODIFY[@]}" | grep -c "^mithril-infra/.*\.tf$")" -gt 0 ]
207+
then
208+
update_plain_version_file $DRY_RUN "$INFRA_VERSION_FILE" "INFRA"
209+
fi
210+
211+
if [ "$(echo "${FILES_MODIFY[@]}" | grep -c "^mithril-test-lab/mithril-devnet/.*\.sh$")" -gt 0 ]
212+
then
213+
update_plain_version_file $DRY_RUN "$DEVNET_VERSION_FILE" "DEVNET"
214+
fi
215+
216+
if [ "$(echo "${FILES_MODIFY[@]}" | grep -c "^mithril-test-lab/benchmark/aggregator-prover/.*\.sh$")" -gt 0 ]
217+
then
218+
update_plain_version_file $DRY_RUN "$BENCHMARK_VERSION_FILE" "BENCHMARK"
219+
fi
220+
221+
172222
if [ true = $DRY_RUN ]
173223
then
174224
echo -e "${ORANGE}warning${RESET}: script is run in dry mode. To apply the changes, run ${GREEN}$0 --run${RESET}"
@@ -204,14 +254,15 @@ else
204254
UPDATED_PACKAGE_JSONS="\n${UPDATED_PACKAGE_JSONS}"
205255
fi
206256

207-
COMMIT_MESSAGE=$(echo -e "chore: upgrade crate versions${OPEN_API_UPDATE_MESSAGE}\n${UPDATED_CRATES}${UPDATED_PACKAGE_JSONS}${OPEN_API_UPDATE}")
257+
COMMIT_MESSAGE=$(echo -e "chore: upgrade crate versions${OPEN_API_UPDATE_MESSAGE}${INFRA_UPDATE_MESSAGE}${DEVNET_UPDATE_MESSAGE}${BENCHMARK_UPDATE_MESSAGE}\n${UPDATED_CRATES}${UPDATED_PACKAGE_JSONS}${OPEN_API_UPDATE}${INFRA_UPDATE}${DEVNET_UPDATE}${BENCHMARK_UPDATE}")
208258

209259
echo -e "$COMMIT_MESSAGE"
210260

211261
if [ true = $COMMIT ]
212262
then
213-
git add --update $OPEN_API_FILE Cargo.lock ./*/Cargo.toml ./internal/*/Cargo.toml ./mithril-test-lab/*/Cargo.toml
263+
git add --update $OPEN_API_FILE Cargo.lock ./*/Cargo.toml ./internal/*/Cargo.toml ./mithril-test-lab/*/Cargo.toml examples/*/Cargo.toml
214264
git add --update ./*/package.json ./*/package-lock.json mithril-client-wasm/ci-test/package-lock.json examples/*/package.json examples/*/package-lock.json
265+
git add --update $INFRA_VERSION_FILE $DEVNET_VERSION_FILE $BENCHMARK_VERSION_FILE
215266
git commit -m "$COMMIT_MESSAGE"
216267
fi
217268
fi

docs/devbook/upgrade-repository-dependencies/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cargo install cargo-edit cargo-audit
1717
To start the update, execute the command below from the root of the repository:
1818

1919
```
20-
. ./docs/devbook/upgrade-repository-dependencies/upgrade_dependencies.sh
20+
./docs/devbook/upgrade-repository-dependencies/upgrade_dependencies.sh
2121
```
2222

2323
By default, Rust dependencies are updated to the latest version. If you want to only update to the latest compatible versions, add the `--incompatible` option to the command.

0 commit comments

Comments
 (0)