Skip to content

Commit 8c23940

Browse files
committed
Adding scripts to prepare and build releases
1 parent 88a66d1 commit 8c23940

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed

package_release.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2018 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
17+
set -e
18+
19+
if [[ -z "${FrameworkPathOverride}" ]]; then
20+
echo "[INFO] FrameworkPathOverride not set. Using default."
21+
FrameworkPathOverride="/usr/lib/mono/4.5/"
22+
fi
23+
24+
rm -rf FirebaseAdmin/FirebaseAdmin/bin/Release
25+
dotnet pack -c Release FirebaseAdmin/FirebaseAdmin /p:OS="Windows_NT" /p:FrameworkPathOverride=${FrameworkPathOverride}

prepare_release.sh

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Copyright 2018 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
17+
function isNewerVersion {
18+
parseVersion "$1"
19+
ARG_MAJOR=$MAJOR_VERSION
20+
ARG_MINOR=$MINOR_VERSION
21+
ARG_PATCH=$PATCH_VERSION
22+
23+
parseVersion "$2"
24+
if [ "$ARG_MAJOR" -ne "$MAJOR_VERSION" ]; then
25+
if [ "$ARG_MAJOR" -lt "$MAJOR_VERSION" ]; then return 1; else return 0; fi;
26+
fi
27+
if [ "$ARG_MINOR" -ne "$MINOR_VERSION" ]; then
28+
if [ "$ARG_MINOR" -lt "$MINOR_VERSION" ]; then return 1; else return 0; fi;
29+
fi
30+
if [ "$ARG_PATCH" -ne "$PATCH_VERSION" ]; then
31+
if [ "$ARG_PATCH" -lt "$PATCH_VERSION" ]; then return 1; else return 0; fi;
32+
fi
33+
# The build numbers are equal
34+
return 1
35+
}
36+
37+
function parseVersion {
38+
if [[ ! "$1" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
39+
return 1
40+
fi
41+
MAJOR_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\1/')
42+
MINOR_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\2/')
43+
PATCH_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\3/')
44+
return 0
45+
}
46+
47+
set -e
48+
49+
if [[ -z "$1" ]]; then
50+
echo "[ERROR] No version number provided."
51+
echo "[INFO] Usage: ./prepare_release.sh <VERSION_NUMBER>"
52+
exit 1
53+
fi
54+
55+
56+
#############################
57+
# VALIDATE VERSION NUMBER #
58+
#############################
59+
60+
VERSION="$1"
61+
if ! parseVersion "$VERSION"; then
62+
echo "[ERROR] Illegal version number provided. Version number must match semver."
63+
exit 1
64+
fi
65+
66+
PROJECT_FILE="FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj"
67+
CUR_VERSION=$(grep "<Version>" ${PROJECT_FILE} | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
68+
if [ -z "$CUR_VERSION" ]; then
69+
echo "[ERROR] Failed to find the current version. Check ${PROJECT_FILE} for version declaration."
70+
exit 1
71+
fi
72+
if ! parseVersion "$CUR_VERSION"; then
73+
echo "[ERROR] Illegal current version number. Version number must match semver."
74+
exit 1
75+
fi
76+
77+
if ! isNewerVersion "$VERSION" "$CUR_VERSION"; then
78+
echo "[ERROR] Illegal version number provided. Version $VERSION <= $CUR_VERSION"
79+
exit 1
80+
fi
81+
82+
83+
#############################
84+
# VALIDATE TEST RESOURCES #
85+
#############################
86+
87+
INTEGRATION_TESTS_DIR="FirebaseAdmin/FirebaseAdmin.IntegrationTests/resources"
88+
if [[ ! -e "${INTEGRATION_TESTS_DIR}/integration_cert.json" ]]; then
89+
echo "[ERROR] integration_cert.json file is required to run integration tests."
90+
exit 1
91+
fi
92+
93+
if [[ ! -e "${INTEGRATION_TESTS_DIR}/integration_apikey.txt" ]]; then
94+
echo "[ERROR] integration_apikey.txt file is required to run integration tests."
95+
exit 1
96+
fi
97+
98+
99+
###################
100+
# VALIDATE REPO #
101+
###################
102+
103+
# Ensure the checked out branch is master
104+
CHECKED_OUT_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')"
105+
if [[ $CHECKED_OUT_BRANCH != "master" ]]; then
106+
read -p "[WARN] You are on the '${CHECKED_OUT_BRANCH}' branch, not 'master'. Continue? (Y/n) " CONTINUE
107+
echo
108+
109+
if ! [[ $CONTINUE == "Y" ]]; then
110+
echo "[INFO] You chose not to continue."
111+
exit 1
112+
fi
113+
fi
114+
115+
# Ensure the branch does not have local changes
116+
if [[ $(git status --porcelain) ]]; then
117+
read -p "[WARN] Local changes exist in the repo. Continue? (Y/n) " CONTINUE
118+
echo
119+
120+
if ! [[ $CONTINUE == "Y" ]]; then
121+
echo "[INFO] You chose not to continue."
122+
exit 1
123+
fi
124+
fi
125+
126+
127+
##################################
128+
# UPDATE VERSION AND CHANGELOG #
129+
##################################
130+
131+
HOST=$(uname)
132+
echo "[INFO] Updating FirebaseAdmin.csproj and CHANGELOG.md"
133+
sed -i -e "s/<Version>$CUR_VERSION<\/Version>/<Version>$VERSION<\/Version>/" "${PROJECT_FILE}"
134+
sed -i -e "1 s/# Unreleased//" "CHANGELOG.md"
135+
136+
137+
echo -e "# Unreleased\n\n-\n\n# v${VERSION}" | cat - CHANGELOG.md > TEMP_CHANGELOG.md
138+
mv TEMP_CHANGELOG.md CHANGELOG.md
139+
140+
141+
##################
142+
# LAUNCH TESTS #
143+
##################
144+
145+
dotnet clean FirebaseAdmin
146+
echo "[INFO] Building project"
147+
dotnet build FirebaseAdmin/FirebaseAdmin
148+
149+
echo "[INFO] Running unit tests"
150+
dotnet test FirebaseAdmin/FirebaseAdmin.Tests
151+
152+
echo "[INFO] Running integration tests"
153+
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests
154+
155+
echo "[INFO] This repo has been prepared for a release. Create a branch and commit the changes."

0 commit comments

Comments
 (0)