Skip to content

Publish Package to npmjs #44

Publish Package to npmjs

Publish Package to npmjs #44

Workflow file for this run

name: Publish Package to npmjs
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
pkg:
description: 'Project To Publish (esm or node). Ensure version is updated & tagged'
default: 'node'
required: true
tag:
description: 'Branch or tag'
default: 'main'
required: true
jobs:
# COMMENTED BECAUSE: cannot push to protected branch
# inc_patch_ver:
# name: Increment patch version
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# ref: ${{ github.event.inputs.tag }}
# - run: git config --global user.name 'ais-one'
# - run: git config --global user.email 'aaronjxz@gmail.com'
# - run: npm version patch --workspace=libs/${{ github.event.inputs.pkg }}
# - run: |
# git add .
# git commit -m "inc patch ver"
# git push
install_and_publish:
name: Install production dependencies and publish to npm
# if: ${{ !always() }}
# needs: inc_patch_ver
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '18' ] # lts?
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org'
# Setup .npmrc file to publish to npm
- run: echo checking out branch/tag ${GITHUB_REF##*/}
# - run: npm install --production --workspace=libs/${{ github.event.inputs.pkg }} # NOT NEEDED CURRENTLY
- run: npm publish --workspace=libs/${{ github.event.inputs.pkg }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}