V9.0.0/finalize yamldotnet migration #149
Workflow file for this run
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: Cuemon CI/CD Pipeline | |
on: | |
pull_request: | |
branches: [main] | |
paths-ignore: | |
- .codecov/** | |
- .docfx/** | |
- .github/** | |
- .nuget/** | |
- '**.md' | |
workflow_dispatch: | |
inputs: | |
configuration: | |
type: choice | |
description: The build configuration to use in the deploy stage. | |
required: true | |
default: Release | |
options: | |
- Debug | |
- Release | |
jobs: | |
prepare_linux: | |
name: 🐧 Prepare Linux | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
outputs: | |
restoreCacheKey: ${{ steps.dotnet-restore.outputs.restoreCacheKey }} | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- id: dotnet-restore | |
name: Restore Dependencies | |
uses: codebeltnet/dotnet-restore@v2 | |
with: | |
useRestoreCache: true | |
prepare_windows: | |
name: 🪟 Prepare Windows | |
runs-on: windows-2022 | |
timeout-minutes: 15 | |
outputs: | |
restoreCacheKey: ${{ steps.dotnet-restore.outputs.restoreCacheKey }} | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- id: dotnet-restore | |
name: Restore Dependencies | |
uses: codebeltnet/dotnet-restore@v2 | |
with: | |
useRestoreCache: true | |
build: | |
name: 🛠️ Build | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
framework: [net9.0, net8.0, netstandard2.1, netstandard2.0] | |
needs: [prepare_linux] | |
outputs: | |
version: ${{ steps.minver-calculate.outputs.version }} | |
testProjects: ${{ steps.test-projects.outputs.result }} | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- name: Install MinVer | |
uses: codebeltnet/dotnet-tool-install-minver@v1 | |
- id: minver-calculate | |
name: Calculate Version | |
uses: codebeltnet/minver-calculate@v2 | |
- name: Download cuemon.snk file | |
uses: codebeltnet/gcp-download-file@v1 | |
with: | |
serviceAccountKey: ${{ secrets.GCP_TOKEN }} | |
bucketName: ${{ secrets.GCP_BUCKETNAME }} | |
objectName: cuemon.snk | |
- name: Set environment variable for projects | |
run: | | |
if [ "${{ matrix.framework }}" == "netstandard2.1" ]; then | |
echo "PROJECTS=src/**/Cuemon.Extensions.IO.csproj src/**/Cuemon.IO.csproj" >> $GITHUB_ENV | |
elif [ "${{ matrix.framework }}" == "netstandard2.0" ]; then | |
projects=( | |
"src/**/Cuemon.Core.csproj" | |
"src/**/Cuemon.Data.csproj" | |
"src/**/Cuemon.Data.Integrity.csproj" | |
"src/**/Cuemon.Data.SqlClient.csproj" | |
"src/**/Cuemon.Diagnostics.csproj" | |
"src/**/Cuemon.Extensions.Collections.Generic.csproj" | |
"src/**/Cuemon.Extensions.Collections.Specialized.csproj" | |
"src/**/Cuemon.Extensions.Core.csproj" | |
"src/**/Cuemon.Extensions.Data.csproj" | |
"src/**/Cuemon.Extensions.Data.Integrity.csproj" | |
"src/**/Cuemon.Extensions.DependencyInjection.csproj" | |
"src/**/Cuemon.Extensions.Diagnostics.csproj" | |
"src/**/Cuemon.Extensions.Globalization.csproj" | |
"src/**/Cuemon.Extensions.Hosting.csproj" | |
"src/**/Cuemon.Extensions.IO.csproj" | |
"src/**/Cuemon.Extensions.Net.csproj" | |
"src/**/Cuemon.Extensions.Newtonsoft.Json.csproj" | |
"src/**/Cuemon.Extensions.Reflection.csproj" | |
"src/**/Cuemon.Extensions.Runtime.Caching.csproj" | |
"src/**/Cuemon.Extensions.Text.csproj" | |
"src/**/Cuemon.Extensions.Threading.csproj" | |
"src/**/Cuemon.Extensions.Xml.csproj" | |
"src/**/Cuemon.IO.csproj" | |
"src/**/Cuemon.Net.csproj" | |
"src/**/Cuemon.Resilience.csproj" | |
"src/**/Cuemon.Runtime.Caching.csproj" | |
"src/**/Cuemon.Security.Cryptography.csproj" | |
"src/**/Cuemon.Threading.csproj" | |
"src/**/Cuemon.Xml.csproj" | |
) | |
echo "PROJECTS=$(IFS=' '; echo "${projects[*]}")" >> $GITHUB_ENV | |
else | |
echo "PROJECTS=src/**/*.csproj" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- id: dotnet-build | |
name: Build for ${{ matrix.framework }} (${{ matrix.configuration }}) | |
uses: codebeltnet/dotnet-build@v2 | |
with: | |
projects: ${{ env.PROJECTS }} | |
configuration: ${{ matrix.configuration }} | |
framework: ${{ matrix.framework }} | |
restoreCacheKey: ${{ needs.prepare_linux.outputs.restoreCacheKey }} | |
- id: test-projects | |
name: Generate matrix for test projects | |
uses: codebeltnet/shell-globbing@v1 | |
with: | |
pattern: test/**/*.csproj | |
pack: | |
name: 📦 Pack | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
needs: [prepare_linux, build] | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- name: Pack for ${{ matrix.configuration }} | |
uses: codebeltnet/dotnet-pack@v2 | |
with: | |
configuration: ${{ matrix.configuration }} | |
uploadPackedArtifact: true | |
version: ${{ needs.build.outputs.version }} | |
restoreCacheKey: ${{ needs.prepare_linux.outputs.restoreCacheKey }} | |
test: | |
name: 🧪 Test | |
needs: [build, prepare_linux, prepare_windows] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, windows-2022] | |
configuration: [Debug, Release] | |
project: ${{ fromJson(needs.build.outputs.testProjects) }} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- name: Download cuemon.snk file | |
uses: codebeltnet/gcp-download-file@v1 | |
with: | |
serviceAccountKey: ${{ secrets.GCP_TOKEN }} | |
bucketName: ${{ secrets.GCP_BUCKETNAME }} | |
objectName: cuemon.snk | |
- name: Install .NET Tool - Report Generator | |
uses: codebeltnet/dotnet-tool-install-reportgenerator@v1 | |
- name: Spin up SQL Server test dependency for ${{ matrix.configuration }} build | |
if: ${{ (runner.os == 'Linux' && contains(matrix.project, 'Cuemon.Data.SqlClient.Tests')) }} | |
uses: codebeltnet/docker-compose@v1 | |
with: | |
command: up | |
options: --wait | |
env: | |
SA_PASSWORD: ${{ secrets.SA_PASSWORD }} | |
- name: Sleep for 60 seconds | |
if: ${{ (runner.os == 'Linux' && contains(matrix.project, 'Cuemon.Data.SqlClient.Tests')) }} | |
run: sleep 60s | |
shell: bash | |
- name: Test with ${{ matrix.configuration }} build | |
if: ${{ !(runner.os == 'Windows' && contains(matrix.project, 'Cuemon.Data.SqlClient.Tests')) }} | |
uses: codebeltnet/dotnet-test@v3 | |
with: | |
projects: ${{ matrix.project }} | |
configuration: ${{ matrix.configuration }} | |
restoreCacheKey: ${{ runner.os == 'Linux' && needs.prepare_linux.outputs.restoreCacheKey || needs.prepare_windows.outputs.restoreCacheKey }} | |
level: normal | |
env: | |
CONNECTIONSTRINGS__ADVENTUREWORKS: ${{ secrets.DB_ADVENTUREWORKS }} | |
- name: Take down SQL Server test dependency for ${{ matrix.configuration }} build | |
if: ${{ (runner.os == 'Linux' && contains(matrix.project, 'Cuemon.Data.SqlClient.Tests')) }} | |
uses: codebeltnet/docker-compose@v1 | |
with: | |
command: down | |
sonarcloud: | |
name: 🔬 Code Quality Analysis | |
needs: [prepare_linux, build, test] | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 25 | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- name: Install .NET Tool - Sonar Scanner | |
uses: codebeltnet/dotnet-tool-install-sonarscanner@v1 | |
- name: Restore Dependencies | |
uses: codebeltnet/dotnet-restore@v2 | |
with: | |
useRestoreCache: true | |
restoreCacheKey: ${{ needs.prepare_linux.outputs.restoreCacheKey }} | |
- name: Run SonarCloud Analysis | |
uses: codebeltnet/sonarcloud-scan@v1 | |
with: | |
token: ${{ secrets.SONAR_TOKEN }} | |
organization: geekle | |
projectKey: Cuemon | |
version: ${{ needs.build.outputs.version }} | |
- name: Build | |
uses: codebeltnet/dotnet-build@v2 | |
with: | |
buildSwitches: -p:SkipSignAssembly=true | |
uploadBuildArtifact: false | |
- name: Finalize SonarCloud Analysis | |
uses: codebeltnet/sonarcloud-scan-finalize@v1 | |
with: | |
token: ${{ secrets.SONAR_TOKEN }} | |
codecov: | |
name: 📊 Code Coverage Analysis | |
needs: [build, test] | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Run CodeCov Analysis | |
uses: codebeltnet/codecov-scan@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
repository: gimlichael/Cuemon | |
codeql: | |
name: 🛡️ Security Analysis | |
needs: [prepare_linux, build, test] | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: codebeltnet/git-checkout@v1 | |
- name: Install .NET | |
uses: codebeltnet/install-dotnet@v1 | |
with: | |
includePreview: true | |
- name: Restore Dependencies | |
uses: codebeltnet/dotnet-restore@v2 | |
with: | |
useRestoreCache: true | |
restoreCacheKey: ${{ needs.prepare_linux.outputs.restoreCacheKey }} | |
- name: Prepare CodeQL SAST Analysis | |
uses: codebeltnet/codeql-scan@v1 | |
- name: Build | |
uses: codebeltnet/dotnet-build@v2 | |
with: | |
buildSwitches: -p:SkipSignAssembly=true | |
uploadBuildArtifact: false | |
- name: Finalize CodeQL SAST Analysis | |
uses: codebeltnet/codeql-scan-finalize@v1 | |
deploy: | |
if: github.event_name != 'pull_request' | |
name: 🚀 Deploy v${{ needs.build.outputs.version }} | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
needs: [build, pack, test, sonarcloud, codecov, codeql] | |
environment: Production | |
steps: | |
- uses: codebeltnet/nuget-push@v1 | |
with: | |
token: ${{ secrets.NUGET_TOKEN }} | |
configuration: ${{ inputs.configuration == '' && 'Release' || inputs.configuration }} |