Skip to content

Commit

Permalink
chore: separate publish step to npm_package file
Browse files Browse the repository at this point in the history
  • Loading branch information
tribiec committed Feb 2, 2024
1 parent 8759389 commit 33ee773
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/npm_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: NPM Package Release

on:
push:
tags:
- '*'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Verify if tag is in master branch
run: |
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }})
MASTER_COMMIT=$(git rev-list -n 1 master)
if ! git merge-base --is-ancestor $TAG_COMMIT $MASTER_COMMIT; then
echo "Tag is not in master branch."
exit 1
fi
- name: Build (if needed for publication)
run: npm run build
- name: npm publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

0 comments on commit 33ee773

Please sign in to comment.