1.0.1 • Published 3 years ago

publish-unscoped-package-to-npm-and-github v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

publish-unscoped-package-to-npm-and-github

Inspired by Dev.to article and this issue

Testing of publishing an unscoped NPM package to Github Package Registry

NPM:

NPM version NPM downloads

GPR (GitHub Package Registry):

GPR version GPR downloads

Steps

  1. Add publishConfig section to your package.json
"publishConfig": {
   "registry": "https://registry-url"
 }
  1. Modify your .github/workflows/deploy.yml file

  2. Add NPM_AUTH_TOKEN variable in your Repository > Settings > Secrets > New repository secret button. GITHUB_TOKEN already exists

  3. Success :tada:

Usage

From NPM:

npm install publish-unscoped-package-to-npm-and-github

From GPR:

npm install @denisstasyev/publish-unscoped-package-to-npm-and-github

Possibly you will need .npmrc file:

@denisstasyev:registry = https://npm.pkg.github.com

Find out the registry used: npm config get registry

Show complete package manager configuration: npm config ls -l

Workflow file

Some notes here how to understand this workflow file:

Now this repository contains the simplest example, you need to manually raise the version for publication. For automatic version control you can use some tools like semantic-release (example of usage in Github Action and necessary .releaserc.json file)