-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathpublish.sh
163 lines (137 loc) · 4.46 KB
/
publish.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
# Copyright 2019 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Publishes a new version of the firebaseui NPM package. The release notes is
# generated from CHANGELOG.md. You need to login to npm using
# `npm login --registry https://wombat-dressing-room.appspot.com` before running
# this script. The twitter and hub credentials have to be set up.
#
# Usage:
# $ buildtools/publish.sh <major|minor|patch>
# CD to the root FirebaseUI directory, which should be the parent directory of
# buildtools/.
set -e
printusage() {
echo "publish.sh <version>"
echo "REPOSITORY_ORG and REPOSITORY_NAME should be set in the environment."
echo "e.g. REPOSITORY_ORG=user, REPOSITORY_NAME=repo"
echo ""
echo "Arguments:"
echo " version: 'patch', 'minor', or 'major'."
}
VERSION=$1
if [[ $VERSION == "" ]]; then
printusage
exit 1
elif [[ ! ($VERSION == "patch" || \
$VERSION == "minor" || \
$VERSION == "major") ]]; then
printusage
exit 1
fi
if [[ $REPOSITORY_ORG == "" ]]; then
printusage
exit 1
fi
if [[ $REPOSITORY_NAME == "" ]]; then
printusage
exit 1
fi
WDIR=$(pwd)
echo "Checking for commands..."
trap "echo 'Missing hub.'; exit 1" ERR
which hub &> /dev/null
trap - ERR
trap "echo 'Missing node.'; exit 1" ERR
which node &> /dev/null
trap - ERR
trap "echo 'Missing jq.'; exit 1" ERR
which jq &> /dev/null
trap - ERR
trap "echo 'Missing JRE.'; exit 1" ERR
which java &> /dev/null
trap - ERR
trap "echo 'Missing python2.'; exit 1" ERR
which python &> /dev/null
trap - ERR
trap "echo 'Missing Chrome.'; exit 1" ERR
which google-chrome &> /dev/null
trap - ERR
echo "Chrome version:"
google-chrome --version
echo "Checked for commands."
echo "Checking for Twitter credentials..."
trap "echo 'Missing Twitter credentials.'; exit 1" ERR
test -f "${WDIR}/buildtools/twitter.json"
trap - ERR
echo "Checked for Twitter credentials..."
echo "Checking for logged-in npm user..."
trap "echo 'Please login to npm using \`npm login --registry https://wombat-dressing-room.appspot.com\`'; exit 1" ERR
npm whoami --registry https://wombat-dressing-room.appspot.com
trap - ERR
echo "Checked for logged-in npm user."
echo "Moving to temporary directory..."
TEMPDIR=$(mktemp -d)
echo "[DEBUG] ${TEMPDIR}"
cd "${TEMPDIR}"
echo "Moved to temporary directory."
echo "Cloning repository..."
git clone "[email protected]:${REPOSITORY_ORG}/${REPOSITORY_NAME}.git"
cd "${REPOSITORY_NAME}"
echo "Cloned repository."
echo "Making sure there is a changelog..."
if [ ! -s CHANGELOG.md ]; then
echo "CHANGELOG.md is empty. Aborting."
exit 1
fi
echo "Made sure there is a changelog."
echo "Running npm ci..."
npm ci
echo "Ran npm ci."
CURRENT_VERSION=$(jq -r ".version" package.json)
echo "Making a $VERSION version..."
npm version $VERSION
NEW_VERSION=$(jq -r ".version" package.json)
echo "Made a $VERSION version."
echo "Making the release notes..."
RELEASE_NOTES_FILE=$(mktemp)
echo "[DEBUG] ${RELEASE_NOTES_FILE}"
echo "v${NEW_VERSION}" >> "${RELEASE_NOTES_FILE}"
echo "" >> "${RELEASE_NOTES_FILE}"
cat CHANGELOG.md >> "${RELEASE_NOTES_FILE}"
echo "Made the release notes."
echo "Publishing to npm..."
npm publish
echo "Published to npm."
echo "Bumping version numbers in README..."
sed -i "s/firebasejs\/ui\/${CURRENT_VERSION}/firebasejs\/ui\/${NEW_VERSION}/g" README.md
git add README.md
echo "Bumped version numbers in README."
echo "Cleaning up release notes..."
rm CHANGELOG.md
touch CHANGELOG.md
git add CHANGELOG.md
git commit -m "[firebase-release] Removed change log and reset repo after ${NEW_VERSION} release"
echo "Cleaned up release notes."
echo "Pushing to GitHub..."
git push origin master --tags
echo "Pushed to GitHub."
echo "Publishing release notes..."
hub release create --file "${RELEASE_NOTES_FILE}" "v${NEW_VERSION}"
echo "Published release notes."
echo "Making the tweet..."
npm install --no-save [email protected]
cp -v "${WDIR}/buildtools/twitter.json" "${TEMPDIR}/${REPOSITORY_NAME}/buildtools/"
node ./buildtools/tweet.js ${NEW_VERSION}
echo "Made the tweet."