Migrate to GitHub actions #11
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: Middleware CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build-and-test: | |
runs-on: windows-latest | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
solution: [ "queue" ] | |
# solution: [ "queue", "scu-at", "scu-de", "scu-it", "scu-es" ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
filter: tree:0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '8.x' | |
- name: Install .NET Framework 4.6.1 | |
run: choco install netfx-4.6.1-devpack -y | |
- name: Install NuGet | |
run: choco install nuget.commandline -y | |
- name: Install MinVer | |
run: dotnet tool install --global minver-cli --version 5.0.0 | |
- name: Restore dependencies | |
run: dotnet restore (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName | |
- name: Build | |
run: dotnet build (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName --configuration Release --no-restore | |
- name: Find Unit Test Projects | |
id: unit_test_projects | |
run: | | |
"PROJECTS=$((Get-ChildItem -Path ./${{ matrix.solution }} -Recurse -Filter '*.UnitTest.csproj' | % { $_.FullName }) -join ';')" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
- name: Find Integration Test Projects | |
id: integration_test_projects | |
run: | | |
"PROJECTS=$((Get-ChildItem -Path ./${{ matrix.solution }} -Recurse -Filter '*.IntegrationTest.csproj' | % { $_.FullName }) -join ';')" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
- name: Find Acceptance Test Projects | |
id: acceptance_test_projects | |
run: | | |
"PROJECTS=$((Get-ChildItem -Path ./${{ matrix.solution }} -Recurse -Filter '*.AcceptanceTest.csproj' | % { $_.FullName }) -join ';')" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
- name: Run Unit Tests | |
env: | |
PROJECTS: ${{ steps.unit_test_projects.outputs.PROJECTS }} | |
if: steps.unit_test_projects.outputs.PROJECTS != '' | |
run: | | |
$projects = "${{ steps.unit_test_projects.outputs.PROJECTS }}".Split(";") | |
foreach ($project in $projects) { | |
dotnet test $project --no-build --verbosity normal --configuration Release | |
} | |
- name: Run Integration Tests | |
if: steps.integration_test_projects.outputs.PROJECTS != '' | |
run: | | |
$projects = "${{ steps.integration_test_projects.outputs.PROJECTS }}".Split(";") | |
foreach ($project in $projects) { | |
dotnet test $project --no-build --verbosity normal --configuration Release | |
} | |
- name: Run Acceptance Tests | |
if: steps.acceptance_test_projects.outputs.PROJECTS != '' | |
run: | | |
$projects = "${{ steps.acceptance_test_projects.outputs.PROJECTS }}".Split(";") | |
foreach ($project in $projects) { | |
dotnet test $project --no-build --verbosity normal --configuration Release | |
} | |
- name: Filter files for codesigning | |
id: filter_files_for_codesigning | |
run: | | |
$files = Get-ChildItem -Path .\\${{ matrix.solution }} -Filter "fiskaltrust.*.dll" -Recurse | Select-Object -ExpandProperty FullName | |
$filesList = $files -join "`n" | |
# Multiline outputs required a unique delimiter | |
$EOF = -join (1..15 | ForEach {[char]((48..57)+(65..90)+(97..122) | Get-Random)}) | |
"FILES<<$EOF" | Out-File -FilePath $env:GITHUB_ENV -Append | |
$filesList | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
"$EOF" | Out-File -FilePath $env:GITHUB_ENV -Append | |
Write-Output "::set-output name=filtered_files::$filesList" | |
- name: Sign binaries | |
uses: dlemstra/code-sign-action@v1 | |
with: | |
certificate: '${{ secrets.SIGNING_CERTIFICATE }}' | |
password: '${{ secrets.SIGNING_CERT_PASSWORD }}' | |
files: ${{ steps.filter_files_for_codesigning.outputs.filtered_files }} | |
- name: Publish v1 Nuget packages | |
run: dotnet pack (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName --no-restore --configuration Release --output ./publish/packages-v1 | |
- name: Publish v2 zip packages | |
run: | | |
$version = minver --verbosity error | |
New-Item -ItemType Directory -Force -Path ./publish/packages-v2 | |
# We're filtering the files to publish here based on the IsPackable attribute that's also used for v1 packages | |
$projectFiles = Get-ChildItem -Path ${{ matrix.solution }} -Recurse -Filter *.csproj | |
foreach ($file in $projectFiles) { | |
[xml]$xmlContent = Get-Content -Path $file.FullName | |
foreach ($propertyGroup in $xmlContent.Project.PropertyGroup) { | |
if ($propertyGroup.IsPackable -eq "true") { | |
$packageName = $file.BaseName | |
dotnet publish $file.FullName --configuration Release -f net6 --output ./publish/raw/packages-v2/$packageName --no-build /p:DebugType=None /p:DebugSymbols=false | |
Compress-Archive -Path ./publish/raw/packages-v2/$packageName/* -DestinationPath ./publish/packages-v2/$packageName.$version.zip | |
$hash = Get-FileHash ./publish/packages-v2/$packageName.$version.zip -Algorithm SHA256 | |
$hashbytes = $hash.Hash -split '([A-F0-9]{2})' | foreach-object { if ($_) {[System.Convert]::ToByte($_,16)}} | |
$hashstring = [System.Convert]::ToBase64String($hashbytes) | |
$hashstring | Set-Content ./publish/packages-v2/$packageName.$version.zip.hash | |
break | |
} | |
} | |
} | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.solution }}-build-artifacts | |
path: ./publish |