Add GitHub Action for publishing package to npm #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |