From b6402b1424bca23e64718a910d5e793877001ae0 Mon Sep 17 00:00:00 2001 From: Max Ustinov Date: Wed, 27 Mar 2024 09:47:10 -0700 Subject: [PATCH] KSM .NET SDK: GHA to publish strong named binary: - updated copyright year to 2024 - updated to the publish.nuget.strong.named.yml - updates to the publish.nuget.yml --- .github/workflows/test.publish.nuget.yml | 28 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.publish.nuget.yml b/.github/workflows/test.publish.nuget.yml index 5cf933d9..72d19c95 100644 --- a/.github/workflows/test.publish.nuget.yml +++ b/.github/workflows/test.publish.nuget.yml @@ -41,9 +41,22 @@ jobs: run: | $snPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe" $snkPath = "${{ github.workspace }}\sdk\dotNet\SecretsManager\sgKSM.snk" - $publicKeyInfo = & $snPath -Tp $snkPath - $publicKey = $publicKeyInfo | Select-String "Public Key:" -Context 0, 1 | ForEach-Object { $_.Context.PostContext[0] } - $publicKey = $publicKey -replace "\s", "" # Remove any whitespace from the public key string + $publicKeyPath = "${{ github.workspace }}\sdk\dotNet\SecretsManager\sgKSM.pub" + & $snPath -p $snkPath $publicKeyPath + $publicKeyInfo = & $snPath -tp $publicKeyPath + Write-Output "Public Key Info: START" + Write-Output "$publicKeyInfo" + Write-Output "Public Key Info: END" + + # Extract the full public key + $publicKey = $publicKeyInfo -split "`n" | Where-Object { $_ -match "^[a-f0-9]{32}$" } -join "" + + if (-not $publicKey) { + Write-Error "Failed to extract the full public key." + exit 1 + } + + Write-Output "Extracted Public Key: $publicKey" $filePath = "${{ github.workspace }}\sdk\dotNet\SecretsManager\SecretsManagerClient.cs" (Get-Content $filePath) -replace '\[assembly: InternalsVisibleTo\("SecretsManager.Test.Core"\)\]', "[assembly: InternalsVisibleTo(`"SecretsManager.Test.Core, PublicKey=$publicKey`")]" | Set-Content $filePath Write-Output "First 20 lines of the modified SecretsManagerClient.cs:" @@ -64,10 +77,6 @@ jobs: Copy-Item -Path "${{ github.workspace }}\sdk\dotNet\SecretsManager\sgKSM.snk" -Destination "${{ github.workspace }}\sdk\dotNet\SecretsManager.Test.Core\sgKSM.snk" Get-ChildItem "${{ github.workspace }}\sdk\dotNet\SecretsManager.Test.Core\" - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 - - name: Build working-directory: ${{ github.workspace }}\sdk\dotNet\SecretsManager\ run: | @@ -91,3 +100,8 @@ jobs: run: | Get-ChildItem ".\bin\Release\" dotnet nuget push ".\bin\Release\*.nupkg" --api-key ${{steps.ksmsecrets.outputs.NUGET_AUTH_TOKEN}} --source https://api.nuget.org/v3/index.json + + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 +