Skip to content

Publish NPM and Release (on merged PR) #20

Publish NPM and Release (on merged PR)

Publish NPM and Release (on merged PR) #20

Workflow file for this run

name: Node.js Package Release
on:
workflow_dispatch:
inputs:
semver:
description: "The semantic version to bump"
required: true
type: choice
options:
- patch
- minor
- major
default: "patch"
nodeVersion:
description: "The Node.js version to use"
required: true
type: choice
options:
- "18.x"
- "20.x"
- "22.x"
default: "18.x"
jobs:
release:
permissions:
contents: write
# Use the semver as the job name
name: "Release ${{ github.event.inputs.semver }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610
with:
node-version: ${{ github.event.inputs.nodeVersion }}
registry-url: "https://registry.npmjs.org"
- name: Bump and commit version
run: |
git config --global user.email "github-actions[bot]@github.com"
git config --global user.name "github-actions[bot]"
npm version ${{ github.event.inputs.semver }} --message "chore(release): bump version to %s"
git push --follow-tags
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Set version as env var
run: |
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false