Skip to content

Node.js Publish Package #1

Node.js Publish Package

Node.js Publish Package #1

Workflow file for this run

name: Node.js Publish Package
on:
# workflow_dispatch:
# push:
# branches:
# - main
release:
types: [published]
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm config set registry https://registry.npmjs.org
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-github:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: https://npm.pkg.github.com/
# scope: "@appsaeed"
- run: npm config set registry https://npm.pkg.github.com
- run: npm run build
- run: |
node <<EOF
const fs = require('fs');
const pkg = require('./package.json');
const _content = { ...pkg, name: '@${{ github.repository }}' };
fs.writeFile('package.json', JSON.stringify(_content), 'utf-8', (err) => {
if (err) {
console.warn(err)
process.exit(0);
};
})
EOF
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}