diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4602353080..680c39b609 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,3 +56,23 @@ jobs: publish_dir: ./gh-pages full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}" enable_jekyll: true + - name: Deploy to npm + run: | + export RELEASE_VERSION="0.2.0-prerelease.$(date +'%Y%m%d%H%M%S')" + if [[ "${{contains(github.ref, 'hotfix')}} ]]; then + export NPM_TAG=hotfix + elif [[ "${{contains(github.ref, 'beta')}} ]]; then + export NPM_TAG=beta + else + export NPM_TAG=latest + fi + echo "Deploying version $RELEASE_VERSION to $NPM_TAG" + npm --no-git-tag-version version $RELEASE_VERSION + npm set //registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}} + npm publish --tag $NPM_TAG + if npm info | grep -q $RELEASE_VERSION; then + git tag $RELEASE_VERSION + git push \ + https://${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository_owner}}/${{github.repository}}.git \ + $RELEASE_VERSION + fi