-
Notifications
You must be signed in to change notification settings - Fork 127
/
release.sh
executable file
·99 lines (79 loc) · 2.32 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
set -e
TOML_FILES="\
replibyte/Cargo.toml \
subset/Cargo.toml \
dump-parser/Cargo.toml
"
old=$1
new=$2
if [ -z "${old}" ] || [ -z "${new}" ]
then
echo "please run: $0 <old version> <new version>"
exit 1
fi
if [ "$(git status --porcelain=v1 2>/dev/null | wc -l)" -ne 0 ]
then
git status
echo "There are unsaved changes in the repository, press CTRL-C to abort now or return to continue."
read -r answer
fi
echo -n "Release process starting from '${old}' -> '${new}', do you want to continue? [y/N] "
read -r answer
case "${answer}" in
Y*|y*)
;;
*)
echo "Aborting"
exit 0
;;
esac;
echo "==> ${answer}"
echo -n "Updating TOML files:"
for toml in ${TOML_FILES}
do
echo -n " ${toml}"
sed -e "s/^version = \"${old}\"$/version = \"${new}\"/" -i.release "${toml}"
done
echo "."
echo "Please review the following changes. (return to continue)"
read -r answer
git diff
echo "Do you want to Continue or Rollback? [c/R]"
read -r answer
case "${answer}" in
C*|c*)
git checkout -b "release-v${new}"
git commit -sa -m "Release v${new}"
git push --set-upstream origin "release-v${new}"
;;
*)
git checkout .
exit
;;
esac;
echo "Please open the following pull request we'll wait here continue when it is merged."
echo
echo " >> https://github.com/qovery/replibyte/pull/new/release-v${new} <<"
echo
echo "Once you continue we'll generate and push the release tag with the latest 'main'"
echo
echo "WARNING: Review and wait until the pull request is merged before continuing to create the release"
read -r answer
echo "Generating release tag v${new}"
git checkout main
git pull
# The version is correctly updated in the replibyte crate cargo.toml (aka the PR is merged)
if grep -q "version = \"${new}\"" ${TOML_FILES[0]}; then
git tag -a -m"Release v${new}" "v${new}"
git push --tags
echo "Congrats release v${new} is done!"
else
echo
echo "It seems the version is not updated, are you sure you have merged the pull request as stated before?"
echo "If that's not the case, you're invited to run again the release script and wait for the PR is merged before continuing."
echo
echo "Rollback changes"
git branch -d "release-v${new}"
git push origin --delete "release-v${new}"
fi