Skip to content

Add GitHub Action for publishing package to npm #1

Add GitHub Action for publishing package to npm

Add GitHub Action for publishing package to npm #1

Workflow file for this run

name: Publish Package to npmjs
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
registry-url: 'https://registry.npmjs.org'
- name: Extract tag name
id: extract
run: echo "version=${GITHUB_REF#refs/tags/}" >> "${GITHUB_OUTPUT}"
- name: Write npm version
run: |
new_version="${{ steps.extract.outputs.version }}"
jq --arg new_version "$new_version" '.version = $new_version' package.json > temp.json && mv temp.json package.json
- run: bun run build
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}