@@ -7,40 +7,27 @@ set -o errtrace # same as set -E: inherit ERR trap in functions
77trap ' echo Error in line "${BASH_SOURCE}":"${LINENO}"; exit 1' ERR
88trap ' echo "Exiting on interrupt"; exit 1' INT
99
10-
11- if [[ " $# " -lt 1 ]]; then
12- echo " Usage: ./gitpublish.sh <master|branch|commit>"
13- echo " Builds dist/ in the given commit, and merges into gitpublish branch."
14- exit 2
10+ if ! git diff --quiet HEAD ; then
11+ echo " Must be run in a clean checkout"
12+ exit 1
1513fi
1614
17- COMMIT=" $1 "
18- export PAGER=cat
15+ BINDIR=./node_modules/.bin
16+ NEXT_BUILD_NUM=` git tag -l ' build-*' | awk -F- ' {if($2>max){max=$2}}END{print max+1}' `
17+ TAG=" build-${NEXT_BUILD_NUM} "
18+ RELEASE_NAME=" grainjs-$TAG "
19+ TOKEN=` cat .publish-release-oauth-token`
1920
20- # Remember the branch we were on.
21- branch=` git rev-parse --abbrev-ref HEAD`
22-
23- git checkout --detach -q " $COMMIT "
24- echo " Switched to ` git rev-parse --short HEAD` ($COMMIT )"
21+ echo " Building $TAG on ` git rev-parse --abbrev-ref HEAD` for publishing"
2522./build.sh
23+ npm test
2624
27- sed -i " " -e ' /^\/dist/d' .gitignore
28- git add .gitignore dist/
29-
30- next_build_num=` git tag -l ' build/*' | awk -F/ ' {if($2>max){max=$2}}END{print max+1}' `
31- tag=" build/${next_build_num} "
32-
33- git --no-pager diff --cached .gitignore
34- git --no-pager status
35-
36- read -p " Commit as tag $tag and push (y/n)? " ANSWER
25+ read -p " Tag the build as $TAG and publish (y/n)? " ANSWER
3726if [ " $ANSWER " != " y" ]; then
3827 echo " Aborted"
3928 exit 1
4029fi
4130
42- git commit -m " Build dist/"
43- git tag $tag
44- git push origin $tag
45-
46- echo " Returning to $branch "
31+ ASSET=` npm pack`
32+ git tag $TAG
33+ $BINDIR /publish-release --token $TOKEN --notes " Build from master" --assets $ASSET --tag $TAG --name=" $RELEASE_NAME "
0 commit comments