Skip to content

Update WinX64.yml

Update WinX64.yml #48

Workflow file for this run

name: Build and Publish PicView Avalonia WinX64
on:
push:
branches:
- dev
pull_request:
branches:
- dev
jobs:
build:
runs-on: windows-latest
steps:
# Step 1: Checkout the code
- 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 the project file
- name: Get version from the project file
id: get-version
with:
proj-path: .\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj
# Step 4: Define paths
- name: Define paths
id: paths
run: |
$outputDir = "PicView-v.$(${{ steps.version.outputs.version }})-win-x64"
echo "##[set-output name=output_dir;]$outputDir"
shell: pwsh
# Step 5: Run dotnet publish
- name: Publish the project
run: |
$projectPath = ".\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj"
$tempPath = [System.IO.Path]::GetTempPath() + "PicView"
dotnet publish $projectPath --runtime win-x64 --self-contained true --configuration Release --output $tempPath /p:PublishReadyToRun=true
shell: pwsh
# Step 6: Copy output to final directory
- name: Copy build to final output directory
run: |
$tempPath = [System.IO.Path]::GetTempPath() + "PicView"
$outputPath = "${{ steps.paths.outputs.output_dir }}"
if (Test-Path $outputPath) {
Remove-Item -Path $outputPath -Recurse -Force
}
New-Item -Path $outputPath -ItemType Directory | Out-Null
Copy-Item -Path "$tempPath\*" -Destination $outputPath -Recurse -Force
shell: pwsh
# Step 7: Remove unnecessary files
- name: Clean up unnecessary files
run: |
$outputPath = "${{ steps.paths.outputs.output_dir }}"
$pdbPath = Join-Path -Path $outputPath -ChildPath "PicView.Avalonia.pdb"
if (Test-Path $pdbPath) {
Remove-Item -Path $pdbPath -Force
}
if ($outputPath -match " ") {
$newOutputPath = $outputPath.Replace(" ","")
Rename-Item -Path $outputPath -NewName $newOutputPath
}
shell: pwsh
# Step 8: Upload the zip file as an artifact
- name: Upload the artifact
uses: actions/upload-artifact@v4
with:
name: PicView-v${{ steps.version.outputs.version }}-win-x64
path: ${{ steps.paths.outputs.output_dir }}
retention-days: 14
# Step 9: Generate the Inno Setup Installer
- name: Generate Inno Setup Installer
run: |
$appVersion = "${{ steps.version.outputs.version }}"
$outputDir = "${{ steps.paths.outputs.output_dir }}"
$setupOutputDir = "${{ steps.paths.outputs.output_dir }}\install"
$appIconPath = "${{ github.workspace }}\src\PicView.Avalonia.Win32\icon.ico"
$licenseFilePath = "${{ github.workspace }}\src\PicView.Core\Licenses\LICENSE.txt"
# Create output directory for installer
New-Item -Path $setupOutputDir -ItemType Directory -Force
# Run Inno Setup Compiler with resolved paths
iscc.exe "/dMyAppVersion=$appVersion" `
"/dMyAppOutputDir=$outputDir" `
"/dMyAppExeName=PicView.exe" `
"/dMyAppIcon=$appIconPath" `
"/dMyAppLicenseFile=$licenseFilePath" `
"/o$setupOutputDir" "${{ github.workspace }}\Build\install.iss"
shell: pwsh
# Step 10: Upload the Inno Setup Installer as an artifact
- name: Upload Inno Setup Installer
uses: actions/upload-artifact@v4
with:
name: PicView-v${{ steps.version.outputs.version }}
path: ${{ steps.paths.outputs.output_dir }}\install
retention-days: 14