Skip to content

feat: add GitHub Actions workflow to create releases on publish #6

feat: add GitHub Actions workflow to create releases on publish

feat: add GitHub Actions workflow to create releases on publish #6

Workflow file for this run

name: Publish to NPM
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write # needed for creating releases
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.3.x'
registry-url: https://registry.npmjs.org/
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=v$(node -p "require('./package.json').version")
echo "Creating release for $VERSION"
gh release create $VERSION \
--title "$VERSION" \
--generate-notes
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access=public