diff --git a/.github/workflows/pr-analysis-codeql.yml b/.github/workflows/pr-analysis-codeql.yml index 46e8bb93..72d81f4c 100644 --- a/.github/workflows/pr-analysis-codeql.yml +++ b/.github/workflows/pr-analysis-codeql.yml @@ -1,8 +1,6 @@ name: PR Analysis Code QL on: - push: - branches: [ dev, main ] pull_request: branches: [ dev, main ] diff --git a/.github/workflows/pr-analysis-devskim.yml b/.github/workflows/pr-analysis-devskim.yml index 80185a82..0982f00e 100644 --- a/.github/workflows/pr-analysis-devskim.yml +++ b/.github/workflows/pr-analysis-devskim.yml @@ -1,8 +1,6 @@ name: PR Analysis DevSkim on: - push: - branches: [ dev, main ] pull_request: branches: [ dev, main ] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d0ccce6..3573faf2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,7 @@ name: Release on: push: - branches: - - main - - dev + branches: [ dev, main ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -18,15 +16,20 @@ jobs: fetch-depth: 0 - name: Read version from csproj - id: extract_version if: github.ref == 'refs/heads/main' run: | - VERSION=$(grep '' src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | sed 's/.*\(.*\)<\/VersionPrefix>.*/\1/') - echo "VERSION=$VERSION" >> $GITHUB_ENV - if git rev-parse "v$VERSION" >/dev/null 2>&1; then - echo "Tag v$VERSION already exists" - exit 1 - fi + # Extract the version from the .csproj file using PowerShell XML parsing + [xml]$csproj = Get-Content 'src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj' + $version = $csproj.Project.PropertyGroup.VersionPrefix + echo "VERSION=$version" >> $env:GITHUB_ENV + + # Check if the tag already exists in git + $tagExists = git tag -l "v$version" + if ($tagExists) { + Write-Host "Tag v$version already exists" + exit 1 + } + shell: pwsh - name: Run build run: ./Build.ps1 -SkipTests @@ -37,20 +40,41 @@ jobs: if: success() && github.ref == 'refs/heads/main' run: | git log -1 --pretty=%B > last_commit_message.txt + shell: pwsh - # Create GitHub release only on main branch (latest release) - name: Create Release if: github.ref == 'refs/heads/main' && success() env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release create v${{ env.VERSION }} \ - --title "v${{ env.VERSION }}" \ - --notes "$(cat last_commit_message.txt)" \ - artifacts/*.nupkg artifacts/*.snupkg + # Der Basisname der Dateien basierend auf der Versionsnummer + $baseFileName = "Serilog.Sinks.MSSqlServer.${{ env.VERSION }}" + + # Suche die exakten Dateipfade für .nupkg und .snupkg + $nupkgFile = Get-ChildItem -Path "artifacts/$baseFileName*.nupkg" | Select-Object -First 1 + $snupkgFile = Get-ChildItem -Path "artifacts/$baseFileName*.snupkg" | Select-Object -First 1 + + # Überprüfe, ob beide Dateien gefunden wurden + if (-not $nupkgFile) { Write-Error "nupkg file not found" ; exit 1 } + if (-not $snupkgFile) { Write-Error "snupkg file not found" ; exit 1 } + + # Ersetze Backslashes durch Forward Slashes für GitHub CLI-Kompatibilität + $nupkgFilePath = $nupkgFile.FullName -replace '\\', '/' + $snupkgFilePath = $snupkgFile.FullName -replace '\\', '/' + + # Ausgabe der Dateipfade zu Debugging-Zwecken + Write-Host "Uploading files: $nupkgFilePath, $snupkgFilePath" + + # Erstelle das Release mit den genauen Dateipfaden + gh release create v${{ env.VERSION }} ` + --title "v${{ env.VERSION }}" ` + --notes "$(Get-Content last_commit_message.txt)" ` + $nupkgFilePath $snupkgFilePath + shell: pwsh - name: Publish to nuget.org env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} run: | nuget push artifacts\*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }} + shell: pwsh diff --git a/CHANGES.md b/CHANGES.md index 9601678f..4be1cfc1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ # 7.0.1 * Fixed issue #567: .NET Framework assemblies were not built properly +* Consolidated PR validation action workflows and updated some task versions # 7.0.0 * Fixed issue #543: Update to Serilog v4, remove reference to Serilog.Sinks.PeriodicBatching (thanks to @cancakar35)