WinX64.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: Build and Publish PicView Avalonia WinX64
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. pull_request:
  7. branches:
  8. - dev
  9. jobs:
  10. build:
  11. runs-on: windows-latest
  12. steps:
  13. # Step 1: Checkout the code
  14. - name: Checkout repository
  15. uses: actions/checkout@v3
  16. # Step 2: Setup .NET 9 SDK
  17. - name: Setup .NET 9 SDK
  18. uses: actions/setup-dotnet@v3
  19. with:
  20. dotnet-version: '9.x'
  21. # Step 3: Extract AssemblyVersion from the project file
  22. - name: Extract AssemblyVersion
  23. id: version
  24. run: |
  25. $projectPath = ".\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj"
  26. $projectFile = [xml](Get-Content $projectPath)
  27. $assemblyVersion = $projectFile.Project.PropertyGroup.AssemblyVersion
  28. echo "##[set-output name=version;]$assemblyVersion"
  29. shell: pwsh
  30. # Step 4: Define paths
  31. - name: Define paths
  32. id: paths
  33. run: |
  34. $outputDir = "PicView-v.$(${{ steps.version.outputs.version }})-win-x64"
  35. echo "##[set-output name=output_dir;]$outputDir"
  36. shell: pwsh
  37. # Step 5: Run dotnet publish
  38. - name: Publish the project
  39. run: |
  40. $projectPath = ".\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj"
  41. $tempPath = [System.IO.Path]::GetTempPath() + "PicView"
  42. dotnet publish $projectPath --runtime win-x64 --self-contained true --configuration Release --output $tempPath /p:PublishReadyToRun=true
  43. shell: pwsh
  44. # Step 6: Copy output to final directory
  45. - name: Copy build to final output directory
  46. run: |
  47. $tempPath = [System.IO.Path]::GetTempPath() + "PicView"
  48. $outputPath = "${{ steps.paths.outputs.output_dir }}"
  49. if (Test-Path $outputPath) {
  50. Remove-Item -Path $outputPath -Recurse -Force
  51. }
  52. New-Item -Path $outputPath -ItemType Directory | Out-Null
  53. Copy-Item -Path "$tempPath\*" -Destination $outputPath -Recurse -Force
  54. shell: pwsh
  55. # Step 7: Remove unnecessary files
  56. - name: Clean up unnecessary files
  57. run: |
  58. $outputPath = "${{ steps.paths.outputs.output_dir }}"
  59. $licensePath = Join-Path -Path $outputPath -ChildPath "Licenses\XamlAnimatedGif LICENSE.txt"
  60. if (Test-Path $licensePath) {
  61. Remove-Item -Path $licensePath -Force
  62. }
  63. $pdbPath = Join-Path -Path $outputPath -ChildPath "PicView.Avalonia.pdb"
  64. if (Test-Path $pdbPath) {
  65. Remove-Item -Path $pdbPath -Force
  66. }
  67. Rename-Item -Path $outputPath -NewName $outputPath.Replace(" ","")
  68. shell: pwsh
  69. # Step 8: Clean up temp directory
  70. - name: Clean up temp directory
  71. run: |
  72. $tempPath = [System.IO.Path]::GetTempPath() + "PicView"
  73. Start-Sleep -Seconds 2
  74. Remove-Item -Path $tempPath -Recurse -Force
  75. shell: pwsh