Skip to content

Commit

Permalink
ci: Set actual commit sha to PackageProjectUrl property when packing …
Browse files Browse the repository at this point in the history
…in github action.
  • Loading branch information
s2quake committed Jun 29, 2024
1 parent be1b6cc commit b1578cd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/scripts/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ param (
[ValidateScript({ $_ -ge 0 })]
[int]$PullRequestNumber = 0,
[ValidateScript({ ($_ -eq "") -or (Test-Path $_) })]
[string]$KeyPath = ""
[string]$KeyPath = "",
[string]$CommitSHA = ""
)

$namespaces = @{
Expand All @@ -18,8 +19,16 @@ if ($null -eq $result) {
Write-Host "File version not found"
exit 1
}

$fileVersion = $result.Node.InnerText

$packageProjectUrlPath = "/ns:Project/ns:PropertyGroup/ns:PackageProjectUrl"
$result = Select-Xml -Path $propsPath -Namespace $namespaces -XPath $packageProjectUrlPath
if ($null -eq $result) {
Write-Host "Package project URL not found"
exit 1
}
$packageProjectUrl = $result.Node.InnerText

$KeyPath = $KeyPath ? $(Resolve-Path -Path $KeyPath) : ""
$OutputPath = $OutputPath ? [System.IO.Path]::GetFullPath($OutputPath) : ""
$keyPathExits = Test-Path -Path $KeyPath
Expand All @@ -30,6 +39,7 @@ $options = @(
$PullRequestNumber ? "--version-suffix pr.$PullRequestNumber" : ""
$keyPathExits ? "-p:TreatWarningsAsErrors=true" : ""
$keyPathExits ? "-p:AssemblyOriginatorKeyFile='$KeyPath'" : ""
$CommitSHA ? "-p:PackageProjectUrl='$packageProjectUrl/tree/$CommitSHA'" : ""
) | Where-Object { $_ }

Invoke-Expression -Command "dotnet pack $($options -join " ")"

0 comments on commit b1578cd

Please sign in to comment.