Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,17 @@ jobs:
shell: pwsh
env:
REF_NAME: ${{ github.ref_name }}
REF_TYPE: ${{ github.ref_type }}
DOTNET_NOLOGO: "true"
run: |
$refName = $env:REF_NAME
if ($refName -match '^v\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$') {
$version = $refName.TrimStart('v')
$tag = $refName
$version = (& dotnet msbuild ThreadPilot.csproj -nologo -getProperty:Version | Out-String).Trim()
if ($LASTEXITCODE -ne 0 -or $version -notmatch '^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$') {
throw "Unable to resolve a valid release version from ThreadPilot.csproj."
}
else {
[xml]$project = Get-Content "ThreadPilot.csproj"
$version = $project.Project.PropertyGroup.Version
if ([string]::IsNullOrWhiteSpace($version)) {
throw "Unable to resolve version from tag or ThreadPilot.csproj"
}

$tag = "v$version"
$tag = "v$version"
if ($env:REF_TYPE -eq 'tag' -and $env:REF_NAME -cne $tag) {
throw "Tag '$env:REF_NAME' does not match project version '$version'."
}

$prerelease = $version.Contains('-').ToString().ToLowerInvariant()
Expand Down
24 changes: 21 additions & 3 deletions build/submit-winget-pr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (-not (Test-Path -LiteralPath $ManifestSourcePath)) {
throw "Manifest source path not found: $ManifestSourcePath"
}

$manifestFiles = Get-ChildItem -LiteralPath $ManifestSourcePath -Recurse -File -Filter '*.yaml'
$manifestFiles = @(Get-ChildItem -LiteralPath $ManifestSourcePath -Recurse -File -Filter '*.yaml')
if (-not $manifestFiles -or $manifestFiles.Count -eq 0) {
throw "No winget manifest files found under $ManifestSourcePath"
}
Expand Down Expand Up @@ -64,6 +64,9 @@ try {

$branch = "threadpilot-$Version"
& git checkout -B $branch
if ($LASTEXITCODE -ne 0) {
throw 'Failed to prepare the WinGet submission branch.'
}

$packageParts = $PackageIdentifier.Split('.')
if ($packageParts.Count -lt 2) {
Expand Down Expand Up @@ -91,18 +94,33 @@ try {
}

& git add $targetDir
& git status --short
if ($LASTEXITCODE -ne 0) {
throw 'Failed to stage the WinGet manifests.'
}

$hasChanges = (& git diff --cached --name-only | Out-String).Trim()
if ($LASTEXITCODE -ne 0) {
throw 'Failed to inspect staged WinGet manifests.'
}
if ([string]::IsNullOrWhiteSpace($hasChanges)) {
Write-Host "No manifest changes detected for $Version. Nothing to submit."
exit 0
}

& git commit -m "Add $PackageIdentifier version $Version"
& git push -u origin $branch --force
if ($LASTEXITCODE -ne 0) {
throw 'Failed to commit the WinGet manifests.'
}

& git push -u origin $branch --force-with-lease
if ($LASTEXITCODE -ne 0) {
throw 'Failed to push the WinGet submission branch.'
}

$existingPr = (& gh pr list --repo microsoft/winget-pkgs --state open --head $branch --author $ForkOwner --json number | Out-String).Trim()
if ($LASTEXITCODE -ne 0) {
throw 'Failed to check for an existing WinGet pull request.'
}
if (-not [string]::IsNullOrWhiteSpace($existingPr) -and $existingPr -ne '[]') {
Write-Host "Winget PR already exists for branch $branch."
exit 0
Expand Down
Loading