Skip to content

Commit

Permalink
support submit environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mnich committed May 12, 2024
1 parent 0b9bcfb commit f12f034
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/GithubReleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
update-releasebased:
name: ${{ matrix.id }}
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Test' }}

strategy:
fail-fast: false
Expand Down Expand Up @@ -52,3 +53,4 @@ jobs:
komac-token: ${{ secrets.WINGET_PAT }}
komac-version: latest
custom-fork-owner: damn-good-b0t
submit: ${{ env.SUBMIT_PR }}
2 changes: 2 additions & 0 deletions .github/workflows/update-via-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
update-scriptbased:
name: ${{ matrix.PackageName }}
runs-on: windows-latest
environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Test' }}

strategy:
fail-fast: false
Expand Down Expand Up @@ -78,6 +79,7 @@ jobs:
WebsiteURL: ${{ matrix.WebsiteURL }}
PackageName: ${{ matrix.PackageName }}
With: ${{ matrix.With }}
Submit: ${{ env.SUBMIT_PR }}
run: .\Scripts\generic.ps1


7 changes: 4 additions & 3 deletions Scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ function Update-WingetPackage {
param(
[Parameter(Mandatory = $true)] [string] $WebsiteURL,
[Parameter(Mandatory = $false)] [string] $WingetPackage = ${Env:PackageName},
[Parameter(Mandatory = $false)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac"
[Parameter(Mandatory = $false)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac",
[Parameter(Mandatory = $false)] [switch] $Submit = $false
)
$gitToken = Test-GitHubToken

Expand Down Expand Up @@ -215,7 +216,7 @@ function Update-WingetPackage {
Write-Error "Komac not downloaded"
exit 1
}
.\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" -s -t $gitToken
.\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" ($Submit -eq $true ? "-s" : "") -t $gitToken
}
"WinGetCreate" {
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
Expand All @@ -226,7 +227,7 @@ function Update-WingetPackage {
Write-Error "wingetcreate not downloaded"
exit 1
}
.\wingetcreate.exe update $wingetPackage -s -v $Latest.Version -u "$($Latest.URLs.replace(' ','" "'))" --prtitle $prMessage -t $gitToken
.\wingetcreate.exe update $wingetPackage ($Submit -eq $true ? "-s" : "") -v $Latest.Version -u "$($Latest.URLs.replace(' ','" "'))" --prtitle $prMessage -t $gitToken
}
default {
Write-Error "Invalid value \"$With\" for -With parameter. Valid values are 'Komac' and 'WinGetCreate'"
Expand Down
3 changes: 3 additions & 0 deletions Scripts/generic.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ $params = @{
if($Env:With) {
$params.Add("With", $Env:With)
}
if($Env:Submit) {
$params.Add("Submit", $true)
}

Update-WingetPackage @params

0 comments on commit f12f034

Please sign in to comment.