.NET SDK #234
This file contains 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: .NET SDK | |
on: | |
push: | |
branches: [main] | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: [main] | |
schedule: | |
- cron: "0 3 * * *" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
env: | |
Solution_Name: Acrolinx.Net/Acrolinx.Net.sln | |
Test_Project_Path: Acrolinx.Net/Acrolinx.Net.Tests/Acrolinx.Net.Tests.csproj | |
BUILD_NUMBER: ${{ github.run_number }} | |
Configuration: Release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8 | |
- name: Setup MSBuild.exe | |
uses: microsoft/setup-msbuild@v2 | |
- name: Restore the application | |
run: dotnet restore $env:Solution_Name | |
- name: Build SDK | |
shell: powershell | |
run: | | |
$version = git describe --abbrev=0 --tags | |
$version = $version.substring(1) + "." + $env:BUILD_NUMBER | |
dotnet build $env:Solution_Name --configuration $env:Configuration -p:Version=$version -p:Platform="Any CPU" | |
- name: run Test project | |
run: | | |
'& dotnet test Acrolinx.Net\Acrolinx.Net.Tests\bin\Release\net7.0\Acrolinx.Net.Tests.dll -l:trx;LogFileName=Acrolinx.Net\Acrolinx.Net\bin\Release\testResult.xml' | |
- name: Setup Certificate | |
if: ${{(startsWith(github.ref, 'refs/tags/')) }} | |
run: echo "${{secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12 | |
shell: bash | |
- name: Set variables | |
id: variables | |
if: ${{(startsWith(github.ref, 'refs/tags/')) }} | |
run: | | |
echo "::set-output name=version::${GITHUB_REF#refs/tags/v}" | |
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 "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 | |
shell: bash | |
- name: Setup SSM KSP on windows latest | |
if: ${{(startsWith(github.ref, 'refs/tags/')) }} | |
run: | | |
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi | |
msiexec /i smtools-windows-x64.msi /quiet /qn | |
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user >nul 2>&1 | |
smksp_cert_sync.exe >nul 2>&1 | |
shell: cmd | |
- name: Signing using Signtool | |
if: ${{(startsWith(github.ref, 'refs/tags/')) }} | |
env: | |
BINARY: "Acrolinx.Net/Acrolinx.Net/bin/Release/netstandard2.0/Acrolinx.Net.dll" | |
run: | | |
signtool.exe sign /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $env:BINARY | |
signtool.exe verify /v /pa $env:BINARY | |
- name: Patch version number in nuget spec | |
run: ((Get-Content -path .\Acrolinx.Net\Acrolinx.Net\Acrolinx.Net.nuspec -Raw) -replace '\$version\$',"`$version`$") | Set-Content -Path .\Acrolinx.Net\Acrolinx.Net\Acrolinx.Net.nuspec | |
- name: Create NuGet Package | |
env: | |
PROJECT_FILE_PATH: Acrolinx.Net\Acrolinx.Net\Acrolinx.Net.csproj | |
shell: powershell | |
run: | | |
$version = git describe --abbrev=0 --tags | |
$version = $version.substring(1) + "." + $env:BUILD_NUMBER | |
dotnet pack ".\Acrolinx.Net\Acrolinx.Net\Acrolinx.Net.csproj" -p:Version=$version --configuration=Release --include-symbols --output ./ | |
- name: Add nuget source to publish on GitHub registry | |
run: nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/acrolinx/index.json" -UserName ${{ github.actor }} -Password ${{ secrets.GITHUB_TOKEN }} | |
- name: Push nuget package to GitHub | |
shell: powershell | |
if: ${{ (github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/')) }} | |
run: | | |
$NugetPackage = Get-ChildItem .\*.nupkg -Exclude *.symbols.nupkg -name | |
Write-Host "NuGet package name is : " $NugetPackage | |
nuget push $NugetPackage -source "GitHub" -ApiKey ${{ secrets.GITHUB_TOKEN }} | |
- name: Push nuget package to Nuget.org (only for tags) | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
$NugetPackage = Get-ChildItem .\*.nupkg -Exclude *.symbols.nupkg -name | |
Write-Host "Pushing to Nuget.org. NuGet package name is : " $NugetPackage | |
nuget push $NugetPackage ${{ secrets.NUGET_API_KEY }} -Source nuget.org -Timeout 600 | |
- name: Create a release in GitHub (only for tags) | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
*.nupkg | |
Acrolinx.Net/Acrolinx.Net/bin/Release/netstandard2.0/ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Restore nuget spec | |
run: ((Get-Content -path .\Acrolinx.Net\Acrolinx.Net\Acrolinx.Net.nuspec -Raw) -replace ('\$version\$-'+$env:BUILD_NUMBER), "`$version`$") | Set-Content -Path .\Acrolinx.Net\Acrolinx.Net\Acrolinx.Net.nuspec | |
- name: Archive GitHub Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dotNetSDK_Artifacts | |
path: | | |
*.nupkg | |
Acrolinx.Net/Acrolinx.Net/bin/Release/netstandard2.0/ |