@@ -2,9 +2,7 @@ name: Release
2
2
3
3
on :
4
4
push :
5
- branches :
6
- - main
7
- - dev
5
+ branches : [ dev, main ]
8
6
9
7
# Allows you to run this workflow manually from the Actions tab
10
8
workflow_dispatch :
@@ -18,15 +16,20 @@ jobs:
18
16
fetch-depth : 0
19
17
20
18
- name : Read version from csproj
21
- id : extract_version
22
19
if : github.ref == 'refs/heads/main'
23
20
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
30
33
31
34
- name : Run build
32
35
run : ./Build.ps1 -SkipTests
@@ -37,20 +40,41 @@ jobs:
37
40
if : success() && github.ref == 'refs/heads/main'
38
41
run : |
39
42
git log -1 --pretty=%B > last_commit_message.txt
43
+ shell : pwsh
40
44
41
- # Create GitHub release only on main branch (latest release)
42
45
- name : Create Release
43
46
if : github.ref == 'refs/heads/main' && success()
44
47
env :
45
48
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
46
49
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
51
74
52
75
- name : Publish to nuget.org
53
76
env :
54
77
NUGET_API_KEY : ${{ secrets.NUGET_API_KEY }}
55
78
run : |
56
79
nuget push artifacts\*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
80
+ shell : pwsh
0 commit comments