Search Unity

Custom Packages With Version Numbers

Discussion in 'Package Manager' started by garrilla, Apr 15, 2019.

  1. garrilla

    garrilla

    Joined:
    Jan 12, 2016
    Posts:
    28
    I've trying to make a custom package that will let me distribute a plugin, and associated assets on a private basis.

    If I update the assets or the plugin - how do I give it a version so it can be seen in package manager by my customer

    is this even possible?
     
  2. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    Hi @garilla,

    It sounds like you want a private registry. With a private registry, you can publish new versions of your package and they will be listed in the Package Manager window for any Unity project that points to that registry. You can even have a project that points to Unity's registry as well as your own. This feature is called "scoped registries" and is described here:
    https://forum.unity.com/threads/setup-for-scoped-registries-private-registries.573934/#post-3819754

    If setting up your own registry server is not feasible, there are other ways of sharing your package privately such as through a Github repository. Let me know if you want more details!
     
  3. garrilla

    garrilla

    Joined:
    Jan 12, 2016
    Posts:
    28
    hi @samuelb_unity

    yes, I'd like to know more about how to do this through a git repo (although most likely to bitbucket than github)

    thanks
     
    Last edited: Apr 15, 2019
  4. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    Sure, in the Package Manager window you can click the
    +
    button and
    Add package from package ID...
    . The package ID should be in the format <package-name>@<git-clone-url> where the URL ends with ".git". For more information on formatting the URL (such as specifying a branch or specific commit) see here:
    https://forum.unity.com/threads/git-support-on-package-manager.573673/#post-3819487

    If you open your project manifest (<your-project>/Packages/manifest.json) you will see the git package has been added to "dependencies" and a "lock" attribute is set. This means your Unity project is locked to that specific revision of the repo e.g.

    Code (CSharp):
    1.  
    2. {
    3.   "dependencies": {
    4.     "my-package": "https://bitbucket.com/my-package.git"
    5.   },
    6.   "lock": {
    7.     "my-package": {
    8.       "hash": "abc123",
    9.       "revision": "HEAD"
    10.     }
    11.   }
    12. }
    13.  
    If you push a new revision and you want your project to get it, simply delete the whole "lock" entry and Package Manager will grab the latest i.e.

    Code (CSharp):
    1.  
    2. {
    3.   "dependencies": {
    4.     "my-package": "https://bitbucket.com/my-package.git"
    5.   }
    6. }
    7.  
    Be careful not to leave any trailing commas behind as this is not valid JSON
     
    RGV and wolfyllow like this.
  5. garrilla

    garrilla

    Joined:
    Jan 12, 2016
    Posts:
    28
    Thanks.

    Is this "lock" deletion a one-time-only affair or each revision?
     
  6. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    You will have to delete the lock (or add the package again) every time you want to fetch the latest revision. This is by design because, for example, 2 people on the same project should always get the same packages. There might be plans in the future to make this easier through the Package Manager window e.g. an "Update to latest" button.
     
  7. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    You can add a branch name at the end:
    Code (CSharp):
    1. "my-package": "https://bitbucket.com/my-package.git#branch"
    and use the branch name as a version ID to switch between versions back and forth with no need to delete the "lock" section.
     
    david-mal likes this.
  8. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    Yep, or you could stay on the same branch and use
    tags
    to differentiate version releases. In fact, any commit-ish identifier can follow the
    #
    symbol.