diff --git a/.github/scripts/pack.ps1 b/.github/scripts/pack.ps1
new file mode 100755
index 0000000..5a131d9
--- /dev/null
+++ b/.github/scripts/pack.ps1
@@ -0,0 +1,35 @@
+#!/usr/local/bin/pwsh
+param (
+ [ValidateScript({ ($_ -eq "") -or !(Test-Path $_ -PathType Leaf) })]
+ [string]$OutputPath = "",
+ [ValidateScript({ $_ -ge 0 })]
+ [int]$PullRequestNumber = 0,
+ [ValidateScript({ ($_ -eq "") -or (Test-Path $_) })]
+ [string]$KeyPath = ""
+)
+
+$namespaces = @{
+ ns = "http://schemas.microsoft.com/developer/msbuild/2003"
+}
+$propsPath = "Directory.Build.props"
+$fileVersionPath = "/ns:Project/ns:PropertyGroup/ns:FileVersion"
+$result = Select-Xml -Path $propsPath -Namespace $namespaces -XPath $fileVersionPath
+if ($null -eq $result) {
+ Write-Host "File version not found"
+ exit 1
+}
+
+$fileVersion = $result.Node.InnerText
+$KeyPath = $KeyPath ? $(Resolve-Path -Path $KeyPath) : ""
+$OutputPath = $OutputPath ? [System.IO.Path]::GetFullPath($OutputPath) : ""
+$keyPathExits = Test-Path -Path $KeyPath
+
+$options = @(
+ $OutputPath ? "-o '$OutputPath'" : ""
+ "-p:FileVersion='$fileVersion'"
+ $PullRequestNumber ? "--version-suffix pr.$PullRequestNumber" : ""
+ $keyPathExits ? "-p:TreatWarningsAsErrors=true" : ""
+ $keyPathExits ? "-p:AssemblyOriginatorKeyFile='$KeyPath'" : ""
+) | Where-Object { $_ }
+
+Invoke-Expression -Command "dotnet pack $($options -join " ")"
diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml
index b3efb99..d37b1f3 100644
--- a/.github/workflows/pack.yml
+++ b/.github/workflows/pack.yml
@@ -2,7 +2,12 @@ name: Pack
on:
pull_request:
-
+ push:
+ branches:
+ - main
+ tags:
+ - "*"
+
jobs:
pack:
runs-on: ubuntu-latest
@@ -12,8 +17,9 @@ jobs:
with:
dotnet-version: 8.0.100
- run: echo "${{ secrets.SNK_FILE }}" | base64 --decode > private.snk
- - run: |
- dotnet pack \
- -o pack \
- -p:TreatWarningsAsErrors=true \
- -p:AssemblyOriginatorKeyFile=$(pwd)/private.snk
+ - if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ .github/scripts/pack.ps1 `
+ -PullRequestNumber ${{ github.event.pull_request.number }} `
+ -KeyPath "$pwd/private.snk"
+ shell: pwsh
diff --git a/Directory.Build.props b/Directory.Build.props
index e0f7e40..0550a44 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -57,7 +57,8 @@ SOFTWARE. -->
Copyright (c) 2024 Jeesu Choi
grpc-based communication library for crema project
s2quake
- $(FileVersion)
+ $(FileVersion)
+ $(FileVersion)-$(VersionSuffix)
https://github.com/s2quake/communication
LICENSE.md
README.md
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 229c68f..513c4e2 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -29,11 +29,6 @@ SOFTWARE. -->
$(PublishDir)
$(DesiredPublishDirTemp)
-
-
- $(FileVersion)-$(TargetFramework)
-
-
$([System.IO.Path]::Combine($(DesiredPublishDir),$(PublishName)))