2
2
set -e
3
3
4
4
printusage () {
5
- echo " publish.sh <version>"
5
+ echo " publish.sh <version> [branch] "
6
6
echo " REPOSITORY_ORG and REPOSITORY_NAME should be set in the environment."
7
7
echo " e.g. REPOSITORY_ORG=user, REPOSITORY_NAME=repo"
8
8
echo " "
9
9
echo " Arguments:"
10
- echo " version: 'patch', 'minor', 'major', or 'artifactsOnly'"
10
+ echo " version: 'patch', 'minor', 'major', 'artifactsOnly', or 'preview'"
11
+ echo " branch: required if version is 'preview'"
11
12
}
12
13
13
14
VERSION=$1
15
+ BRANCH=$2
14
16
if [[ $VERSION == " " ]]; then
15
17
printusage
16
18
exit 1
17
19
elif [[ $VERSION == " artifactsOnly" ]]; then
18
20
echo " Skipping npm package publish since VERSION is artifactsOnly."
19
21
exit 0
22
+ elif [[ $VERSION == " preview" ]]; then
23
+ if [[ $BRANCH == " " ]]; then
24
+ printusage
25
+ exit 1
26
+ fi
20
27
elif [[ ! ($VERSION == " patch" || $VERSION == " minor" || $VERSION == " major" ) ]]; then
21
28
printusage
22
29
exit 1
@@ -61,6 +68,11 @@ echo "Moved to temporary directory."
61
68
echo " Cloning repository..."
62
69
git clone
" [email protected] :${REPOSITORY_ORG} /${REPOSITORY_NAME} .git"
63
70
cd " ${REPOSITORY_NAME} "
71
+ if [[ $VERSION == " preview" ]]; then
72
+ echo " Checking out branch $BRANCH ..."
73
+ git checkout " $BRANCH "
74
+ echo " Checked out branch $BRANCH ."
75
+ fi
64
76
echo " Cloned repository."
65
77
66
78
echo " Making sure there is a changelog..."
@@ -78,10 +90,18 @@ echo "Running tests..."
78
90
npm test
79
91
echo " Ran tests."
80
92
81
- echo " Making a $VERSION version..."
82
- npm version $VERSION
83
- NEW_VERSION=$( jq -r " .version" package.json)
84
- echo " Made a $VERSION version."
93
+ if [[ $VERSION == " preview" ]]; then
94
+ echo " Making a preview version..."
95
+ sanitized_branch=$( echo " $BRANCH " | sed ' s/[^a-zA-Z0-9]/-/g' )
96
+ npm version prerelease --preid=${sanitized_branch}
97
+ NEW_VERSION=$( jq -r " .version" package.json)
98
+ echo " Made a preview version."
99
+ else
100
+ echo " Making a $VERSION version..."
101
+ npm version $VERSION
102
+ NEW_VERSION=$( jq -r " .version" package.json)
103
+ echo " Made a $VERSION version."
104
+ fi
85
105
86
106
echo " Making the release notes..."
87
107
RELEASE_NOTES_FILE=$( mktemp)
@@ -95,20 +115,22 @@ echo "Publishing to npm..."
95
115
npx
[email protected] --before-script ./scripts/clean-shrinkwrap.sh
96
116
echo " Published to npm."
97
117
98
- echo " Updating package-lock.json for Docker image..."
99
- npm --prefix ./scripts/publish/firebase-docker-image install
100
- echo " Updated package-lock.json for Docker image."
118
+ if [[ $VERSION != " preview" ]]; then
119
+ echo " Updating package-lock.json for Docker image..."
120
+ npm --prefix ./scripts/publish/firebase-docker-image install
121
+ echo " Updated package-lock.json for Docker image."
101
122
102
- echo " Cleaning up release notes..."
103
- rm CHANGELOG.md
104
- touch CHANGELOG.md
105
- git commit -m " [firebase-release] Removed change log and reset repo after ${NEW_VERSION} release" CHANGELOG.md scripts/publish/firebase-docker-image/package-lock.json
106
- echo " Cleaned up release notes."
123
+ echo " Cleaning up release notes..."
124
+ rm CHANGELOG.md
125
+ touch CHANGELOG.md
126
+ git commit -m " [firebase-release] Removed change log and reset repo after ${NEW_VERSION} release" CHANGELOG.md scripts/publish/firebase-docker-image/package-lock.json
127
+ echo " Cleaned up release notes."
107
128
108
- echo " Pushing to GitHub..."
109
- git push origin master --tags
110
- echo " Pushed to GitHub."
129
+ echo " Pushing to GitHub..."
130
+ git push origin master --tags
131
+ echo " Pushed to GitHub."
111
132
112
- echo " Publishing release notes..."
113
- hub release create --file " ${RELEASE_NOTES_FILE} " " v${NEW_VERSION} "
114
- echo " Published release notes."
133
+ echo " Publishing release notes..."
134
+ hub release create --file " ${RELEASE_NOTES_FILE} " " v${NEW_VERSION} "
135
+ echo " Published release notes."
136
+ fi
0 commit comments