Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

ModRelease - create new GitHub Release from commandline

ALIENALIEN Member Posts: 1,164
edited January 11 in General Modding
Hi,

A tool for creating a new GitHub Release from the command line!

Features:
  • can be combined with Infinity Auto Packager tool
  • cross-platform, single code for Windows, macOS, and Linux
  • release version (tag) is taken directly from tp2 file "VERSION" keyword
  • prevent creating a "2.0.0" release when your mod version is "1.9.0"
  • prevent creating new release if the same release already exist
  • prevent creating new release if there are uncommitted file modifications
  • release description can be edited before creating a new release
  • initial release description is generated from commit messages between the new release and previous release

Prerequisites:
Software Requirements:
Installation:
  1. Download and extract ModRelease repository, move everything from 'ModRelease-master' folder directly into the folder where you keep all cloned top-level mod folders.
  2. Create new "Personal Access Token" with "public_repo" privilege, it's not your password, you can revoke it at any time, more info here.
  3. Save it to "#ModRelease-Github-Key-Example.txt" file and rename it to #ModRelease-Github-Key.txt
  4. Put #ModRelease.bat/#ModRelease.command inside the top-level directory of the mod's cloned Github repository, it's where WeiDU executable should be, use the included mod example as reference.

Reference of the proper folder structure:
  • Red - #ModRelease folder and #ModRelease.bat/#ModRelease.command files location
  • Yellow - top-level folder of the local repository
  • Green - .git folder location inside local repository

prz2z60ja0wg.png

Usage:
  1. Assuming that all mod files are ready for a new release, increase mod version inside mod readme and mod tp2 file.
  2. Create a new commit with all modified files. Do not create a new tag for release, the tag itself will be created automatically (from mod "VERSION" keyword) and pushed into an online repository.
  3. Run #ModRelease.bat (Windows) | #ModRelease.command (Mac) | #ModRelease.sh (Linux) and follow further instructions.


Feedback/questions/comments are welcome.

Post edited by ALIEN on
Mirandel
«1

Comments

  • RaduzielRaduziel Member Posts: 4,716
    I'm failing to see how it is easier than making the release in the ordinary way.

    But I have a lot of ignorance when it comes to GitHub.

  • ALIENALIEN Member Posts: 1,164
    edited June 2019
    @Raduziel
    How about extra features like:

    -checks "VERSION" keyword and make sure that you don't create '2.1.3' release when you mod version is actually '2.1.1' - done
    -creating mod archive: modname-version.zip and upload it into release as 'Assets', you can see examples here - done
    -ability to read "changelog.md" file in order to insert changes from last version directly into release description

    Post edited by ALIEN on
  • RaduzielRaduziel Member Posts: 4,716
    - Very good!

    - I don't have the knowledge necessary to judge the importance of this

    - Lovely!

  • ALIENALIEN Member Posts: 1,164
    edited June 2019
    I've finally manage to create first public version of my script, first post updated. If someone needs help or have an feature request, feel free to ask.

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited June 2019
    Yes, additional details would be welcomed.

    I'm on macOS and my mod is composed of:
    1. example (main mod folder)
    2. .gitignore

    I generated a personal access token and saved it to '#ModRelease-Github-Key.txt'.

    After that, I moved '#ModRelease.bat' from your 'ExampleMod' folder to my mod, so now I have 3 files:
    1. example (main mod folder)
    2. .gitignore
    3. #ModRelease.bat

    What am I supposed to do now exactly?

    Post edited by _Luke_ on
  • ALIENALIEN Member Posts: 1,164
    edited June 2019
    Hi, @Luke93

    Sorry, forget about .bat files, those are for Windows OS. I've added missing "#ModRelease.command" file for Mac. I also made some improvements so you need to re-download whole repository again and overwrite #ModRelease.ps1 file.

    Now, when you ready with you release ( read 'Usage' paragraph ), simply run "#ModRelease.command" file and follow instruction.

    P.S. Probably tomorrow, I will add a nice GUI where you can edit release description, instead of the limited one-line commandline.

    Post edited by ALIEN on
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    @ALIEN

    When running "#ModRelease.command", I get the following error:
    The argument '..\#ModRelease\#ModRelease.ps1' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    

    My repository consists of:
    1. my_mod (main mod folder)
    2. #ModRelease (a folder which contains "#ModRelease-Github-Key.txt" with my personal access token and a file named "#ModRelease.ps1")
    3. "#ModRelease.command"

    Am I missing something?

  • ALIENALIEN Member Posts: 1,164
    @Luke93 Please move #ModRelease.command into "my_mod (main mod folder)" - this should be you top-level folder where you cloned Github repository. Probably the instructions are not clear enough, I will try to add screenshots.

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited June 2019
    OK, now I get these warnings:
    Invoke-RestMethod : {"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
    At /Users/%username%/Desktop/my_mod/#ModRelease/#ModRelease.ps1:104 char:24
    + ... aReleases = Invoke-RestMethod -Uri "https://api.github.com/repos/$Org ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Method: GET, Reques\u2026PowerShell/6.2.1
    }:HttpRequestMessage) [Invoke-RestMethod], HttpResponseException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    
    followed by
    Cannot index into a null array.
    At /Users/%username%/Desktop/my_mod/#ModRelease/#ModRelease.ps1:114 char:29
    + Write-Host "Last Release: $($dataTags[0])"
    +                             ~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray
    

    In any case I'm given the possibility to continue:
    Last Release: 
    
    Do you want to create new Release: v1.0 ?
    
    Press ENTER to continue, Ctrl+c to stop:
    

    So, what's wrong now?

  • ALIENALIEN Member Posts: 1,164
    @Luke93 Is this is you first mod release, repository doesn't have any tags?

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited June 2019
    ALIEN wrote: »
    @Luke93 Is this is you first mod release, repository doesn't have any tags?

    Yes, first release.

    Moreover, I also received the following communication from Github:
    "We noticed that a valid OAuth access token of yours was committed to a GitHub repository. Disclosing a valid access token would allow other people to interact with GitHub on your behalf, potentially altering data, your contact information, and billing data.

    As a precautionary measure, we have revoked the OAuth token. A new token will need to be generated in order to continue using OAuth to authenticate to GitHub."

    I mean, that's weird since I didn't do anything in the end....

  • ALIENALIEN Member Posts: 1,164
    edited June 2019
    Luke93 wrote: »
    ALIEN wrote: »
    @Luke93 Is this is you first mod release, repository doesn't have any tags?
    Moreover, I also received the following communication from Github:
    "We noticed that a valid OAuth access token of yours was committed to a GitHub repository. Disclosing a valid access token would allow other people to interact with GitHub on your behalf, potentially altering data, your contact information, and billing data.

    As a precautionary measure, we have revoked the OAuth token. A new token will need to be generated in order to continue using OAuth to authenticate to GitHub."

    I mean, that's weird since I didn't do anything in the end....

    You did but not via this script:
    Luke93 wrote: »
    My repository consists of:
    1. my_mod (main mod folder)
    2. #ModRelease (a folder which contains "#ModRelease-Github-Key.txt" with my personal access token and a file named "#ModRelease.ps1")
    3. "#ModRelease.command"
    I missed the fact that you put two folders into repository, this is wrong, repository should only contains you mod files + "#ModRelease.command".

    Example:
    Red - ModRelease folder and "#ModRelease.command" location
    Yellow - Repository top-level folder
    Green - .git folder location

    prz2z60ja0wg.png

    Now it's clear why you received this message: you committed "#ModRelease-Github-Key.txt" file into online repository by mistake. As a security feature, Github blocked this API key. You need to move "#ModRelease" folder outside the local git repository (see example ), recreate new API key and put it into #ModRelease-Github-Key.txt.

    Luke93 wrote: »
    ALIEN wrote: »
    @Luke93 Is this is you first mod release, repository doesn't have any tags?
    Yes, first release.
    I see, I will fix error messages. You can create initial release, next time you should't see errors.

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    @ALIEN

    It seems to work fine now, thanks :)
    tp2 VERSION: v1.0
    
    No online releases detected.
    Do you want to create new Release: v1.0 ?
    
    Press ENTER to continue, Ctrl+c to stop:
    

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited June 2019
    A question though: how can I generate Windows/macOS/Linux assets? I currently have only source code...


    3bn7rrbhkzgd.png

  • ALIENALIEN Member Posts: 1,164
    edited June 2019
    @Luke93 For mod packages, I have nearly finished "#ModPackage" script. It has to be separate because some people create mod packages but they don't use Github as hosting. I will finish it during this week.

    P.S. There is no need for 3 separate packages instead of one universal mod package which simultaneously supports Windows, macOS and Linux.

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    ALIEN wrote: »
    P.S. There is no need for 3 separate packages instead of one universal mod package which simultaneously supports Windows, macOS and Linux.

    OK, so your "#ModPackage" script will allow to generate this universal mod package? I'll wait for it then...

  • ALIENALIEN Member Posts: 1,164
    edited July 2019
    @Luke93 Could you tell me which approach/solution is less and most acceptable for you?

    A. Package the mod as .iemod + don't include weidu: you basically forces the players to use mod managers (unlike other games not many other games require them) and you need to include explanation, something like: 'if you don't want to use mod manager, simply rename it to zip and extract the content of this file to game dir, also download copy of the weidu, rename it to setup-mymod/.exe and run from game directory', no double-click feature for macOS right now (unless you manually associate file type)

    B. Package the mod as .iemod + include weidu: you basically forces the players to use mod managers (unlike other games not many other games require them) and you need to include explanation, something like: 'if you don't want to use mod manager, simply rename it to zip and extract the content of this file to game dir', no double-click feature for macOS right now (unless you manually associate file type)

    C. Package the mod as .zip and include weidu: no double-click feature for mod manager, double-click works for macOS and Windows

    D. Two separate packages: first: .iemod without weidu, second .zip with weidu

    Post edited by ALIEN on
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited July 2019
    @ALIEN

    I was thinking of something like this:
    o6l44c77jf7z.png

    See? Source code + Windows + macOS + Linux.
    • Linux: this contains just the main mod folder
    • Windows: this contains the main mod folder + WeiDU executable (setup-mymod.exe)
    • macOS: this contains the main mod folder, WeiDU executable (setup-mymod) and setup-mymod.command.

    What do you think?

  • ALIENALIEN Member Posts: 1,164
    edited July 2019
    @Luke93 That's bad because there is no point of having 3 different zip archives (not to mention that the naming scheme breaks 'searching by typing' feature). So how about D variant where you have 'ModName-Version.zip' with weidu and 'ModName-Version.iemod' package for mod managers? (Now we have two but it's still less than 3 :wink: )

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited July 2019
    ALIEN wrote: »
    @Luke93 That's bad because there is no point of having 3 different zip archives (not to mention that the naming scheme breaks 'searching by typing' feature). So how about D variant where you have 'ModName-Version.zip' with weidu and 'ModName-Version.iemod' package for mod managers? (Now we have two but it's still less than 3 :wink: )

    OK, let's try....

    So, the zip version will contain both setup-mymod.exe and setup-mymod.command (i.e., both Windows and Unix WeiDU executables)?

  • ALIENALIEN Member Posts: 1,164
    @Luke93 Yep, that's the idea. Size of the package doesn't really matter those days.

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,474
    edited July 2019
    ALIEN wrote: »
    @Luke93 Yep, that's the idea. Size of the package doesn't really matter those days.

    OK, proceed then.... Once you're done with your update, I'll test it...

  • ALIENALIEN Member Posts: 1,164
    edited July 2019
    @Luke93 ModRelease was updated, everything is the same except now it should create two packages as we speak and add it into new release automatically. You need to redownload whole repository again (new files were added), extract it and then move and replace files. After that, you simply execute creation of the new release.

    Post edited by ALIEN on
  • The user and all related content has been deleted.

  • ALIENALIEN Member Posts: 1,164
    edited July 2019
    @subtledoctor
    I don't understand the reference to Applescript, do you mean that for .zip package, I should replace .command files with "MacOS Weidu Launcher" as replacement for them?

    Also, I'm interested in any kind of solution which improves user/player experience on macOS.

  • [Deleted User][Deleted User] Posts: 0
    edited July 2019
    The user and all related content has been deleted.

  • ALIENALIEN Member Posts: 1,164
    @subtledoctor I played a bit with this using macOS Mojave and this is what are my observation:
    - the idea of the application is good but ... why you also included this inside all of you mod packages instead of simply telling people that 'you need one time download of "Mac Weidu Launcher"?
    - it creates a symlink (alias) inside game directory so there will be 41 items after installing 20 mods but anyway, the pollution of main game directory can't be avoided
    - you choose to name WeiDU executable as "weidu", every time when a Linux user will extract one of you mod, it will break his 'weidu' executable
    - iemod packages are for mod files only, if it would be included into zip package (not the same as github "Download" zip because it has extra dir) it causes "overwrite files" question, which would spike infinite amount of "Should I overwrite files or not" from new players.

    It seems to me that while it has some benefits, it also has flaws. Are you interested in changing the app in order to overcome some of them?


  • The user and all related content has been deleted.

  • [Deleted User][Deleted User] Posts: 0
    edited July 2019
    The user and all related content has been deleted.

  • ALIENALIEN Member Posts: 1,164
    edited July 2019
    @subtledoctor
    Being asked whether to overwrite something (where it will work no matter what you choose) vs. being asked to go find and download a separate package... I figured the former is less of a burden for players. It's a judgment call.

    Plus, I figured it would be a way to get the Weidu Launcher in front of more eyeballs and maybe spark some interest.

    Regarding 'burden for players' - it's only one 'extra' thing to download (same as one extra mod), requirements to use mod managers are totally normal thing for 90% of games. No one will complain that he need to download and use mod manager if it is in fact the easiest way to install mods.

    Okay I mentioned elsewhere but I'll put it here as well: this is a Mac app that works exactly like the Windows "setup-modname.exe" files. Unzip this to your MacOS game folder, rename it to "setup-modname" to match a mod folder, and double-click it. It should make installing mods on a Mac precisely the same as installing on Windows. No need for separate instances of Weidu + .command script, and it doesn't pollute the folder with extra files.

    Well, there is one more issue with the concept of setup-modname.app:

    Mac OS Mojave, after launching .app:

    - first window with confirmation:
    image.png.1a5cf2266203d1bc028398822c86fea4.png


    - after clicking "OK" another window for confirmation:

    image.png.37223c6951f52698c72eb84ac782c354.png


    then finally console appears.

    And from what I've found, there is no way to avoid it (please correct me if I'm wrong, I'm not familiar with macOS at all) thus .command files still have one advantage of not requiring such confirmation (if using 'setup-modname' approach, I'm much more of a fan of separate 'mod manager')

Sign In or Register to comment.