How did I write a PackageManager with GitHub

Unity open package manager

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.
Advantage:
– Fast
– Safe (because it worked in the previous project)
Disadvantages:
– 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:

https://github.com/:author/:packageName/archive/:versiontag.zip

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": "https://github.com/"
}

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:

https://api.github.com/repos/:author/:packageName/zipball

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.

Stop being X, be Y instead

Brain

 

When I was 12–13 years old, my father bought me a PC with some cool games running windows. every month we were allowed to go for buying new CDs. I was looking at the CD labels with joy trying to decide which one I want to have this month. there were Discreet 3ds max CD with a funny stupid 3D soldier on its cover. but that was not a game! and shipping that CD would be waste of money for my father. I never got that CD and forgot that.. *

At University, we started a game development team as 5 young engineering students with absolutely no ideas how to develop a game. just because we thought games are fun! OK, now were should we start? I remembered that CD:

“I want to be an Artist!”

I said.

we’ve spent a whole summer developing a game called “Satyar-Return to Parseh” and won the best game award of 2nd Broadcast Engineering Conference in 2007.

And I’ve spent 7 years as 3D Artist.

after 7 years full of joy, work, and earning money from 3D artist works , one day I said to myself, hey, you can be one of top 10 best character/environment artists in the world! do you want to be as good as Alex Alvarez?! of course I do! beside that, I started to learn how to work with “Game maker studio” after 3–4 month playing with the tool and making some simple apps/games I found that field truly amusing! Suddenly one of my friends told me that we need a programmer for our game can you do it?! after listening to the project description, and thinking about that I can do every thing that the game designer wants, I have accepted the project and!

“I want to be a Programmer!”

I said.

The Memoranda game went well. So I kept looking for more programming opportunities. one thing led to another and here am I with 4 years of experiment as a game programmer.

Do I want to be one of the top 10 best game programmers in the world? Yes I do!

But I want to live a happy life. I want to enjoy my work and I need to learn more before my time is up!

So who knows?! some day I may stop being x = “game programmer” and be y = ? instead!

— * There were no Copyrights in Iran and we could buy a 3d studio max CD for less than $1.