Victor-IX / Blender-Launcher-V2

Standalone client for managing official builds of Blender 3D
GNU General Public License v3.0
405 stars 18 forks source link

Github Action to update winget package on release #141

Open jo-chemla opened 2 months ago

jo-chemla commented 2 months ago

Is your feature request related to a problem? Please describe. I've just submitted a PR https://github.com/microsoft/winget-pkgs/pull/172582 so that BlenderLauncher gets listed and can be installed on windows via winget install blender-launcher or winget install VictorIX.BlenderLauncher. I've used Komac to create the manifest files available in the PR - crediting your github profile, name etc.

It could be useful to add a github action on this repo so that the winget blender-launcher package gets updated on every github release.

Describe the solution you'd like

Here are two reference articles + action yml files made to keep the winget package up-to-date on every github release, via Github Actions. Requires a winget-token to be stored in security of the repo.

name: Publish to WinGet
on:
  release:
    types: [ released ]
jobs:
  publish:
    runs-on: windows-latest
    steps:
      - uses: vedantmgoyal9/winget-releaser@main
        with:
          identifier: Package.Identifier
          token: ${{ secrets.WINGET_TOKEN }}
          # installers-regex: '\.exe$' # Only .exe files
name: Submit Nushell package to Windows Package Manager Community Repository 

on:
  release:
    types: [published]

jobs:

  winget:
    name: Publish winget package
    runs-on: windows-latest
    steps:
      - name: Submit package to Windows Package Manager Community Repository
        run: |
          iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
          $github = Get-Content '${{ github.event_path }}' | ConvertFrom-Json
          $installerUrl = $github.release.assets | Where-Object -Property name -match 'windows.msi' | Select -ExpandProperty browser_download_url -First 1
          .\wingetcreate.exe update Nushell.Nushell -s -v $github.release.tag_name -u $installerUrl -t ${{ secrets.NUSHELL_PAT }}

Describe alternatives you've considered Once the initial PR gets merged, anyone can update the BlenderLauncher package. But having a github action do it on every release would make sure the winget repo always has the latest version available

Victor-IX commented 2 months ago

Thanks for doing that! I'll start this weekend implementing that

jo-chemla commented 2 months ago

Great, thanks for doing it! Will tell you once the PR gets merged. Probably no need to setup the Github Action before that. https://github.com/microsoft/winget-pkgs/pull/172582

jo-chemla commented 2 months ago

PR merged! Package available via a standard winget install VictorIX.BlenderLauncher

Since it uses Portable file, Blender-Launcher ends-up in C:\Users\username\AppData\Local\Microsoft\WinGet\Packages\VictorIX.BlenderLauncher_Microsoft.Winget.Source_8wekyb3d8bbwe\Blender launcher.exe but does not get added to windows start-menu. Winget adds it to path though, so can be run by running the "Blender Launcher.exe" from a terminal, with quotes since there is a space in exe filename.

Also, the -set-library-folder flag could maybe be exposed to the winget install options, not sure how I could do that I pinged the PR reviewer.

Here is another example github action workflow based on winget-releaser if you want to apply it to Blender-Launcher!

jo-chemla commented 2 months ago

Hi there, just made a quick PR as the basis for that github action: https://github.com/Victor-IX/Blender-Launcher-V2/pull/142 Hope this iwll work-out! I added instructions as to how to setup the github classic token in the PR message.

Victor-IX commented 4 days ago

Hey there, I did a new release and the action to build and publish the package failed Here is the builder log:

Updating manifests and creating pull request...
  Executing command: java -jar komac.jar update --id 'VictorIX.BlenderLauncher' --version 2.3.0 --urls '' --submit
  CI environment detected! Komac will throw errors instead of prompting on invalid input
  Latest version of VictorIX.BlenderLauncher: 2.2.0
  Installer URL cannot be blank on http://localhost
  node:internal/errors:984
    const err = new Error(message);
                ^

  Error: Command failed: & /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -jar komac.jar update --id 'VictorIX.BlenderLauncher' --version 2.3.0 --urls '' --submit
      at genericNodeError (node:internal/errors:984:15)
      at wrappedFn (node:internal/errors:538:14)
      at checkExecSyncError (node:child_process:890:11)
      at execSync (node:child_process:962:15)
      at /home/runner/work/_actions/vedantmgoyal2009/winget-releaser/v2/dist/index.js:300[79](https://github.com/Victor-IX/Blender-Launcher-V2/actions/runs/11925143422/job/33236719969#step:3:81):39
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    status: 1,
    signal: null,
    output: [ null, null, null ],
    pid: 1923,
    stdout: null,
    stderr: null
  }

  Node.js v20.13.1

Do you have an idea of what could have failed?

jo-chemla commented 4 days ago

The executed command Executing command: java -jar komac.jar update --id 'VictorIX.BlenderLauncher' --version 2.3.0 --urls '' --submit shows no urls have been passed, so probably the regex is wrong.

I think that line could be replaced by the following, escaping underscores

          # installers-regex: '^Blender_Launcher_v[\d\.]+_Windows_x64\.zip$'
          # evaluating Blender_Launcher_v2.3.0_Windows_x64.zip 
          installers-regex: '^Blender\_Launcher\_v[\d\.]+\_Windows\_x64\.zip$'
          # or even less conservative: installers-regex: 'Windows\_x64\.zip$'