Skip to content

Commit

Permalink
update publish script to publish alpha versions
Browse files Browse the repository at this point in the history
  • Loading branch information
siddy2181 committed Nov 27, 2023
1 parent 71b5b83 commit ebacc5e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: 🤝 Set Node version from .nvmrc
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV

- name: ⎔ Setup node
# sets up the .npmrc file to publish to npm
uses: actions/setup-node@v3
with:
node-version: "16"
node-version: ${{ env.NVMRC }}
registry-url: "https://registry.npmjs.org"

- name: 📥 Download deps
Expand Down
24 changes: 19 additions & 5 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh

# This script will determine the type of release based on the git branch. When the default branch is used, it will be a `patch` that's published to npm under the `latest` dist-tag. Any other branch will be a `prelease` that's published to npm under the `alpha` dist-tag.
bump='patch'
tag='latest'

set -e;

if ! git diff-files --quiet; then
Expand All @@ -15,10 +19,20 @@ fi;
rm -rf node_modules
npm install

npm test;
current_branch=$(git rev-parse --abbrev-ref HEAD)
default_branch=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')

npm version ${1-patch}
if [ "$current_branch" != "$default_branch" ]; then
bump='prerelease'
tag='alpha'
npm --no-git-tag-version version $bump --preid=$tag
git push
npm publish --tag $tag
else
npm test;
npm version ${1-bump}

git push;
git push --tags;
npm publish;
git push;
git push --tags;
npm publish;
fi

0 comments on commit ebacc5e

Please sign in to comment.