Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release workfow for windows #573

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading