Skip to content

Merge pull request #12 from lewxdev/fix-publish-action-registry #3

Merge pull request #12 from lewxdev/fix-publish-action-registry

Merge pull request #12 from lewxdev/fix-publish-action-registry #3

Workflow file for this run

# based on https://github.com/azu/npm-github-package-example
name: Publish
on:
push:
branches:
- master
tags:
- "!*"
jobs:
publish:
name: 🚀 Publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: "https://registry.npmjs.org"
- run: npm clean-install
- run: npm test
# Publish to npm if this version is not published
- run: |
npx can-npm-publish --yes --verbose && npm publish || echo "Does not publish"
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
# Push tag to GitHub if the version's tag is not tagged
- run: echo "PACKAGE_VERSION=$(npm pkg get version | tr -d \")" >> $GITHUB_ENV
- uses: pkgdeps/git-tag-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
version: ${{ env.PACKAGE_VERSION }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "v"