Skip to content

Commit 077a523

Browse files
authored
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
1 parent 4bb2e52 commit 077a523

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

Makefile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
.PHONY: version-bump
22

3-
# usage: > type=patch make version-bump
4-
# usage: > type=minor make version-bump
5-
# usage: > type=major make version-bump
3+
# * Usage Examples:*
4+
# type=patch make version-bump
5+
# type=minor make version-bump
6+
# type=major make version-bump
7+
# ** skip increment spec_version in substrate-node/runtime/src/lib.rs **
8+
# type=patch retain_spec_version=1 make version-bump
69
version-bump:
710
set -e; \
811
if [ "$(type)" = "patch" ] || [ "$(type)" = "minor" ] || [ "$(type)" = "major" ]; then \
@@ -13,10 +16,13 @@ version-bump:
1316
branch_name="$$default_branch-bump-version-to-$$new_version"; \
1417
git checkout -b $$branch_name; \
1518
current_spec_version=$$(sed -n -e 's/^.*spec_version: \([0-9]\+\),$$/\1/p' substrate-node/runtime/src/lib.rs); \
16-
echo "Current spec_version: $$current_spec_version"; \
17-
new_spec_version=$$((current_spec_version + 1)); \
18-
echo "New spec_version: $$new_spec_version"; \
19-
sed -i "s/spec_version: $$current_spec_version,/spec_version: $$new_spec_version,/" substrate-node/runtime/src/lib.rs; \
19+
if [ -z "$${retain_spec_version}" ]; then \
20+
current_spec_version=$$(sed -n -e 's/^.*spec_version: \([0-9]\+\),$$/\1/p' substrate-node/runtime/src/lib.rs); \
21+
echo "Current spec_version: $$current_spec_version"; \
22+
new_spec_version=$$((current_spec_version + 1)); \
23+
echo "New spec_version: $$new_spec_version"; \
24+
sed -i "s/spec_version: $$current_spec_version,/spec_version: $$new_spec_version,/" substrate-node/runtime/src/lib.rs; \
25+
fi; \
2026
jq ".version = \"$$new_version\"" activation-service/package.json > temp.json && mv temp.json activation-service/package.json; \
2127
jq ".version = \"$$new_version\"" clients/tfchain-client-js/package.json > temp.json && mv temp.json clients/tfchain-client-js/package.json; \
2228
jq ".version = \"$$new_version\"" scripts/package.json > temp.json && mv temp.json scripts/package.json; \
@@ -30,7 +36,11 @@ version-bump:
3036
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" activation-service/helm/tfchainactivationservice/Chart.yaml; \
3137
cd substrate-node && cargo metadata -q 1> /dev/null && cd ..; \
3238
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; \
33-
git commit -m "Bump version to $$new_version (spec v$$new_spec_version)"; \
39+
if [ -z "$${new_spec_version}" ]; then \
40+
git commit -m "Bump version to $$new_version"; \
41+
else \
42+
git commit -m "Bump version to $$new_version (spec v$$new_spec_version)"; \
43+
fi \
3444
else \
3545
echo "Invalid version type. Please use patch, minor, or major."; \
3646
fi

docs/production/releases.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ This function will take care also of branch and commit creation.
2323
Review the changes and push them, then follow the steps 3 and 4 below to finish the release.
2424

2525
Important: This function will also incrment the spec version in the runtime.
26-
If you already did this in another commit you need to undo spec_version changes to avoid double incrment.
26+
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.
27+
28+
```bash
29+
type=patch retain_spec_version=1 make version-bump
30+
```
2731

2832
### Manually
2933

0 commit comments

Comments
 (0)