Skip to content

Commit e19cbcd

Browse files
committed
fix(ci): improve version handling in publish workflow
- Simplify environment variable setting using Add-Content - Add version normalization step to sanitize special characters - Pass version parameters to publish commands for proper assembly versioning
1 parent c9dfc33 commit e19cbcd

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

.github/workflows/commit.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,23 @@ jobs:
4848
id: gitversion
4949
run: |
5050
$version = dotnet-gitversion /showvariable FullSemVer
51-
Write-Host "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
52-
Write-Host "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
51+
Add-Content $env:GITHUB_ENV "VERSION=$version"
52+
Add-Content $env:GITHUB_OUTPUT "version=$version"
53+
- name: Normalize version
54+
run: |
55+
$rawVersion = $env:VERSION
56+
$safeVersion = $rawVersion -replace '[^a-zA-Z0-9\.\-]', '_'
57+
Add-Content $env:GITHUB_ENV "SAFE_VERSION=$safeVersion"
5358
- name: Publish Self-Contained
5459
run: |
5560
dotnet publish app/Sentinel.NLogViewer.App/Sentinel.NLogViewer.App.csproj `
5661
-c Release `
5762
-p:SelfContained=true `
5863
-p:PublishSingleFile=true `
5964
-p:RuntimeIdentifier=win-x64 `
65+
-p:Version=$env:VERSION `
66+
-p:AssemblyVersion=$env:VERSION `
67+
-p:FileVersion=$env:VERSION `
6068
-p:IncludeNativeLibrariesForSelfExtract=true `
6169
-o publish/self-contained
6270
- name: Publish Framework-Dependent
@@ -65,23 +73,26 @@ jobs:
6573
-c Release `
6674
-p:SelfContained=false `
6775
-p:RuntimeIdentifier=win-x64 `
76+
-p:Version=$env:VERSION `
77+
-p:AssemblyVersion=$env:VERSION `
78+
-p:FileVersion=$env:VERSION `
6879
-o publish/framework-dependent
6980
- name: Rename folders with version
7081
run: |
71-
$version = $env:VERSION
82+
$version = $env:SAFE_VERSION
7283
Rename-Item -Path "publish/self-contained" -NewName "NLogViewer-SelfContained-win-x64-$version"
7384
Rename-Item -Path "publish/framework-dependent" -NewName "NLogViewer-FrameworkDependent-win-x64-$version"
7485
- name: Upload Self-Contained artifact
7586
uses: actions/upload-artifact@v4
7687
with:
77-
name: NLogViewer-SelfContained-win-x64-${{ env.VERSION }}
78-
path: publish/NLogViewer-SelfContained-win-x64-${{ env.VERSION }}
88+
name: NLogViewer-SelfContained-win-x64-${{ env.SAFE_VERSION }}
89+
path: publish/NLogViewer-SelfContained-win-x64-${{ env.SAFE_VERSION }}
7990
if-no-files-found: error
8091
retention-days: 1
8192
- name: Upload Framework-Dependent artifact
8293
uses: actions/upload-artifact@v4
8394
with:
84-
name: NLogViewer-FrameworkDependent-win-x64-${{ env.VERSION }}
85-
path: publish/NLogViewer-FrameworkDependent-win-x64-${{ env.VERSION }}
95+
name: NLogViewer-FrameworkDependent-win-x64-${{ env.SAFE_VERSION }}
96+
path: publish/NLogViewer-FrameworkDependent-win-x64-${{ env.SAFE_VERSION }}
8697
if-no-files-found: error
8798
retention-days: 1

0 commit comments

Comments
 (0)