Skip to content

Commit 45d7349

Browse files
authored
Merge pull request #573 from ckadluba/fix-release-workfow-for-windows
Fix release workfow for windows
2 parents 513661d + 455dded commit 45d7349

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

.github/workflows/pr-analysis-codeql.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: PR Analysis Code QL
22

33
on:
4-
push:
5-
branches: [ dev, main ]
64
pull_request:
75
branches: [ dev, main ]
86

.github/workflows/pr-analysis-devskim.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: PR Analysis DevSkim
22

33
on:
4-
push:
5-
branches: [ dev, main ]
64
pull_request:
75
branches: [ dev, main ]
86

.github/workflows/release.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: Release
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- dev
5+
branches: [ dev, main ]
86

97
# Allows you to run this workflow manually from the Actions tab
108
workflow_dispatch:
@@ -18,15 +16,20 @@ jobs:
1816
fetch-depth: 0
1917

2018
- name: Read version from csproj
21-
id: extract_version
2219
if: github.ref == 'refs/heads/main'
2320
run: |
24-
VERSION=$(grep '<VersionPrefix>' src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | sed 's/.*<VersionPrefix>\(.*\)<\/VersionPrefix>.*/\1/')
25-
echo "VERSION=$VERSION" >> $GITHUB_ENV
26-
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
27-
echo "Tag v$VERSION already exists"
28-
exit 1
29-
fi
21+
# Extract the version from the .csproj file using PowerShell XML parsing
22+
[xml]$csproj = Get-Content 'src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj'
23+
$version = $csproj.Project.PropertyGroup.VersionPrefix
24+
echo "VERSION=$version" >> $env:GITHUB_ENV
25+
26+
# Check if the tag already exists in git
27+
$tagExists = git tag -l "v$version"
28+
if ($tagExists) {
29+
Write-Host "Tag v$version already exists"
30+
exit 1
31+
}
32+
shell: pwsh
3033

3134
- name: Run build
3235
run: ./Build.ps1 -SkipTests
@@ -37,20 +40,41 @@ jobs:
3740
if: success() && github.ref == 'refs/heads/main'
3841
run: |
3942
git log -1 --pretty=%B > last_commit_message.txt
43+
shell: pwsh
4044

41-
# Create GitHub release only on main branch (latest release)
4245
- name: Create Release
4346
if: github.ref == 'refs/heads/main' && success()
4447
env:
4548
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4649
run: |
47-
gh release create v${{ env.VERSION }} \
48-
--title "v${{ env.VERSION }}" \
49-
--notes "$(cat last_commit_message.txt)" \
50-
artifacts/*.nupkg artifacts/*.snupkg
50+
# Der Basisname der Dateien basierend auf der Versionsnummer
51+
$baseFileName = "Serilog.Sinks.MSSqlServer.${{ env.VERSION }}"
52+
53+
# Suche die exakten Dateipfade für .nupkg und .snupkg
54+
$nupkgFile = Get-ChildItem -Path "artifacts/$baseFileName*.nupkg" | Select-Object -First 1
55+
$snupkgFile = Get-ChildItem -Path "artifacts/$baseFileName*.snupkg" | Select-Object -First 1
56+
57+
# Überprüfe, ob beide Dateien gefunden wurden
58+
if (-not $nupkgFile) { Write-Error "nupkg file not found" ; exit 1 }
59+
if (-not $snupkgFile) { Write-Error "snupkg file not found" ; exit 1 }
60+
61+
# Ersetze Backslashes durch Forward Slashes für GitHub CLI-Kompatibilität
62+
$nupkgFilePath = $nupkgFile.FullName -replace '\\', '/'
63+
$snupkgFilePath = $snupkgFile.FullName -replace '\\', '/'
64+
65+
# Ausgabe der Dateipfade zu Debugging-Zwecken
66+
Write-Host "Uploading files: $nupkgFilePath, $snupkgFilePath"
67+
68+
# Erstelle das Release mit den genauen Dateipfaden
69+
gh release create v${{ env.VERSION }} `
70+
--title "v${{ env.VERSION }}" `
71+
--notes "$(Get-Content last_commit_message.txt)" `
72+
$nupkgFilePath $snupkgFilePath
73+
shell: pwsh
5174

5275
- name: Publish to nuget.org
5376
env:
5477
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
5578
run: |
5679
nuget push artifacts\*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
80+
shell: pwsh

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# 7.0.1
22
* Fixed issue #567: .NET Framework assemblies were not built properly
3+
* Consolidated PR validation action workflows and updated some task versions
34

45
# 7.0.0
56
* Fixed issue #543: Update to Serilog v4, remove reference to Serilog.Sinks.PeriodicBatching (thanks to @cancakar35)

0 commit comments

Comments
 (0)