Skip to content

Instantly share code, notes, and snippets.

@anthowen
Created June 9, 2021 19:12
Show Gist options
  • Save anthowen/43e238fc944fe7626a340309ca7cefb0 to your computer and use it in GitHub Desktop.
Save anthowen/43e238fc944fe7626a340309ca7cefb0 to your computer and use it in GitHub Desktop.
How to publish a private JavaScript library to GPR using yarn package manager

This instruction is to register the library to GPR privately under the certain organization, like @org/lib.

  1. package.json
{
  "name": "@org/lib",
  "repository": {
    "type": "git",
    "url": "https://github.com/org/lib.git"
  },
  "publishConfig": {
    "registry": "https://npm.pkg.github.com/"
  },
  1. CI job
  • Version bump

    yarn version --major

    Depending on what version you're bumping, it can be different params, like (--minor or --patch)

  • Publish to GPR (GitHub Packages Registry)

    yarn publish . --tag latest
  1. NPM/yarn configurations
  • .npmrc

    //npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
    always-auth=true 
    
  • .yarnrc

    "@org:registry" "https://npm.pkg.github.com" 
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment