Skip to content

Build Keeper SDK for .NET #128

Build Keeper SDK for .NET

Build Keeper SDK for .NET #128

Workflow file for this run

name: Build Keeper SDK for .NET
on:
workflow_dispatch:
inputs:
cli:
description: Build CLI package
type: boolean
required: false
default: false
jobs:
build:
runs-on: windows-latest
steps:
- name: Setup product versions
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
shell: powershell
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Load signing certificate
run: |
if (Test-Path -Path certificate.txt) { Remove-Item certificate.txt }
if (Test-Path -Path certificate.pfx) { Remove-Item certificate.pfx }
Set-Content -Path certificate.txt -Value '${{ secrets.PFX_CERT }}'
certutil -decode certificate.txt certificate.pfx
Remove-Item certificate.txt
shell: powershell
- 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.17763.0/x86/signtool.exe' sign /f ..\certificate.pfx /t "http://timestamp.digicert.com" /v /p "${{ secrets.PFX_PASS }}" /d ".NET Keeper SDK" "bin\Release\net472\KeeperSdk.dll"
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /f ..\certificate.pfx /t "http://timestamp.digicert.com" /v /p "${{ secrets.PFX_PASS }}" /d ".NET Keeper SDK" "bin\Release\net6.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
shell: powershell
- name: Build CLI library
working-directory: ./Cli
run: |
if (Test-Path bin) { Remove-Item -Force -Recurse bin }
dotnet build --configuration=Release --no-dependencies
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /f ..\certificate.pfx /t "http://timestamp.digicert.com" /v /p "${{ secrets.PFX_PASS }}" /d ".NET Keeper SDK" "bin\Release\net472\Cli.dll"
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /f ..\certificate.pfx /t "http://timestamp.digicert.com" /v /p "${{ secrets.PFX_PASS }}" /d ".NET Keeper SDK" "bin\Release\net6.0\Cli.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 --no-dependencies
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /f ..\certificate.pfx /t "http://timestamp.digicert.com" /v /p "${{ secrets.PFX_PASS }}" /d ".NET Keeper SDK" "bin\Release\net472\Commander.exe"
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /f ..\certificate.pfx /t "http://timestamp.digicert.com" /v /p "${{ secrets.PFX_PASS }}" /d ".NET Keeper SDK" "bin\Release\net6.0\Commander.dll"
shell: powershell
- name: Zip .Net Framework Commander
working-directory: "./Commander/bin/Release/net472"
run: |
$params = @{
Path = "*.exe", "Commander.exe.config", "*.dll", "x64/", "x86/"
CompressionLevel = "Fastest"
DestinationPath = "Commander-win-${Env:PACKAGE_VERSION}.zip"
}
Compress-Archive @params
shell: powershell
- name: Zip .Net 6.0 Commander
working-directory: "./Commander/bin/Release/net6.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 SDK Nuget artifacts
uses: actions/upload-artifact@v4
with:
name: KeeperSdk-${{ env.PACKAGE_VERSION }}-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: 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/net6.0/Commander-net-${{ env.PACKAGE_VERSION }}.zip
retention-days: 1
- name: Store 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