Skip to content

Workflow file for this run

# This workflow will run tests using node and then publish a package to GitHub Packages & npm when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Publish to both npm & GitHub Packages registries
on:
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- run: npm ci
- run: npm run build
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
registry-url: https://registry.npmjs.org/
- run: npm ci
- name: 'Publishing to npm'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
publish-gpr:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
registry-url: https://npm.pkg.github.com/
scope: '@somnusjs'
# see https://github.com/actions/setup-node/issues/130 for why we need to auth explicitly here
# @TODO consider removing this step once the issue above is resolved
- name: 'Authenticate with the GitHub Packages registry'
run:
echo "//npm.pkg.github.com:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
- name: 'Scope the package to satisfy GitHub Packages scoping requirements'
run: './scripts/publish-gpr.mjs unsafe-rescope'
- name: 'Publishing to GitHub Packages'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}