Skip to content

Publish NPM and Release (on merged PR) #14

Publish NPM and Release (on merged PR)

Publish NPM and Release (on merged PR) #14

Workflow file for this run

name: Node.js Package Release
on:
workflow_dispatch:
inputs:
semver:
description: "The semantic version to bump (patch, minor, major)"
required: true
default: "patch"
nodeVersion:
description: "The Node.js version to use"
required: true
default: "16.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 version and push tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
npm version ${{ github.event.inputs.semver }}
git push && git push --tags
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: |
echo VERSION=$(cat package.json | grep version | tr -d " " | cut -d":" -f2 | tr -d "\",") >> $GITHUB_ENV
shell: bash
name: Set version as env var
- uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
name: Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false