Search Unity

Add support for Github Package Registry

Discussion in 'Package Manager' started by Rocktavious, Nov 20, 2019.

  1. Rocktavious

    Rocktavious

    Joined:
    May 10, 2017
    Posts:
    44
    Hello,

    Long time lurker first time poster. I really love the direction Unity is going with the package manager but with the advent of some of the developments with Github I would like to see the package manager not only support git urls but it should now support the Github Package Registry.

    Here is an example unity library I wrote and here is what the package.json need to look like to beable to publish the resulting "package" to github - https://github.com/red-owl-games/UIEX/blob/a1a2696555a585feda73640ac3847668a051fe11/package.json

    You can view the package here - https://github.com/red-owl-games/UIEX/packages/32700
    and here is the github documentation on configuring NPM to download that package "unauth'd" - https://help.github.com/en/github/m...use-with-github-packages#installing-a-package

    That being said - i've tried and it seems to come down to the fact that unity is forcing a "domain reverse lookup" style on the naming of packages.

    When i configure my project manifest.json file like so

    Code (JavaScript):
    1. {
    2.   "scopedRegistries": [
    3.     {
    4.       "name": "RedOwl",
    5.       "url": "https://npm.pkg.github.com/red-owl-games",
    6.       "scopes": [
    7.         "com.redowlgames"
    8.       ]
    9.     }
    10.   ],
    11.   "dependencies": {
    12.     "com.redowlgames.uiex": "1.0.0"
    13.   }
    14. }
    I get the error


    Code (CSharp):
    1. An error occurred while resolving packages:
    2.   Project has invalid dependencies:
    3.     com.redowlgames.uiex: Request [GET https://npm.pkg.github.com/red-owl-games/com.redowlgames.uiex] failed with status code [401]
    Since you guys seem to be trying to closely (but no 100% adhere to the NPM spec) it seems like you could easily support this by allowing the following

    Code (JavaScript):
    1. {
    2.   "scopedRegistries": [
    3.     {
    4.       "name": "RedOwl",
    5.       "url": "https://npm.pkg.github.com/red-owl-games",
    6.       "scopes": [
    7.         "@red-owl-games"
    8.       ]
    9.     }
    10.   ],
    11.   "dependencies": {
    12.     "@red-owl-games/uiex": "1.0.0"
    13.   }
    14. }
    and thus building the request as https://npm.pkg.github.com/red-owl-games/uiex

    but doing the above results in the seemingly forced error on Unity's side of

    Code (CSharp):
    1.  
    2. An error occurred while resolving packages:
    3.   Project has invalid dependencies:
    4.     @red-owl-games/uiex: Package name '@red-owl-games/uiex' is invalid.
    5.  
    If Unity package manager would support Github Package Registry - it would be a huge boon to opensource package managers (and likely Unity itself could use it because of the number of new github based projects unity is pushing)

    Cheers!
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @Rocktavious,

    Thank you very much for this in-depth analysis. This will be useful if we ever implement this feature. More and more users like are asking for Unity to support this registry. I think we will get there. Btw, this request can be made both ways. In other words, you could reach out to GitHub and ask them to support Unity *scoped registries* ️. I'll share your investigation with the team.

    Thank you again! Regards,

    Pascal
     
    Zamaroht likes this.
  3. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    @Rocktavious, I posted a thread explaining how to configure GitHub Packages registry here. Come with some caveats.

    Regards,

    Pascal
     
    gustavo_quiroz and wcoastsands like this.