Merge branch 'master' into feature/host-builder #428
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 Core | |
on: | |
push: | |
branches: | |
- master | |
- feature/host-builder | |
tags: | |
- '*' | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build_test_pack: | |
runs-on: windows-latest | |
steps: | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
java-package: jdk | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
cache-dependency-path: '.reuse/requirements.txt' | |
- name: Install REUSE | |
run: | | |
python -m pip install --upgrade pip | |
pip install python-debian==0.1.38 | |
pip install reuse | |
- name: REUSE Compliance Check | |
run: | | |
reuse lint | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '9.x' | |
cache: true | |
cache-dependency-path: 'Directory.Packages.props' | |
- name: Cache nuget Packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('Directory.Packages.props') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache dotnet tools | |
id: cache-dotnet-tools | |
uses: actions/cache@v3 | |
with: | |
path: ~/.dotnet/tools | |
key: ${{ runner.os }}-dotnet-tools-${{ hashFiles('./.config/dotnet-tools.json') }} | |
restore-keys: ${{ runner.os }}-dotnet-tools- | |
- name: Install/upgrade dotnet tools | |
shell: powershell | |
run: | | |
dotnet tool restore | |
- name: Run minver | |
id: minver | |
shell: powershell | |
run: | | |
$version = dotnet minver | |
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
- name: nuget restore | |
run: dotnet restore './src/SmartApplicationFramework.sln' | |
- name: Build, test and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: | | |
dotnet dotnet-sonarscanner begin /k:"TRUMPF-IoT_saf" /o:"trumpf-iot" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.dotnet.excludeTestProjects=true /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
if ( $LASTEXITCODE -ne 0 ) { exit $LASTEXITCODE } | |
dotnet build './src/SmartApplicationFramework.sln' --configuration Release --no-restore | |
if ( $LASTEXITCODE -ne 0 ) { exit $LASTEXITCODE } | |
dotnet dotnet-coverage collect -f xml -o coverage.xml 'dotnet test ./src/SmartApplicationFramework.sln --configuration Release --no-build --no-restore --verbosity normal' | |
if ( $LASTEXITCODE -ne 0 ) { exit $LASTEXITCODE } | |
dotnet dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
if ( $LASTEXITCODE -ne 0 ) { exit $LASTEXITCODE } | |
- name: Pack | |
run: | | |
mkdir -p ./artifacts | |
dotnet pack './src/SmartApplicationFramework.sln' --configuration Release --no-build --output './artifacts' | |
- name: Upload artifacts | |
if: github.event_name == 'push' && (contains(github.ref, 'refs/tags/') || contains(github.ref, 'refs/heads/master')) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: SmartApplicationFramework-${{ steps.minver.outputs.version }} | |
path: ./artifacts | |
- name: Publish nuget packages | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
run: | | |
dotnet nuget push ".\artifacts\*.nupkg" --api-key "${{secrets.SAF_NUGETORG_APIKEY}}" --source https://api.nuget.org/v3/index.json --skip-duplicate |