Skip to content

Commit e238263

Browse files
update version step to bash [skip ci]
1 parent 2aba5b0 commit e238263

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

.github/workflows/Publish-Nuget.yml

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,24 @@ jobs:
5959

6060
- name: Get Version
6161
id: version
62+
shell: bash
6263
run: |
63-
$projectPath = "${{ github.workspace }}\OpenAI-DotNet\OpenAI-DotNet.csproj"
64-
65-
if (-Not (Test-Path $projectPath)) {
66-
Write-Host "Project file not found at $projectPath"
67-
exit 1
68-
}
69-
70-
[xml]$csproj = Get-Content $projectPath
71-
72-
if ($csproj -eq $null) {
73-
Write-Host "Failed to load csproj file."
64+
project_path="${{ github.workspace }}/OpenAI-DotNet/OpenAI-DotNet.csproj"
65+
66+
if [ ! -f "$project_path" ]; then
67+
echo "Project file not found at $project_path"
7468
exit 1
75-
}
76-
77-
$version = $csproj.Project.PropertyGroup.Version
78-
79-
if ([string]::IsNullOrEmpty($version)) {
80-
Write-Host "Version not found in csproj."
69+
fi
70+
71+
version=$(grep -oPm1 '(?<=<Version>)[^<]+' "$project_path" || true)
72+
73+
if [ -z "$version" ]; then
74+
echo "Version not found in csproj."
8175
exit 1
82-
}
83-
84-
Write-Host "Project Version: $version"
85-
echo "PACKAGE_VERSION=$version" >> $GITHUB_OUTPUT
76+
fi
77+
78+
echo "Project Version: $version"
79+
echo "PACKAGE_VERSION=$version" >> "$GITHUB_OUTPUT"
8680
8781
- name: Test Packages
8882
if: ${{ github.ref != 'refs/heads/main' && github.event_name != 'push' }}
@@ -162,7 +156,7 @@ jobs:
162156
- uses: actions/upload-artifact@v6
163157
if: always()
164158
with:
165-
name: OpenAI-DotNet.${{ steps.version.outputs.PACKAGE_VERSION }}-artifacts
159+
name: OpenAI-DotNet.${{ steps.version.outputs.PACKAGE_VERSION }}
166160
path: |
167161
${{ github.workspace }}/test-results
168162
${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet.${{ steps.version.outputs.PACKAGE_VERSION }}.nupkg

0 commit comments

Comments
 (0)