Skip to content

Commit

Permalink
Allow spec_version increment skipping during version-bump execution (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
sameh-farouk authored Jun 5, 2024
1 parent 4bb2e52 commit 077a523
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
26 changes: 18 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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; \
Expand All @@ -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
6 changes: 5 additions & 1 deletion docs/production/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 077a523

Please sign in to comment.