From 440912c71d5b2d48c1c42010f0d495bb666cef52 Mon Sep 17 00:00:00 2001 From: s2quake Date: Sat, 29 Jun 2024 16:51:56 +0900 Subject: [PATCH 1/2] ci: Set actual commit sha to PackageProjectUrl property when packing in github action. --- .github/scripts/pack.ps1 | 14 ++++++++++++-- .github/workflows/pack.yml | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/scripts/pack.ps1 b/.github/scripts/pack.ps1 index 5a131d9..ceb6cb0 100755 --- a/.github/scripts/pack.ps1 +++ b/.github/scripts/pack.ps1 @@ -5,7 +5,8 @@ param ( [ValidateScript({ $_ -ge 0 })] [int]$PullRequestNumber = 0, [ValidateScript({ ($_ -eq "") -or (Test-Path $_) })] - [string]$KeyPath = "" + [string]$KeyPath = "", + [string]$CommitSHA = "" ) $namespaces = @{ @@ -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 @@ -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 " ")" diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml index 6cbf3bf..662887a 100644 --- a/.github/workflows/pack.yml +++ b/.github/workflows/pack.yml @@ -34,10 +34,12 @@ jobs: Remove-Item -Force -Recurse pack -ErrorAction SilentlyContinue + $commitSHA = "$(git log -1 --pretty=%H)" .github/scripts/pack.ps1 ` -OutputPath "pack" ` -PullRequestNumber $matches[1] ` - -KeyPath "$pwd/private.snk" + -KeyPath "$pwd/private.snk" ` + -CommitSHA $commitSHA Get-ChildItem -Path pack -Filter "*.nupkg" | ForEach-Object { dotnet nuget push ` From 41ba089ec264124f457f5100da1eb07c404e9bbf Mon Sep 17 00:00:00 2001 From: s2quake Date: Sat, 29 Jun 2024 16:54:11 +0900 Subject: [PATCH 2/2] chore: Changelog. --- CHANGES.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 93a08e4..3afcf64 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,9 +6,11 @@ Communication changes To be released. -* Improve CI to make sure minimal checks are done before merge [[#26]] +* Improve CI to make sure minimal checks are done before merge [[#26]] +* Set actual sha to PackageProjectUrl property [[#27]] -[26]: https://github.com/s2quake/communication/pull/26 +[#26]: https://github.com/s2quake/communication/pull/26 +[#27]: https://github.com/s2quake/communication/pull/27 2.0.2