Skip to content

Commit

Permalink
Merge pull request #573 from ckadluba/fix-release-workfow-for-windows
Browse files Browse the repository at this point in the history
Fix release workfow for windows
  • Loading branch information
ckadluba authored Sep 20, 2024
2 parents 513661d + 455dded commit 45d7349
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/pr-analysis-codeql.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: PR Analysis Code QL

on:
push:
branches: [ dev, main ]
pull_request:
branches: [ dev, main ]

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pr-analysis-devskim.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: PR Analysis DevSkim

on:
push:
branches: [ dev, main ]
pull_request:
branches: [ dev, main ]

Expand Down
54 changes: 39 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 '<VersionPrefix>' src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | sed 's/.*<VersionPrefix>\(.*\)<\/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
Expand All @@ -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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 45d7349

Please sign in to comment.