Skip to content

Commit 02dff00

Browse files
authored
feat(version): add makefile version-bump (#973)
1 parent 8a36c1d commit 02dff00

File tree

2 files changed

+92
-28
lines changed

2 files changed

+92
-28
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 (spec v$$new_spec_version)"; \
34+
else \
35+
echo "Invalid version type. Please use patch, minor, or major."; \
36+
fi

docs/production/releases.md

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,74 @@
1-
## Releases
1+
# Releases
22

3-
Releases are automated by [this workflow](.github/workflows/030_create_release.yaml). When a release should be created following things need to be done:
3+
Releases are automated by [this workflow](.github/workflows/030_create_release.yaml).
4+
When a release should be created following things need to be done:
45

5-
* substrate-node
6-
* Increment spec version in the runtime [lib.rs](../../substrate-node/runtime/src/lib.rs)
7-
* Increment version in [Cargo.toml](../../substrate-node/Cargo.toml)
8-
* Increment chart `version` filed in [Chart.yaml](../../substrate-node/charts/substrate-node/Chart.yaml)
9-
* Increment chart `appVersion` filed in [Chart.yaml](../../substrate-node/charts/substrate-node/Chart.yaml)
6+
## Version bump
107

11-
* tfchainbridge
12-
* Increment chart `version` filed in [Chart.yaml](../../bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml)
13-
* Increment chart `appVersion` filed in [Chart.yaml](../../bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml)
8+
This step can be done using Makefile or manually.
149

15-
* activation-service
16-
* Increment chart `version` filed in [Chart.yaml](../../activation-service/helm/tfchainactivationservice/Chart.yaml)
17-
* Increment chart `appVersion` filed in [Chart.yaml](../../activation-service/helm/tfchainactivationservice/Chart.yaml)
18-
* Increment package `version` in [package.json](../../activation-service/package.json)
10+
### Makefile
1911

20-
* Js TFChain Client
21-
* Increment package `version` in [package.json](../../clients/tfchain-client-js/package.json)
12+
see makefile [here](../../Makefile)
2213

23-
* Scripts
24-
* Increment package `version` in [package.json](../../scripts/package.json)
14+
#### Usage
2515

26-
* Tools/fork-off-substrate
27-
* Increment package `version` in [package.json](../../tools/fork-off-substrate/package.json)
16+
```bash
17+
type=patch make version-bump # incrment the patch version
18+
type=minor make version-bump # incrment the minor version
19+
type=major make version-bump # incrment the major version
20+
```
2821

29-
* Commit the changes
22+
This function will take care also of branch and commit creation.
23+
Review the changes and push them, then follow the steps 3 and 4 below to finish the release.
3024

31-
* Create a new tag with the version number prefixed with a `v` (e.g. `v1.0.0`, `v1.0.0-rc1` for release candidates)
25+
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.
3227

33-
* Push the tag to the repository
28+
### Manually
3429

35-
* The workflow will create a release draft with the changelog and the binaries attached
30+
1 - Create a new branch for the release, increment the version for all components in the monorepo.
31+
Here is a list of the files that need to be changed to make the release:
3632

37-
A changelog will be generated based on the Pull requests merged, so having PRs with meaningful titles is important.
33+
* substrate-node
34+
* Increment spec version in the runtime [lib.rs](../../substrate-node/runtime/src/lib.rs)
35+
* Increment version in [Cargo.toml](../../substrate-node/Cargo.toml)
36+
* Increment chart `version` filed in [Chart.yaml](../../substrate-node/charts/substrate-node/Chart.yaml)
37+
* Increment chart `appVersion` filed in [Chart.yaml](../../substrate-node/charts/substrate-node/Chart.yaml)
38+
39+
* tfchainbridge
40+
* Increment chart `version` filed in [Chart.yaml](../../bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml)
41+
* Increment chart `appVersion` filed in [Chart.yaml](../../bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml)
42+
43+
* activation-service
44+
* Increment chart `version` filed in [Chart.yaml](../../activation-service/helm/tfchainactivationservice/Chart.yaml)
45+
* Increment chart `appVersion` filed in [Chart.yaml](../../activation-service/helm/tfchainactivationservice/Chart.yaml)
46+
* Increment package `version` in [package.json](../../activation-service/package.json)
47+
48+
* Js TFChain Client
49+
* Increment package `version` in [package.json](../../clients/tfchain-client-js/package.json)
50+
51+
* Scripts
52+
* Increment package `version` in [package.json](../../scripts/package.json)
53+
54+
* Tools/fork-off-substrate
55+
* Increment package `version` in [package.json](../../tools/fork-off-substrate/package.json)
56+
57+
2 - Commit the changes
58+
59+
3 - Create a new tag with the version number prefixed with a `v` (e.g. `v1.0.0`)
60+
61+
4 - Push the tag to the repository
62+
63+
The workflow will create a release draft with the changelog and the binaries attached
64+
65+
The generated changelog will be based on the merged Pull requests, so having PRs with meaningful titles is important.
3866

3967
## Validate a runtime
4068

4169
See [validate](../misc/validating_runtime.md) for instructions on how to validate a runtime.
4270

43-
### Upgrade runtime
71+
## Upgrade runtime
4472

45-
To upgrade the runtime for a network based on a release, download the runtime attached to the release (tfchain\_runtime.compact.compressed.wasm)
46-
and upload it to the network using a council proposal. The proposal should be a `set_code` proposal with the runtime as the code and majority of the council should vote in favor of the proposal.
73+
To upgrade the runtime for a network based on a release, download the runtime attached to the release (tfchain\_runtime.compact.compressed.wasm) and upload it to the network using a council proposal.
74+
The proposal should be a `set_code` proposal with the runtime as the code and majority of the council should vote in favor of the proposal.

0 commit comments

Comments
 (0)