|
| 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