Skip to content

Commit 5ea93af

Browse files
authored
Update publish to NPM script (#96)
* update publish script * bump version
1 parent 4dce96a commit 5ea93af

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

scripts/publish.sh

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
#!/bin/sh
22

3-
# Running `npm version` will run through the other version lifecycle scripts
4-
npm version ${1-patch};
3+
# This script will determine the type of release based on the git branch.
4+
# When the default branch is used, it will be a `patch` that's published to npm
5+
# under the `latest` dist-tag. Any other branch will be a `prelease` that's
6+
# published to npm under the `alpha-$SHA` dist-tag.
7+
bump='patch'
8+
tag='latest'
9+
10+
current_branch=$(git rev-parse --abbrev-ref HEAD)
11+
default_branch=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
12+
current_sha=$(git rev-parse --short HEAD)
13+
14+
if [ "$current_branch" != "$default_branch" ]; then
15+
bump='prerelease'
16+
tag="alpha-$current_sha"
17+
export tag
18+
npm --no-git-tag-version version $bump --preid=$tag
19+
else
20+
export tag
21+
npm version $bump
22+
fi

0 commit comments

Comments
 (0)