Skip to content

Commit e7d56f0

Browse files
committed
Revert "chore: remove prepare-release script"
This reverts commit 17a51c0.
1 parent 3fb5cad commit e7d56f0

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"update-models": "./scripts/update-models.sh",
6969
"update-protobuf": "./scripts/update-protobuf.sh",
7070
"update-coinjoin-middleware": "yarn workspace @trezor/suite-data update-coinjoin-middleware",
71+
"prepare-release": "./scripts/prepare-release.sh",
7172
"native:android": "yarn workspace @suite-native/app android",
7273
"native:ios": "yarn workspace @suite-native/app ios",
7374
"native:prebuild": "yarn workspace @suite-native/app prebuild",

scripts/prepare-release.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
3+
# Prepare release and testing branches before Suite freeze, bump beta version, and create a pull request.
4+
# You need to have the permission to push to pretected branches in order to execute the script correctly.
5+
# For security reasons, the script can only run locally as we do not have a shared GitHub token with the necessary permissions.
6+
# If you want the script to automatically create a pull request to bump beta version, install and set up gh tool:
7+
# brew install gh
8+
# gh auth login
9+
10+
MAIN_BRANCH=develop
11+
FILEPATH=packages/suite/package.json
12+
ORIGIN='origin'
13+
14+
if ! git diff --cached --quiet; then
15+
tput setaf 1
16+
echo "There are potentially unrelated staged changes that should not be committed. Unstage them before running this script."
17+
tput sgr0
18+
exit 1
19+
fi
20+
21+
if ! git diff --quiet $FILEPATH; then
22+
tput setaf 1
23+
echo "There are potentially unrelated unstaged changes in $FILEPATH that should not be committed. Stash the changes before running this script."
24+
tput sgr0
25+
exit 1
26+
fi
27+
28+
echo Calculating versions...
29+
CURRENT_VERSION=$(grep -m1 -o '\"suiteVersion\": *\"[^\"]*\"' $FILEPATH | cut -d':' -f2- | tr -d '\" ')
30+
CURRENT_VERSION_YEAR=$(echo "$CURRENT_VERSION" | cut -d '.' -f 1)
31+
CURRENT_VERSION_MONTH=$(echo "$CURRENT_VERSION" | cut -d '.' -f 2)
32+
33+
RELEASE_MONTH="$CURRENT_VERSION_YEAR.$CURRENT_VERSION_MONTH"
34+
RELEASE_VERSION="$RELEASE_MONTH.1"
35+
TEST_UPGRADE_VERSION="$((CURRENT_VERSION_YEAR+10)).$CURRENT_VERSION_MONTH.1"
36+
TEST_DOWNGRADE_VERSION="0.$CURRENT_VERSION_YEAR.$CURRENT_VERSION_MONTH"
37+
if [ "$CURRENT_VERSION_MONTH" == 12 ]; then
38+
NEXT_VERSION_YEAR="$((CURRENT_VERSION_YEAR+1))"
39+
NEXT_VERSION_MONTH=1
40+
else
41+
NEXT_VERSION_YEAR=$CURRENT_VERSION_YEAR
42+
NEXT_VERSION_MONTH="$((CURRENT_VERSION_MONTH+1))"
43+
fi
44+
BETA_VERSION="$NEXT_VERSION_YEAR.$NEXT_VERSION_MONTH.0"
45+
46+
echo Pulling "$MAIN_BRANCH"...
47+
git pull origin $MAIN_BRANCH
48+
49+
echo Creating release branch "$RELEASE_MONTH"...
50+
git switch -c release/"$RELEASE_MONTH" $MAIN_BRANCH
51+
sed -i '' -E "s/(\"suiteVersion\": \")[^\"]*(\".*)/\1$RELEASE_VERSION\2/" $FILEPATH
52+
git add $FILEPATH
53+
git commit -m "chore(suite): bump Suite version to $RELEASE_VERSION [RELEASE ONLY]"
54+
git push --set-upstream $ORIGIN "$(git branch --show-current)"
55+
56+
echo Creating testing branch "$TEST_UPGRADE_VERSION"...
57+
git switch -c release/test-"$TEST_UPGRADE_VERSION" $MAIN_BRANCH
58+
sed -i '' -E "s/(\"suiteVersion\": \")[^\"]*(\".*$)/\1$TEST_UPGRADE_VERSION\2/" $FILEPATH
59+
git add $FILEPATH
60+
git commit -m "chore(suite): set Suite version to $TEST_UPGRADE_VERSION for testing [RELEASE ONLY]"
61+
git push --set-upstream $ORIGIN "$(git branch --show-current)"
62+
63+
echo Creating testing branch "$TEST_DOWNGRADE_VERSION"...
64+
git switch -c release/test-"$TEST_DOWNGRADE_VERSION" $MAIN_BRANCH
65+
sed -i '' -E "s/(\"suiteVersion\": \")[^\"]*(\".*$)/\1$TEST_DOWNGRADE_VERSION\2/" $FILEPATH
66+
git add $FILEPATH
67+
git commit -m "chore(suite): set Suite version to $TEST_DOWNGRADE_VERSION for testing [RELEASE ONLY]"
68+
git push --set-upstream $ORIGIN "$(git branch --show-current)"
69+
70+
echo Bumping beta version to "$BETA_VERSION"...
71+
git switch -c chore/bump-suite-version-"$BETA_VERSION" $MAIN_BRANCH
72+
sed -i '' -E "s/(\"suiteVersion\": \")[^\"]*(\".*$)/\1$BETA_VERSION\2/" $FILEPATH
73+
git add $FILEPATH
74+
git commit -m "chore(suite): bump beta version to $BETA_VERSION"
75+
git push --set-upstream $ORIGIN "$(git branch --show-current)"
76+
77+
echo Creating pull request...
78+
if ! OUTPUT=$(gh pr create --repo trezor/trezor-suite --base $MAIN_BRANCH --title "Bump beta version to $BETA_VERSION" --body "Automatically generated PR to bump beta Suite version" --label deployment --web 2>&1); then
79+
tput setaf 3
80+
echo -e "Pull request not created. Create one manually on GitHub!\n${OUTPUT}"
81+
tput sgr0
82+
fi
83+
84+
echo Switching to $MAIN_BRANCH...
85+
git switch $MAIN_BRANCH

0 commit comments

Comments
 (0)