14

I got access to the github package registry beta, just fiddled with it and followed the configuration steps to publish.

The thing is, I published it correctly, but noticed it didn't publish to npm. Is there a way to publish in both registries with the same command? Does it make sense to have the package published in both registries?


Also, my package name in the package.json is @alvarocastro/quicksort (as stated in the doc) and the name in the github page ends up being that, but in the command example to install, the scope is duplicated, eg: @alvarocastro/@alvarocastro/quicksort


Here is the complete package.json file as a reference:

{
  "name": "@alvarocastro/quicksort",
  "version": "1.0.1",
  "description": "An implementation of the quicksort algorithm",
  "main": "index.js",
  "scripts": {
    "performance": "node performance.js",
    "test": "xo && nyc ava",
    "coverage": "nyc report --reporter=text-lcov | coveralls"
  },
  "publishConfig": {
    "registry":"https://npm.pkg.github.com/@alvarocastro"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/alvarocastro/quicksort.git"
  },
  "keywords": [
    "quicksort",
    "sort",
    "algorithm"
  ],
  "author": "Alvaro Castro",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/alvarocastro/quicksort/issues"
  },
  "homepage": "https://github.com/alvarocastro/quicksort#readme",
  "devDependencies": {
    "ava": "2.3.0",
    "coveralls": "3.0.6",
    "nyc": "14.1.1",
    "xo": "0.24.0"
  }
}
Alvaro Castro
  • 811
  • 1
  • 9
  • 26
  • 2
    I saw you're in the GitHub Actions beta: if you want to automate the whole thing you could create a workflow that checks for the version & then runs two commands to publish to both registries. – Federico Grandi Sep 18 '19 at 15:07
  • @FedericoGrandi but to change the registry I have to modify the `publishConfig` property in the `package.json`, you say I should make an action that does that? Also, I'm a total noob of github actions, will do a bit of research later. – Alvaro Castro Sep 18 '19 at 16:05
  • For that you don't need to change `package.json`, since you can simply reset npm to use GPR as default registry: there's an example you can check in the "Usage" section of `actions/setup-node`, [here](https://github.com/actions/setup-node#usage). The part that will be more tricky is checking whether you pushed a new version: the easiest way would be to just run the thing when you create a new release, but that will force you to manually add a release every time you want to publish a new version... – Federico Grandi Sep 18 '19 at 17:52
  • 1
    There is another conflict: GitHub requires package name to be scoped whereas npm considers scoped name "private". – songololo Sep 24 '19 at 14:21
  • @AlvaroCastro, did you solved this issue? If yes, can you post an answer? I am exactly in the same situation as you! Thanks! – Paulo Coghi Nov 13 '19 at 21:05
  • 3
    @PauloCoghi-ReinstateMonica, no, still didn't manage to solve this. I'm sticking with npm for the moment. Now that npm is part of github maybe they get more integrated in the future as a single registry and none of this is needed. – Alvaro Castro Jun 17 '20 at 12:40
  • @AlvaroCastro, thanks for the update! – Paulo Coghi Jun 17 '20 at 13:34

0 Answers0