UNPKG

1.26 kBapplication/x-shView Raw
1#!/bin/sh
2
3if [ -z "`which github-changes`" ]; then
4 # specify version because github-changes "is under heavy development. Things
5 # may break between releases" until 0.1.0
6 echo "First, do: [sudo] npm install -g github-changes@0.0.14"
7 exit 1
8fi
9
10if [ -d .git/refs/remotes/upstream ]; then
11 remote=upstream
12else
13 remote=origin
14fi
15
16# Increment v2.x.y -> v2.x+1.0
17npm version minor || exit 1
18
19# Generate changelog from pull requests
20github-changes -o request -r request \
21 --auth --verbose \
22 --file CHANGELOG.md \
23 --only-pulls --use-commit-body \
24 --date-format '(YYYY/MM/DD)' \
25 || exit 1
26
27# Since the tag for the new version hasn't been pushed yet, any changes in it
28# will be marked as "upcoming"
29version="$(grep '"version"' package.json | cut -d'"' -f4)"
30sed -i -e "s/^### upcoming/### v$version/" CHANGELOG.md
31
32# This may fail if no changelog updates
33# TODO: would this ever actually happen? handle it better?
34git add CHANGELOG.md; git commit -m 'Update changelog'
35
36# Publish the new version to npm
37npm publish || exit 1
38
39# Increment v2.x.0 -> v2.x.1
40# For rationale, see:
41# https://github.com/request/oauth-sign/issues/10#issuecomment-58917018
42npm version patch || exit 1
43
44# Push back to the main repo
45git push $remote master --tags || exit 1