Skip to content

Commit

Permalink
winget deployment added to the release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
lowleveldesign committed Apr 12, 2024
1 parent bd8e422 commit 480d942
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 15 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 15 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,35 @@ jobs:
prerelease: true
files: procgov.zip

- name: Publish to winget
run: ./winget-publish.ps1

- name: Copy the binary to Chocolatey path
run: |
Copy-Item artifacts\procgov32.exe choco\tools
Copy-Item artifacts\procgov32.pdb choco\tools
Copy-Item artifacts\procgov64.exe choco\tools
Copy-Item artifacts\procgov64.pdb choco\tools
Copy-Item artifacts\procgov32.exe .choco\tools
Copy-Item artifacts\procgov32.pdb .choco\tools
Copy-Item artifacts\procgov64.exe .choco\tools
Copy-Item artifacts\procgov64.pdb .choco\tools
- run: |
Invoke-WebRequest -OutFile Print-FileHashes.ps1 https://gist.githubusercontent.com/lowleveldesign/f1afd42662ee8dabe07cf8cbfe25e6a1/raw/Print-FileHashes.ps1
"## procgov32.exe" >> choco\tools\VERIFICATION.txt
./Print-FileHashes.ps1 -FilePath choco\tools\procgov32.exe >> choco\tools\VERIFICATION.txt
"" >> choco\tools\VERIFICATION.txt
"## procgov64.exe" >> choco\tools\VERIFICATION.txt
./Print-FileHashes.ps1 -FilePath choco\tools\procgov64.exe >> choco\tools\VERIFICATION.txt
"## procgov32.exe" >> .choco\tools\VERIFICATION.txt
./Print-FileHashes.ps1 -FilePath .choco\tools\procgov32.exe >> .choco\tools\VERIFICATION.txt
"" >> .choco\tools\VERIFICATION.txt
"## procgov64.exe" >> .choco\tools\VERIFICATION.txt
./Print-FileHashes.ps1 -FilePath .choco\tools\procgov64.exe >> .choco\tools\VERIFICATION.txt
- name: Build Chocolatey package
run: choco pack
working-directory: choco
working-directory: .choco

- uses: actions/upload-artifact@v4
with:
name: procgov-pkg
path: choco\procgov.*.nupkg
path: .choco\procgov.*.nupkg

- name: Release Chocolatey package
run: choco push $(Resolve-Path "procgov.*.nupkg") -s https://push.chocolatey.org/ -k "$env:CHOCO_KEY"
env:
CHOCO_KEY: ${{ secrets.CHOCO_KEY }}
working-directory: choco
working-directory: .choco
24 changes: 24 additions & 0 deletions .winget/LowLevelDesign.ProcessGovernor.installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Created using wingetcreate 1.6.1.0
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.6.0.schema.json

PackageIdentifier: LowLevelDesign.ProcessGovernor
PackageVersion: ###VERSION###
InstallerType: zip
NestedInstallerType: portable
Installers:
- Architecture: x64
NestedInstallerFiles:
- RelativeFilePath: procgov64.exe
PortableCommandAlias: procgov64
- RelativeFilePath: procgov32.exe
PortableCommandAlias: procgov32
InstallerUrl: https://github.com/lowleveldesign/process-governor/releases/download/###TAG###/procgov.zip
InstallerSha256: ###FILE_HASH###
- Architecture: x86
NestedInstallerFiles:
- RelativeFilePath: procgov32.exe
PortableCommandAlias: procgov32
InstallerUrl: https://github.com/lowleveldesign/process-governor/releases/download/###TAG###/procgov.zip
InstallerSha256: ###FILE_HASH###
ManifestType: installer
ManifestVersion: 1.6.0
12 changes: 12 additions & 0 deletions .winget/LowLevelDesign.ProcessGovernor.locale.en-US.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Created using wingetcreate 1.6.1.0
# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.6.0.schema.json

PackageIdentifier: LowLevelDesign.ProcessGovernor
PackageVersion: ###VERSION###
PackageLocale: en-US
Publisher: Sebastian Solnica
PackageName: procgov
License: MIT License
ShortDescription: Process Governor allows you to put various limits on Windows processes.
ManifestType: defaultLocale
ManifestVersion: 1.6.0
8 changes: 8 additions & 0 deletions .winget/LowLevelDesign.ProcessGovernor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Created using wingetcreate 1.6.1.0
# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.6.0.schema.json

PackageIdentifier: LowLevelDesign.ProcessGovernor
PackageVersion: ###VERSION###
DefaultLocale: en-US
ManifestType: version
ManifestVersion: 1.6.0
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ This application allows you to set constraints on Windows processes. It uses [a

## Installation

You may download the latest version binaries from the [release page](https://github.com/lowleveldesign/process-governor/releases) or install it with [Chocolatey](https://chocolatey.org/):
You may download the latest version binaries from the [release page](https://github.com/lowleveldesign/process-governor/releases) or install it with [Chocolatey](https://chocolatey.org/) or [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/):

```
> choco install procgov
```shell
choco install procgov
# or
winget install procgov
```

:warning: Remember to use procgov32.exe with 32-bit apps and procgov64.exe with 64-bit ones.
Expand Down
20 changes: 20 additions & 0 deletions winget-publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$ErrorActionPreference="Stop"

if (-not (Test-Path -Path "wingetcreate.exe")) {
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-create/releases/latest/download/wingetcreate.exe" -OutFile "wingetcreate.exe"
}

$BuildNumber = $env:GITHUB_RUN_NUMBER % [int16]::MaxValue
$Tag = [System.IO.Path]::GetFileName("$env:GITHUB_REF")
if (-not ($Tag -match "^(\d+\.\d+\.\d+)(\-.+)?$")) { Write-Error "Invalid tag name for the release." }
$Version = "$($Matches[1]).$buildNumber"

$FileHash = $(Get-FileHash -Algorithm SHA256 "procgov.zip").Hash
Get-ChildItem -Path ".winget" -Filter *.yaml | Foreach-Object -Process {
$FilePath = $_.FullName
$Content = Get-Content -Encoding UTF8 $FilePath
$Content = $Content -replace "###VERSION###", $Version -replace "###FILE_HASH###", $FileHash -replace "###TAG###", $Tag
Set-Content -Encoding Utf8 -Path $FilePath -Value $Content
}

.\wingetcreate.exe submit -p "procgov v$Version" -t "$env:WINGET_GH_TOKEN" .winget

0 comments on commit 480d942

Please sign in to comment.