瀏覽代碼

Update build logic

Ruben 11 月之前
父節點
當前提交
9d6de376ed

+ 4 - 6
.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: |

+ 4 - 5
.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

+ 5 - 5
.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

+ 16 - 0
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"