From 077a5234484b18d871103b87285c00ec5d331f36 Mon Sep 17 00:00:00 2001 From: Sameh Abouel-saad Date: Thu, 6 Jun 2024 01:27:28 +0300 Subject: [PATCH] Allow spec_version increment skipping during version-bump execution (#977) * build: allow spec_version increment skipping during make version-bump execution * docs: update releases doc * build: modifiy commit message if spec_version retained * build: fix typo --- Makefile | 26 ++++++++++++++++++-------- docs/production/releases.md | 6 +++++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 75518d111..cc94da7cf 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ .PHONY: version-bump -# usage: > type=patch make version-bump -# usage: > type=minor make version-bump -# usage: > type=major make version-bump +# * Usage Examples:* +# type=patch make version-bump +# type=minor make version-bump +# type=major make version-bump +# ** skip increment spec_version in substrate-node/runtime/src/lib.rs ** +# type=patch retain_spec_version=1 make version-bump version-bump: set -e; \ if [ "$(type)" = "patch" ] || [ "$(type)" = "minor" ] || [ "$(type)" = "major" ]; then \ @@ -13,10 +16,13 @@ version-bump: branch_name="$$default_branch-bump-version-to-$$new_version"; \ git checkout -b $$branch_name; \ current_spec_version=$$(sed -n -e 's/^.*spec_version: \([0-9]\+\),$$/\1/p' substrate-node/runtime/src/lib.rs); \ - echo "Current spec_version: $$current_spec_version"; \ - new_spec_version=$$((current_spec_version + 1)); \ - echo "New spec_version: $$new_spec_version"; \ - sed -i "s/spec_version: $$current_spec_version,/spec_version: $$new_spec_version,/" substrate-node/runtime/src/lib.rs; \ + if [ -z "$${retain_spec_version}" ]; then \ + current_spec_version=$$(sed -n -e 's/^.*spec_version: \([0-9]\+\),$$/\1/p' substrate-node/runtime/src/lib.rs); \ + echo "Current spec_version: $$current_spec_version"; \ + new_spec_version=$$((current_spec_version + 1)); \ + echo "New spec_version: $$new_spec_version"; \ + sed -i "s/spec_version: $$current_spec_version,/spec_version: $$new_spec_version,/" substrate-node/runtime/src/lib.rs; \ + fi; \ jq ".version = \"$$new_version\"" activation-service/package.json > temp.json && mv temp.json activation-service/package.json; \ jq ".version = \"$$new_version\"" clients/tfchain-client-js/package.json > temp.json && mv temp.json clients/tfchain-client-js/package.json; \ jq ".version = \"$$new_version\"" scripts/package.json > temp.json && mv temp.json scripts/package.json; \ @@ -30,7 +36,11 @@ version-bump: sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" activation-service/helm/tfchainactivationservice/Chart.yaml; \ cd substrate-node && cargo metadata -q 1> /dev/null && cd ..; \ git add substrate-node/Cargo.toml substrate-node/Cargo.lock substrate-node/charts/substrate-node/Chart.yaml bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml activation-service/helm/tfchainactivationservice/Chart.yaml activation-service/package.json clients/tfchain-client-js/package.json scripts/package.json tools/fork-off-substrate/package.json substrate-node/runtime/src/lib.rs; \ - git commit -m "Bump version to $$new_version (spec v$$new_spec_version)"; \ + if [ -z "$${new_spec_version}" ]; then \ + git commit -m "Bump version to $$new_version"; \ + else \ + git commit -m "Bump version to $$new_version (spec v$$new_spec_version)"; \ + fi \ else \ echo "Invalid version type. Please use patch, minor, or major."; \ fi diff --git a/docs/production/releases.md b/docs/production/releases.md index 061cb891c..2b96aed7b 100644 --- a/docs/production/releases.md +++ b/docs/production/releases.md @@ -23,7 +23,11 @@ This function will take care also of branch and commit creation. Review the changes and push them, then follow the steps 3 and 4 below to finish the release. Important: This function will also incrment the spec version in the runtime. -If you already did this in another commit you need to undo spec_version changes to avoid double incrment. +If you already did this in another commit or you don't need to do this, you can instruct the Makefile version-bump function to skip it by setting the `retain_spec_version` variable to 1 or any other value. + +```bash +type=patch retain_spec_version=1 make version-bump +``` ### Manually