Publish package to GitHub Packages #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish package to GitHub Packages | |
on: | |
release: | |
types: [created] | |
permissions: # added using https://github.com/step-security/secure-workflows | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: 🔐 Harden Runner | |
uses: step-security/harden-runner@03bee3930647ebbf994244c21ddbc0d4933aab4f # v2.3.0 | |
with: | |
disable-sudo: true | |
egress-policy: block | |
allowed-endpoints: > | |
github.com:443 | |
npm.pkg.github.com:443 | |
registry.npmjs.org:443 | |
api.github.com:443 | |
nodejs.org:443 | |
- name: ⚙️ Git Checkout | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
- name: ⚙️ Install Node@20 and .npmrc for GitHub Packages | |
# Setup .npmrc file to publish to GitHub Packages | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://npm.pkg.github.com' | |
# Defaults to the user or organization that owns the workflow file | |
scope: '@onebeyond' | |
- name: ⚙️ Install dependencies | |
run: npm ci | |
- name: 📦 Publish in GitHub Packages | |
run: | | |
npm config set scope "@onebeyond" | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |