Skip to content

Publish package to registry #3

Publish package to registry

Publish package to registry #3

Workflow file for this run

name: Publish package to registry
on:
workflow_dispatch:
inputs:
version:
description: Version to publish
default: 1.0.0
required: true
release:
types:
- released
jobs:
publish:
runs-on: ubuntu-latest
steps:
#
# Checkout repository
#
- name: Checkout
uses: actions/checkout@v4
#
# Setup Node.js
#
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
#
# Setup PNPM package manager
#
- name: Setup package manager
uses: pnpm/action-setup@v2
with:
version: 8
#
# Install all dependencies
#
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
#
# Build package and generate javascript files
#
- name: Build package
run: pnpm build
#
# Configure git user email
#
- if: github.event_name == 'release'
name: Configure git user email
run: git config --global user.email "${{ github.event.release.author.email }}"
- if: github.event_name == 'workflow_dispatch'
name: Configure git user email
run: git config --global user.email "${{ github.actor }}@users.noreply.github.com"
#
# Configure git user name
#
- if: github.event_name == 'release'
name: Configure git user name
run: git config --global user.name "${{ github.event.release.author.login }}"
- if: github.event_name == 'workflow_dispatch'
name: Configure git user name
run: git config --global user.name "${{ github.actor }}"
#
# Change package version
#
- if: github.event_name == 'release'
name: Change package version
run: pnpm version ${{ github.event.release.tag_name }}
- if: github.event_name == 'workflow_dispatch'
name: Change package version
run: pnpm version ${{ github.event.inputs.version }}
#
# Publish package to destination registry
#
- name: Publish package to registry
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}