|
name: Release |
|
|
|
on: |
|
release: |
|
types: [published] |
|
|
|
permissions: |
|
contents: write |
|
|
|
jobs: |
|
build-release: |
|
runs-on: windows-latest |
|
|
|
steps: |
|
- name: Checkout |
|
uses: actions/checkout@v4 |
|
|
|
- name: Setup .NET 6 |
|
uses: actions/setup-dotnet@v4 |
|
with: |
|
dotnet-version: "6.0.x" |
|
|
|
- name: Restore |
|
run: dotnet restore ./installer/Phat.wixproj |
|
|
|
- name: Build MSI |
|
shell: pwsh |
|
run: | |
|
$tagVersion = "${{ github.event.release.tag_name }}".TrimStart('v') |
|
# Strip pre-release suffix (e.g., 1.1.1-beta -> 1.1.1) |
|
$version = $tagVersion -replace '-.*$', '' |
|
Write-Host "Tag: $tagVersion -> MSI Version: $version" |
|
dotnet build ./installer/Phat.wixproj -c Release -p:ProductVersion=$version |
|
if ($LASTEXITCODE -ne 0) { |
|
Write-Error "Build failed with exit code $LASTEXITCODE" |
|
exit $LASTEXITCODE |
|
} |
|
|
|
- name: Debug - List built files |
|
shell: pwsh |
|
run: | |
|
Write-Host "=== Looking for output files ===" |
|
$msiFiles = Get-ChildItem -Path "installer/bin/Release" -Filter "*.msi" -Recurse |
|
if ($msiFiles) { |
|
Write-Host "Found MSI files:" |
|
$msiFiles | ForEach-Object { |
|
Write-Host " - $($_.FullName) ($([math]::Round($_.Length / 1KB, 2)) KB)" |
|
} |
|
} else { |
|
Write-Host "No .msi files found in installer/bin/Release!" |
|
Write-Host "" |
|
Write-Host "=== Directory contents ===" |
|
Get-ChildItem -Path "installer/bin/Release" -Recurse | ForEach-Object { Write-Host $_.FullName } |
|
} |
|
|
|
- name: Code Sign MSI (Optional) |
|
shell: pwsh |
|
run: | |
|
Write-Host "โน๏ธ Code signing certificate not configured." |
|
Write-Host "To enable code signing, add CODE_SIGNING_CERT and CODE_SIGNING_PASS secrets to the repository." |
|
Write-Host "The MSI will be distributed with elevated privileges for trusted installation." |
|
|
|
- name: Upload Release Assets |
|
env: |
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
shell: pwsh |
|
run: | |
|
$msiPath = Get-ChildItem -Path "installer/bin/Release" -Filter "*.msi" -Recurse | Select-Object -First 1 |
|
if (-not $msiPath) { |
|
Write-Error "No MSI file found!" |
|
exit 1 |
|
} |
|
|
|
$tagName = "${{ github.event.release.tag_name }}" |
|
Write-Host "Uploading $($msiPath.Name) to release $tagName..." |
|
|
|
# Upload the asset using GitHub CLI |
|
gh release upload "$tagName" "$($msiPath.FullName)" --clobber |
|
|
|
if ($LASTEXITCODE -eq 0) { |
|
Write-Host "โ
Successfully uploaded Phat.msi to release $tagName" |
|
} else { |
|
Write-Error "Failed to upload asset" |
|
exit 1 |
|
} |
|
|
|
- name: Verify Release |
|
shell: pwsh |
|
env: |
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
run: | |
|
$tagName = "${{ github.event.release.tag_name }}" |
|
Write-Host "โ
Release workflow completed successfully" |
|
Write-Host "๐ฆ MSI uploaded to $tagName release" |