Skip to content

Node.js Webpack Package #9

Node.js Webpack Package

Node.js Webpack 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 Webpack Package
on:
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ matrix.node-version }}
restore-keys: |
${{ matrix.node-version }}
- run: npm ci
# Run test using Mocha framework
- run: npm test
# Ensure this script builds to the dist directory
- run: npm run build
# Copy package.json to dist directory
- run: cp package.json dist/
publish-gpr:
needs: build
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [20.x, 22.x]
permissions:
contents: read
packages: write
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ matrix.node-version }}
restore-keys: |
${{ matrix.node-version }}
- run: npm ci
# Copy package.json to dist directory
- run: cp package.json dist/
# Set working directory to dist
- working-directory: ./dist
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}