diff --git a/.github/workflows/BuildWin32.yml b/.github/workflows/BuildWin32.yml index 1a9f06ada..3e947be43 100644 --- a/.github/workflows/BuildWin32.yml +++ b/.github/workflows/BuildWin32.yml @@ -23,13 +23,11 @@ jobs: with: dotnet-version: '9.x' - # Step 3: Get version from the project file - - name: Get version from the project file - uses: kzrnm/get-net-sdk-project-versions-action@v2 + # Step 3: Get version from Directory.Build.props using PowerShell + - name: Get version from Directory.Build.props id: get-version - with: - proj-path: .\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj - + run: pwsh -File "${{ github.workspace }}/Build/Get-VersionInfo.ps1" + # Step 4 (x64): Publish x64 version - name: Publish x64 version run: | diff --git a/.github/workflows/ReleaseSignWindows.yaml b/.github/workflows/ReleaseSignWindows.yaml index cc1f4ac15..9a47c5ea7 100644 --- a/.github/workflows/ReleaseSignWindows.yaml +++ b/.github/workflows/ReleaseSignWindows.yaml @@ -18,12 +18,11 @@ jobs: with: dotnet-version: '9.x' - # Step 3: Get version from the project file - - name: Get version from the project file - uses: kzrnm/get-net-sdk-project-versions-action@v2 + + # Step 3: Get version from Directory.Build.props using PowerShell + - name: Get version from Directory.Build.props id: get-version - with: - proj-path: .\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj + run: pwsh -File "${{ github.workspace }}/Build/Get-VersionInfo.ps1" # Step 4 (x64): Publish x64 version - name: Publish x64 version diff --git a/.github/workflows/TestSignWindows.yaml b/.github/workflows/TestSignWindows.yaml index 78be938f4..b8ac35d5d 100644 --- a/.github/workflows/TestSignWindows.yaml +++ b/.github/workflows/TestSignWindows.yaml @@ -12,11 +12,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # Step 2: Setup .NET 9 SDK - - name: Setup .NET 9 SDK - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.x' + + # Step 3: Get version from Directory.Build.props using PowerShell + - name: Get version from Directory.Build.props + id: get-version + run: pwsh -File "${{ github.workspace }}/Build/Get-VersionInfo.ps1" # Step 3: Get version from the project file - name: Get version from the project file diff --git a/Build/Get-VersionInfo.ps1 b/Build/Get-VersionInfo.ps1 new file mode 100644 index 000000000..1df178839 --- /dev/null +++ b/Build/Get-VersionInfo.ps1 @@ -0,0 +1,16 @@ +# Get-VersionInfo.ps1 + +# Load Directory.Build.props as an XML +[xml]$xml = Get-Content "$PSScriptRoot/../Directory.Build.props" + +# Extract VersionPrefix, VersionSuffix, and FileVersion +$versionPrefix = $xml.Project.PropertyGroup.VersionPrefix +$versionSuffix = $xml.Project.PropertyGroup.VersionSuffix +$fileVersion = $xml.Project.PropertyGroup.FileVersion + +# Combine VersionPrefix and VersionSuffix +$fullVersion = "$versionPrefix-$versionSuffix" + +# Output the results for GitHub Actions +Write-Output "::set-output name=version::$fullVersion" +Write-Output "::set-output name=file-version::$fileVersion" \ No newline at end of file