Skip to content

Node.js Package

Node.js Package #9

Workflow file for this run

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Node.js Package
on:
workflow_dispatch:
create:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci
- name: build package
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: ./lib
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifact
path: ./lib
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}