How did I write a PackageManager with GitHub
Published 4 months ago
When I started game development, I wanted to be able to use some of codes and assets I use a lot, in my other projects. One way was to put all assets together in a folder, zip them, (export as unitypackage in Unity), and import into other projects.
- Fast - Safe (because it worked in the previous project)
- Packages are not up to date - You can not manage these packages - Does not feel geek 👾
I was getting to know about package managers like npm, but I had no idea how to get started with writing something like that. On the other hand, Unity has its own AssetStore to download various Asset, but personally I do not use much of it except for premium assets.

First try:

A year ago - I began to read and learn about the mechanism of a package manager. I’ve found that I need to have a server that keeps the list of all packages with packages source (I had neither enough knowledge how to do that nor had my own server), I had to write a CLI to download packages from the server (and again the error: knowledge not enough) and I was humbled, and without making additional noises, closed web pages and went away.

Second try:

Unity’s 2018 has its own internal Package manager that only handles their own packages(published or wrote by unity company). So I remembered my old dream and It went on my nerves again. since the last time, I had some repositories in my GitHub and I used to know more about GitHub rather than last year. - I know that we can have files with direct download link in GitHub. - I could see that if we have a repository name, its owner’s name and the version code in Release page, then we have its zipped download link:
If I have a JSON containing some package info, I can download them.
{ "packages": [ { "name": "Open Audio", "description": "An easy to use Unity audio service", "packageName": "OpenAudio", "author": "omid3098" }, { "name": "Open Framework", "description": "A Lightweight framework for unity.", "packageName": "OpenFramework", "author": "omid3098" } ], "server": "" }
Digging sometime in GitHub API, I’ve found that we do not need the version number and we can get the latest changes for each package by having only the package name and author:
Here we can access the zipped version of each package. we just need to download and unzip it in the right place. (You can also download the tarball)
  • A place to have all packages (Github) ✅
  • A place to store package meta (Github) ✅
  • CLI or a tool to search and manage these packages. 👨‍🔧
Apparently we only need to write a tool to manage these packages and the rest is between package developer and end user. Whenever the developer releases a new version, this Package Manager will automatically look for latest repository zip.
So with some knowledge of editor tool development for Unity, I’ve made this tool. You can search through packages and download them in desired location in your project.
If you also have a package for Unity that you want to put into this package manager, just send the repository link with as described here.

What else?

Please consider that this tool is at the beginning of the way. it can be improved by the API provided by GitHub, like the date of the last release, Latest commit tag, consider package dependencies and more.
You also can use something like this method for other situations than game development or Unity engine.
Feel free to contribute in GitHub repository.

Omid Saadat
Programmer - Tech Consultant - 3D Generalist - Programmer