Build Keeper SDK for .NET #237
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Keeper SDK for .NET | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| cli: | |
| description: Build CLI package | |
| type: boolean | |
| required: false | |
| default: false | |
| biometrics: | |
| description: Build Biometrics package | |
| type: boolean | |
| required: false | |
| default: false | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| outputs: | |
| package-version: ${{ steps.vars.outputs.package_version }} | |
| steps: | |
| - name: Setup product versions | |
| id: vars | |
| run: | | |
| $ErrorView = 'NormalView' | |
| $branch = ($Env:GITHUB_REF -split '/')[2] | |
| $comp = $branch -split '_' | |
| $sdkVersion = $comp[1] | |
| $packageVersion = $sdkVersion | |
| if ($comp[2]) { | |
| $packageVersion = $packageVersion + '-' + $comp[2] | |
| } | |
| $buildVersion = $sdkVersion + '.' + $Env:GITHUB_RUN_NUMBER | |
| echo "SDK_VERSION=${sdkVersion}" >> $Env:GITHUB_ENV | |
| echo "PACKAGE_VERSION=${packageVersion}" >> $Env:GITHUB_ENV | |
| echo "BUILD_VERSION=${buildVersion}" >> $Env:GITHUB_ENV | |
| echo "package_version=${packageVersion}" >> $Env:GITHUB_OUTPUT | |
| shell: powershell | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Setup Code Sign Cert | |
| shell: bash | |
| run: | | |
| echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12 | |
| - name: Set variables | |
| shell: bash | |
| id: variables | |
| run: | | |
| echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV" | |
| echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV" | |
| echo "SM_CLIENT_CERT_FILE=D:/Certificate_pkcs12.p12" >> "$GITHUB_ENV" | |
| echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV" | |
| echo "SM_CODE_SIGNING_CERT_SHA1_HASH=${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}" >> "$GITHUB_ENV" | |
| echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH | |
| echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH | |
| echo "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools" >> $GITHUB_PATH | |
| - name: Setup DigiCert SSM Tools | |
| uses: digicert/ssm-code-signing@b300bb7e8c2ab85257d660fe5b6c6374131ca2ef | |
| - name: Sync Certificates | |
| shell: cmd | |
| env: | |
| KEYPAIR_ALIAS: ${{ secrets.KEYPAIR_ALIAS }} | |
| run: | | |
| smctl healthcheck | |
| smctl windows certsync --keypair-alias=%KEYPAIR_ALIAS% | |
| - name: Restore solution | |
| run: | | |
| dotnet restore KeeperSdk.sln | |
| shell: powershell | |
| - name: Build Keeper SDK Nuget package | |
| working-directory: ./KeeperSdk | |
| run: | | |
| if (Test-Path bin) { Remove-Item -Force -Recurse bin } | |
| dotnet build /P:Configuration=Release /P:Version=${Env:PACKAGE_VERSION} /P:AssemblyVersion=${Env:BUILD_VERSION} /P:FileVersion=${Env:BUILD_VERSION} | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\netstandard2.0\KeeperSdk.dll" | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\net8.0\KeeperSdk.dll" | |
| dotnet pack --no-build --no-restore --no-dependencies /P:Configuration=Release /P:Version=${Env:PACKAGE_VERSION} /P:IncludeSymbols=true /P:SymbolPackageFormat=snupkg | |
| # $cert = Get-Item "Cert:\CurrentUser\My\${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}" | |
| # $sha256 = $cert.GetCertHashString("SHA256") | |
| # dotnet nuget sign --certificate-fingerprint $sha256 --timestamper http://timestamp.digicert.com "bin/Release/Keeper.Sdk.${{ env.PACKAGE_VERSION }}.nupkg" | |
| shell: powershell | |
| - name: Store SDK Nuget artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: KeeperSdk-Nuget-Package | |
| path: | | |
| KeeperSdk/bin/Release/Keeper.Sdk.${{ env.PACKAGE_VERSION }}.nupkg | |
| KeeperSdk/bin/Release/Keeper.Sdk.${{ env.PACKAGE_VERSION }}.snupkg | |
| retention-days: 1 | |
| - name: Build CLI library | |
| working-directory: ./Cli | |
| run: | | |
| if (Test-Path bin) { Remove-Item -Force -Recurse bin } | |
| dotnet build --configuration=Release | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\net472\Cli.dll" | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\netstandard2.0\Cli.dll" | |
| dotnet pack --no-build --no-restore --no-dependencies --configuration=Release /P:IncludeSymbols=true /P:SymbolPackageFormat=snupkg | |
| shell: powershell | |
| - name: Build Biometrics library | |
| working-directory: ./KeeperBiometrics | |
| run: | | |
| if (Test-Path bin) { Remove-Item -Force -Recurse bin } | |
| dotnet build --configuration=Release | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\net472\KeeperBiometrics.dll" | |
| dotnet pack --no-build --no-restore --no-dependencies --configuration=Release /P:IncludeSymbols=true /P:SymbolPackageFormat=snupkg | |
| shell: powershell | |
| - name: Build .Net Commander | |
| working-directory: ./Commander | |
| run: | | |
| if (Test-Path bin) { Remove-Item -Force -Recurse bin } | |
| dotnet build --configuration=Release | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\net472\Commander.exe" | |
| & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/signtool.exe' sign /debug /v /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /d ".NET Keeper SDK" "bin\Release\net8.0\Commander.dll" | |
| shell: powershell | |
| - name: Zip .Net Framework Commander | |
| working-directory: "./Commander/bin/Release/net472" | |
| run: | | |
| $params = @{ | |
| Path = "*.exe", "*.dll", "Commander.exe.config" | |
| CompressionLevel = "Fastest" | |
| DestinationPath = "Commander-win-${Env:PACKAGE_VERSION}.zip" | |
| } | |
| Compress-Archive @params | |
| shell: powershell | |
| - name: Zip .Net 8.0 Commander | |
| working-directory: "./Commander/bin/Release/net8.0" | |
| run: | | |
| $params = @{ | |
| Path = "*.dll", "Commander.dll.config", "Commander.deps.json", "runtimes/", "Commander.runtimeconfig.json" | |
| CompressionLevel = "Fastest" | |
| DestinationPath = "Commander-net-${Env:PACKAGE_VERSION}.zip" | |
| } | |
| Compress-Archive @params | |
| shell: powershell | |
| - name: Store Commander artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Commander-win-${{ env.PACKAGE_VERSION }} | |
| path: Commander/bin/Release/net472/Commander-win-${{ env.PACKAGE_VERSION }}.zip | |
| retention-days: 1 | |
| - name: Store Commander artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Commander-net-${{ env.PACKAGE_VERSION }} | |
| path: Commander/bin/Release/net8.0/Commander-net-${{ env.PACKAGE_VERSION }}.zip | |
| retention-days: 1 | |
| - name: Store Cli artifacts | |
| if: ${{ inputs.cli }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Cli | |
| path: | | |
| Cli/bin/Release/Keeper.Cli.*.nupkg | |
| Cli/bin/Release/Keeper.Cli.*.snupkg | |
| retention-days: 1 | |
| - name: Store Biometrics artifacts | |
| if: ${{ inputs.biometrics }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: KeeperBiometrics | |
| path: | | |
| KeeperBiometrics/bin/Release/Keeper.Biometrics.*.nupkg | |
| KeeperBiometrics/bin/Release/Keeper.Biometrics.*.snupkg | |
| retention-days: 1 | |
| publish: | |
| runs-on: windows-latest | |
| needs: build | |
| environment: prod | |
| env: | |
| PACKAGE_VERSION: ${{ needs.build.outputs.package-version }} | |
| steps: | |
| - name: Download Nuget package | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: KeeperSdk-Nuget-Package | |
| path: nuget | |
| - name: Publish to Nuget repo | |
| working-directory: nuget | |
| run: | | |
| dotnet nuget push Keeper.Sdk.${{ env.PACKAGE_VERSION }}.nupkg -k "${{ secrets.NUGET_PUBLISH_KEY }}" -s https://api.nuget.org/v3/index.json | |
| shell: powershell |