Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Action to update winget package on release for Triplex.Triplex #218

Closed
jo-chemla opened this issue Sep 11, 2024 · 11 comments
Closed

Comments

@jo-chemla
Copy link
Contributor

jo-chemla commented Sep 11, 2024

I've just submitted a PR - now merged 🚀 - microsoft/winget-pkgs#172824 so that Triplex had been listed and can be installed on windows via winget install triplex or winget install Triplex.Triplex. I've used Komac to create the manifest file, crediting your github profile, name etc.

It could be useful to add a Github Action workflow on this repo so that the winget package gets updated on every github release. Having a github action do it on every release would make sure the winget repo always has the latest version available.
Note I did the same request for github action workflow for BlenderLauncher which I also added to winget-pkgs, see Victor-IX/Blender-Launcher-V2#141.

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 }}

Note installer might install portable app to C:\Users\username\AppData\Local\Microsoft\WinGet\Packages and not add it to start-menu entries, see microsoft/winget-cli#2299

@itsdouges
Copy link
Collaborator

Oh hey mate, can you tell me more about what winget is? Is it like homebrew for macOS?

@jo-chemla
Copy link
Contributor Author

Exactly, it's the default windows package manager, that has shipped natively with windows for a few years. Makes it easier to install a bunch of apps in one command, or also rely on apps like UnigetUI/formerly WingetUI. Helper webapps like winstall.app make it easier to package lists.

@itsdouges
Copy link
Collaborator

Interesting! TIL. @krispya have you used it?

Is raising a PR the canonical way of getting updates into it? Ideally the flow would be:

  • Release is created on this repo
  • CI action runs
  • We push out metadata associated with the release

@itsdouges
Copy link
Collaborator

Note installer might install portable app to C:\Users\username\AppData\Local\Microsoft\WinGet\Packages and not add it to start-menu entries, see microsoft/winget-cli#2299

Did you cross this out because Triplex doesn't currently ship a portable install? For clarity I did that because I want to make sure folks continue getting updates.

@itsdouges
Copy link
Collaborator

itsdouges commented Sep 11, 2024

I'd be happy to accept a contribution to this repo to set this all up. As a side have you been added to the vscode early adopters channel? What's your Discord name I'll add you.

@jo-chemla
Copy link
Contributor Author

jo-chemla commented Sep 11, 2024

Thabks for the feedback.

  • the PR is usually the way to publish the initial package to winget-pkgs. Then pushing updates is usually done via a github action like winget-releaser, see the second code block, which watches your github release and pushes the new version, with release notes, version bump etc to winget-pkgs. So the flow you described is exactly it.
  • sure, here is my discord handle jochemla for the vscode early adopters channel!
  • I crossed it out because the Triplex package manifest I designed and tested with winget uses your installer which installs at on a global level, in AppData, and that the start menu entry is actually created. I've only face that issue of no start menu creation for portable installs, so it does not concern triplex!

@itsdouges
Copy link
Collaborator

Come join first https://discord.gg/22fQ9acT

@itsdouges
Copy link
Collaborator

Want to put up a PR to add the Github action? Where do we get a WINGET_TOKEN from?

jo-chemla referenced this issue in jo-chemla/triplex Sep 12, 2024
Following issue https://github.com/try-triplex/triplex/issues/218
Uses [winget-releaser](https://github.com/vedantmgoyal9/winget-releaser)
I suggest a `Classic Github Token` with `public_repo` scope is created, following [this link](https://github.com/settings/tokens/new), for the user [triplex-bot](https://github.com/triplex-bot), then the Token can be added to the triplex repo as a secret named `WINGET_ACC_TOKEN`. See below, that user also will have to fork the winget-pkgs repository.

Notes:
> You will need to create a *classic* Personal Access Token (PAT) with `public_repo` scope. New fine-grained PATs aren't supported by the action. Review trytriplex#172 for information.
> Fork [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs) under the same account/organization as the project's repository. If you are forking winget-pkgs on a different account (e.g. bot/personal account), you can use the fork-user input to specify the username of the account where the fork is present.
@jo-chemla
Copy link
Contributor Author

Just submitted this as a PR https://github.com/try-triplex/triplex/pull/220
With instructions as to how to get the github classic token in the PR thread.

And also I just joined the triplex discord - although I'm not using it often!

@itsdouges
Copy link
Collaborator

Done! Thanks mate.

@jo-chemla
Copy link
Contributor Author

jo-chemla commented Sep 24, 2024

Glad it worked!
Nice to see these auto-PRs by triplex-bot to winget-pkgs repo for every new triplex release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants