Skip to content

Commit 7f86edb

Browse files
committed
add makefile version-bump
1 parent 9f93646 commit 7f86edb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.PHONY: version-bump
2+
3+
# usage: > type=patch make version-bump
4+
# usage: > type=minor make version-bump
5+
# usage: > type=major make version-bump
6+
version-bump:
7+
set -e; \
8+
if [ "$(type)" = "patch" ] || [ "$(type)" = "minor" ] || [ "$(type)" = "major" ]; then \
9+
default_branch=$$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'); \
10+
git checkout $$default_branch; \
11+
git pull origin $$default_branch; \
12+
new_version=$$(npx semver -i $(type) $$(jq -r .version clients/tfchain-client-js/package.json)); \
13+
branch_name="$$default_branch-bump-version-to-$$new_version"; \
14+
git checkout -b $$branch_name; \
15+
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; \
20+
jq ".version = \"$$new_version\"" activation-service/package.json > temp.json && mv temp.json activation-service/package.json; \
21+
jq ".version = \"$$new_version\"" clients/tfchain-client-js/package.json > temp.json && mv temp.json clients/tfchain-client-js/package.json; \
22+
jq ".version = \"$$new_version\"" scripts/package.json > temp.json && mv temp.json scripts/package.json; \
23+
jq ".version = \"$$new_version\"" tools/fork-off-substrate/package.json > temp.json && mv temp.json tools/fork-off-substrate/package.json; \
24+
sed -i "s/^version = .*/version = \"$$new_version\"/" substrate-node/Cargo.toml; \
25+
sed -i "s/^version: .*/version: $$new_version/" substrate-node/charts/substrate-node/Chart.yaml; \
26+
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" substrate-node/charts/substrate-node/Chart.yaml; \
27+
sed -i "s/^version: .*/version: $$new_version/" bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml; \
28+
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml; \
29+
sed -i "s/^version: .*/version: $$new_version/" activation-service/helm/tfchainactivationservice/Chart.yaml; \
30+
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" activation-service/helm/tfchainactivationservice/Chart.yaml; \
31+
cd substrate-node && cargo metadata -q 1> /dev/null && cd ..; \
32+
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"; \
34+
else \
35+
echo "Invalid version type. Please use patch, minor, or major."; \
36+
fi

0 commit comments

Comments
 (0)