Skip to content

Publish Package to npmjs #41

Publish Package to npmjs

Publish Package to npmjs #41

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:
inc_patch_ver:
name: Increment patch version
runs-on: ubuntu-latest
# if: "!startsWith(github.event.head_commit.message, '[RELEASE]')"
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag }}
# token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
- run: git config --global user.name 'ais-one'
- run: git config --global user.email '[email protected]'
# - run: npm version patch -m "[RELEASE] %s"
- run: npm version patch --workspace=libs/${{ github.event.inputs.pkg }}
- run: |
git add .
git commit -m "inc patch ver"
git push origin ${{ github.event.inputs.tag }}
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 }}