Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Best practices for git repo for upm

Discussion in 'Package Manager' started by push-pop, Apr 6, 2020.

  1. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    28
    Hi all,

    I have a library for Unity here: https://github.com/push-pop/Unity-MVVM/

    I'm trying to figure out how people maintain/develop their libraries while also keeping a branch for upm up to date.

    So I have a master branch that is a full Unity project where I originally wrote the library. Then I branched that to a "module" branch where I moved all the code around so that I could import it directly (as in with upm)

    Curious how people keep their development in sync with a upm branch, since the files are in different places so pull requests/ merges won't really work. Trying to figure out the best automated approach to keep these branches in sync.

    Can upm move/delete files after importing a master branch for example? Or do I need a bot to copy files into the proper structure for upm when a commit goes to master? Any ideas here? First time getting this deep into upm.

    Thanks!
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
  3. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    28
    Thank you!! Exactly what I was looking for.

    I was digging through the approach taken by Mirror and it seems that this is it. Unfortunately I already branched and diverged from my master project branch going to take a bit if work to get it back to a state where this will work :/
     
  4. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    28
    So I followed your tutorial as best I could... I now have a master branch and a upm branch being generated by GitHub actions. AWESOME!

    Only issue is not when I import the package via packagemanager, I cannot access the namespaces of my package. Any idea why that would be? I can see Unity-MVVM in my Packages folder and in the package manager window.

    When I edit one of the files in my package, I see this warning:
    Script 'Packages/com.push-pop.unitymvvm/ViewModel/ViewModelBase.cs' will not be compiled because it exists outside the Assets folder and does not to belong to any assembly definition file.


    Any ideas what the issue is?
     
  5. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
  6. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    so thanks to the article and your response i met additional idea / problem

    i figured out it should be placed here as it is the proper thread for it.

    so as suggested in my other thread

    is to divide utility script into smaller piece. which ends up me having many unity project for small package code.

    also referring here that it would be great to have `"Test" Project` for package that i might need to test between development. this would end up with me having bunch of small unity project that handle it's own package which looks like overkill to even open a single unity project for a package consisting for measly ~50 line of code

    i've looked for monorepo like @Favo-Yang says. and it does looks like something i would like to achieve

    are there any way i could achieve this ? i could just use multiple split for different package. but is that feasible would it also make package versioning through git tag harder ?
     
  7. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    The link is https://forum.unity.com/threads/should-i-package-utility-script.861403/

    For monorepo, here's an example https://github.com/reeseschultz/ReeseUnityDemos
    - It has 3 packages
    - It splits to 3 branch, each for one package
    - It creates separate release (git tag) with package prefix
    - All packages are submitted to the OpenUPM platform i.e. https://openupm.com/packages/com.reese.spawning/
    - It doesn't use CI, but a tool called https://github.com/reeseschultz/ubump instead (from the same author).
     
  8. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    wow it looks nice i'll check it out. thanks