Skip to content

Commit 2e6774d

Browse files
committed
Release script
1 parent 5a95032 commit 2e6774d

File tree

6 files changed

+125
-9
lines changed

6 files changed

+125
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add new `geofire-common` library.

changelog.txt

Whitespace-only changes.

packages/geofire-common/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "rollup -c",
77
"coverage": "nyc report --reporter=text-lcov > ./coverage/lcov.info",
88
"lint": "tslint --project ./tslint.json 'src/**/*.ts'",
9-
"test": "nyc --reporter=html --reporter=text mocha",
9+
"test": "nyc --reporter=html --reporter=text mocha --exit",
1010
"prepare": "npm run build"
1111
},
1212
"author": "Firebase (https://firebase.google.com/)",
@@ -26,11 +26,11 @@
2626
"realtime",
2727
"geolocation"
2828
],
29-
"main": "dist/geofire/index.cjs.js",
30-
"index": "dist/geofire/index.js",
31-
"browser": "dist/geofire/geofire.min.js",
32-
"module": "dist/geofire/index.esm.js",
33-
"typings": "dist/geofire/index.d.ts",
29+
"main": "dist/geofire-common/index.cjs.js",
30+
"index": "dist/geofire-common/index.js",
31+
"browser": "dist/geofire-common/geofire-common.min.js",
32+
"module": "dist/geofire-common/index.esm.js",
33+
"typings": "dist/geofire-common/index.d.ts",
3434
"files": [
3535
"dist/**",
3636
"LICENSE",

packages/geofire-common/rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import typescript from 'rollup-plugin-typescript2';
44
import { uglify } from 'rollup-plugin-uglify';
55
import pkg from './package.json';
66

7-
const GLOBAL_NAME = 'geofire';
7+
const GLOBAL_NAME = 'geofire-common';
88

99
const plugins = [
1010
resolveModule(),
@@ -47,4 +47,4 @@ const completeBuilds = [{
4747
}
4848
];
4949

50-
export default [...completeBuilds];
50+
export default [...completeBuilds];

packages/geofire/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "rollup -c",
77
"coverage": "nyc report --reporter=text-lcov > ./coverage/lcov.info",
88
"lint": "tslint --project ./tslint.json 'src/**/*.ts'",
9-
"test": "nyc --reporter=html --reporter=text mocha",
9+
"test": "nyc --reporter=html --reporter=text mocha --exit",
1010
"prepare": "npm run build"
1111
},
1212
"author": "Firebase (https://firebase.google.com/)",

scripts/release.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/bin/bash
2+
3+
set -o nounset
4+
set -o errexit
5+
6+
print_usage() {
7+
echo "$0 <version>"
8+
echo
9+
echo "Arguments:"
10+
echo " version: version to release"
11+
exit 1
12+
}
13+
14+
exit_on_error() {
15+
echo $1
16+
exit 1
17+
}
18+
19+
if [[ $# -gt 0 ]]; then
20+
next_version="$1"
21+
else
22+
print_usage
23+
fi
24+
25+
which jq &> /dev/null || exit_on_error "Missing jq command. https://stedolan.github.io/jq/"
26+
which hub &> /dev/null || exit_on_error "Missing hub command. https://github.com/github/hub#installation"
27+
28+
current_version=$(jq -r '.version' packages/geofire/package.json)
29+
echo "Current version: ${current_version}"
30+
echo "Next version: ${next_version}"
31+
echo
32+
33+
echo "Does that look correct?"
34+
echo " <enter> to continue"
35+
read
36+
37+
echo
38+
echo "Building and testing"
39+
npm install
40+
npm run bootstrap
41+
npm run build
42+
npm run test
43+
44+
# Modify the geofire-common version
45+
tmp=$(jq ".version=\"${next_version}\"" packages/geofire-common/package.json)
46+
echo "${tmp}" > packages/geofire-common/package.json
47+
48+
# Modify the geofire version
49+
tmp=$(jq ".version=\"${next_version}\"" packages/geofire/package.json)
50+
echo "${tmp}" > packages/geofire/package.json
51+
52+
# Modify the geofire geofire-common dependency version
53+
tmp=$(jq ".dependencies[\"geofire-common\"]=\"${next_version}\"" packages/geofire/package.json)
54+
echo "${tmp}" > packages/geofire/package.json
55+
56+
# Commit the version changes
57+
git commit -am "[release] Version ${next_version}"
58+
59+
# Create git tag
60+
next_version_tag="v${next_version}"
61+
git tag "${next_version_tag}"
62+
63+
echo
64+
echo "Logging into npm via wombat-dressing-room (see http://go/npm-publish)."
65+
echo " Press <enter> to open browser, then click 'Create 24 hour token'."
66+
echo " If you can't open a browser, try logging in from a different machine:"
67+
echo " npm login --registry https://wombat-dressing-room.appspot.com"
68+
echo " And then copy/paste the resulting ~/.npmrc contents here:"
69+
echo " (this will overwrite your current ~/.npmrc)"
70+
read npmrc
71+
72+
if [[ ! $npmrc == "" ]]; then
73+
echo $npmrc > ~/.npmrc
74+
else
75+
npm login --registry https://wombat-dressing-room.appspot.com
76+
fi
77+
78+
# Publish
79+
echo
80+
echo "Publishing geofire-common@${next_version} to npm."
81+
(
82+
cd packages/geofire-common
83+
npm publish --registry https://wombat-dressing-room.appspot.com
84+
)
85+
86+
echo
87+
echo "Publishing geofire@${next_version} to npm."
88+
(
89+
cd packages/geofire
90+
npm publish --registry https://wombat-dressing-room.appspot.com
91+
)
92+
93+
# Create a separate release notes file to be included in the github release.
94+
release_notes_file=$(mktemp)
95+
echo "${next_version}" >> "${release_notes_file}"
96+
echo >> "${release_notes_file}"
97+
cat CHANGELOG.md >> "${release_notes_file}"
98+
echo ${release_notes_file}
99+
100+
echo
101+
echo "Clearing CHANGELOG.md."
102+
echo > CHANGELOG.md
103+
git commit -am "[release] Cleared CHANGELOG.md after ${next_version} release." CHANGELOG.md
104+
105+
echo
106+
echo "Pushing changes to GitHub."
107+
git push origin master --tags
108+
109+
echo
110+
echo "Creating GitHub release."
111+
hub release create \
112+
-F "${release_notes_file}" \
113+
-a packages/geofire-common/dist/geofire-common/geofire-common.min.js \
114+
-a packages/geofire/dist/geofire/geofire.min.js \
115+
"${next_version_tag}"

0 commit comments

Comments
 (0)