8000 Prepare Script to Update Changelog (#120) · CyberSys/firebase-admin-python@cec75e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit cec75e1

Browse files
authored
Prepare Script to Update Changelog (firebase#120)
* Updating change log at releases * Updated prepare script * Addressing some styling concerns
1 parent 9f3b8de commit cec75e1

File tree

1 file changed

+55
-12
lines changed

1 file changed

+55
-12
lines changed

scripts/prepare_release.sh

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ if [ -z "$1" ]; then
4444
exit 1
4545
fi
4646

47+
48+
#############################
49+
# VALIDATE VERSION NUMBER #
50+
#############################
51+
4752
VERSION="$1"
4853
if ! parseVersion "$VERSION"; then
4954
echo "[ERROR] Illegal version number provided. Version number must match semver."
5055
exit 1
5156
fi
5257

53-
CUR_VERSION=`grep "^__version__ =" ../firebase_admin/__init__.py | awk '{print $3}' | sed "s/'//g"`
58+
CUR_VERSION=$(grep "^__version__ =" ../firebase_admin/__init__.py | awk '{print $3}' | sed "s/'//g")
5459
if [ -z "$CUR_VERSION" ]; then
5560
echo "[ERROR] Failed to find the current version. Check firebase_admin/__init__.py for version declaration."
5661
exit 1
@@ -65,15 +70,10 @@ if ! isNewerVersion "$VERSION" "$CUR_VERSION"; then
6570
exit 1
6671
fi
6772

68-
CHECKED_OUT_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')"
69-
if [[ $CHECKED_OUT_BRANCH != "master" ]]; then
70-
echo "[ERROR] You are on the '${CHECKED_OUT_BRANCH}' branch. Release must be prepared from the 'master' branch."
71-
exit 1
72-
fi
73-
if [[ `git status --porcelain` ]]; then
74-
echo "[ERROR] Local changes exist in the repo. Resolve local changes before release."
75-
exit 1
76-
fi
73+
74+
#############################
75+
# VALIDATE TEST RESOURCES #
76+
#############################
7777

7878
if [[ ! -e "cert.json" ]]; then
7979
echo "[ERROR] cert.json file is required to run integration tests."
@@ -85,14 +85,57 @@ if [[ ! -e "apikey.txt" ]]; then
8585
exit 1
8686
fi
8787

88+
89+
###################
90+
# VALIDATE REPO #
91+
###################
92+
93+
# Ensure the checked out branch is master
94+
CHECKED_OUT_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')"
95+
if [[ $CHECKED_OUT_BRANCH != "master" ]]; then
96+
read -p "[WARN] You are on the '${CHECKED_OUT_BRANCH}' branch, not 'master'. Continue? (Y/n) " CONTINUE
97+
echo
98+
99+
if ! [[ $CONTINUE == "Y" ]]; then
100+
echo "[INFO] You chose not to continue."
101+
exit 1
102+
fi
103+
fi
104+
105+
# Ensure the branch does not have local changes
106+
if [[ $(git status --porcelain) ]]; then
107+
read -p "[WATN] Local changes exist in the repo. Continue? (Y/n) " CONTINUE
108+
echo
109+
110+
if ! [[ $CONTINUE == "Y" ]]; then
111+
echo "[INFO] You chose not to continue."
112+
exit 1
113+
fi
114+
fi
115+
116+
117+
##################################
118+
# UPDATE VERSION AND CHANGELOG #
119+
##################################
120+
88121
HOST=$(uname)
89-
echo "[INFO] Updating version number in firebase_admin/__init__.py"
122+
echo "[INFO] Updating __init__.py and CHANGELOG.md"
90123
if [ $HOST == "Darwin" ]; then
91124
sed -i "" -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__init__.py"
125+
sed -i "" -e "1 s/# Unreleased//" "../CHANGELOG.md"
92126
else
93-
sed --in-place -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__init__.py"
127+
sed -i -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__init__.py"
128+
sed -i -e "1 s/# Unreleased//" "../CHANGELOG.md"
94129
fi
95130

131+
echo -e "# Unreleased\n\n-\n\n# v${VERSION}" | cat - ../CHANGELOG.md > TEMP_CHANGELOG.md
132+
mv TEMP_CHANGELOG.md ../CHANGELOG.md
133+
134+
135+
##################
136+
# LAUNCH TESTS #
137+
##################
138+
96139
echo "[INFO] Running unit tests"
97140
tox
98141

0 commit comments

Comments
 (0)
0