Skip to content

Commit 034f61c

Browse files
committed
Change gitpublish script to use publish-release module to publish build results as github release tarballs
1 parent ca22224 commit 034f61c

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/node_modules/
22
/dist/
3+
.publish-release-*
34

45
# Logs
56
logs

gitpublish.sh

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,27 @@ set -o errtrace # same as set -E: inherit ERR trap in functions
77
trap 'echo Error in line "${BASH_SOURCE}":"${LINENO}"; exit 1' ERR
88
trap '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
1513
fi
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
3726
if [ "$ANSWER" != "y" ]; then
3827
echo "Aborted"
3928
exit 1
4029
fi
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"

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
"**/*.d.ts"
4747
]
4848
},
49+
"publishRelease": {
50+
"owner": "gristlabs",
51+
"repo": "grainjs"
52+
},
4953
"dependencies": {},
5054
"devDependencies": {
5155
"@types/chai": "^4.1.2",
@@ -61,6 +65,7 @@
6165
"lodash": "^4.17.4",
6266
"mocha": "^3.0.1",
6367
"nyc": "^11.4.1",
68+
"publish-release": "^1.4.0",
6469
"sinon": "^4.0.0",
6570
"ts-node": "^3.3.0",
6671
"tslint": "^5.8.0",

0 commit comments

Comments
 (0)