Fix WiX icon path: pass IconFile as build variable #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to release (e.g. v2604271200)' | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag || github.ref }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Resolve version | |
| id: ver | |
| shell: pwsh | |
| run: | | |
| $tag = "${{ github.event.inputs.tag || github.ref_name }}" | |
| $version = $tag -replace '^v','' | |
| # Parse yyMMddHHmm into Major.Minor.Patch.Build for VS_VERSIONINFO | |
| if ($version -match '^(\d{2})(\d{2})(\d{2})(\d{4})$') { | |
| $vMaj = [int]$Matches[1]; $vMin = [int]$Matches[2] | |
| $vPat = [int]$Matches[3]; $vBld = [int]$Matches[4] | |
| } else { | |
| $vMaj = 0; $vMin = 0; $vPat = 0; $vBld = 0 | |
| } | |
| "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "vMaj=$vMaj" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "vMin=$vMin" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "vPat=$vPat" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "vBld=$vBld" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| Write-Host "Tag: $tag Version: $version ($vMaj.$vMin.$vPat.$vBld)" | |
| - name: Install goversioninfo | |
| shell: pwsh | |
| run: | | |
| go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.1 | |
| # Add Go bin to PATH for subsequent steps | |
| "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Append | |
| - name: Build binaries | |
| shell: pwsh | |
| env: | |
| CGO_ENABLED: '0' | |
| run: | | |
| $version = "${{ steps.ver.outputs.version }}" | |
| $vMaj = "${{ steps.ver.outputs.vMaj }}" | |
| $vMin = "${{ steps.ver.outputs.vMin }}" | |
| $vPat = "${{ steps.ver.outputs.vPat }}" | |
| $vBld = "${{ steps.ver.outputs.vBld }}" | |
| $stage = Join-Path $env:GITHUB_WORKSPACE 'dist\FileDO' | |
| New-Item -ItemType Directory -Force -Path $stage | Out-Null | |
| $builds = @( | |
| @{ Dir = '.'; Out = "$stage\filedo.exe"; UseVersion = $true }, | |
| @{ Dir = 'FILL'; Out = "$stage\filedo_fill.exe"; UseVersion = $false }, | |
| @{ Dir = 'CHECK'; Out = "$stage\filedo_check.exe"; UseVersion = $false }, | |
| @{ Dir = 'TEST'; Out = "$stage\filedo_test.exe"; UseVersion = $false } | |
| ) | |
| foreach ($b in $builds) { | |
| Push-Location $b.Dir | |
| try { | |
| # Embed PE version info + Windows app manifest. resource.syso | |
| # is auto-linked by `go build` from the package directory. | |
| goversioninfo ` | |
| -64 ` | |
| -ver-major $vMaj -ver-minor $vMin ` | |
| -ver-patch $vPat -ver-build $vBld ` | |
| -product-ver-major $vMaj -product-ver-minor $vMin ` | |
| -product-ver-patch $vPat -product-ver-build $vBld ` | |
| -file-version "$vMaj.$vMin.$vPat.$vBld" ` | |
| -product-version "$vMaj.$vMin.$vPat.$vBld" ` | |
| -o resource.syso ` | |
| versioninfo.json | |
| if ($LASTEXITCODE -ne 0) { throw "goversioninfo failed in $($b.Dir)" } | |
| # Keep symbols (-s -w stripping correlates with higher AV | |
| # heuristic false-positive rates for Go binaries). | |
| if ($b.UseVersion) { | |
| go build -trimpath -ldflags "-X main.version=$version" -o $b.Out . | |
| } else { | |
| go build -trimpath -o $b.Out . | |
| } | |
| if ($LASTEXITCODE -ne 0) { throw "build failed in $($b.Dir)" } | |
| } finally { | |
| Pop-Location | |
| } | |
| } | |
| Copy-Item exe_to_download\*.bat $stage -Force | |
| Copy-Item LICENSE $stage -Force | |
| Copy-Item README.md $stage -Force | |
| - name: Package zip | |
| id: pkg | |
| shell: pwsh | |
| run: | | |
| $version = "${{ steps.ver.outputs.version }}" | |
| $zipName = "FileDO-$version-windows-x64.zip" | |
| $zipPath = Join-Path $env:GITHUB_WORKSPACE "dist\$zipName" | |
| Compress-Archive -Path "dist\FileDO\*" -DestinationPath $zipPath -Force | |
| $sha = (Get-FileHash -Algorithm SHA256 $zipPath).Hash | |
| "$sha $zipName" | Out-File -FilePath "dist\$zipName.sha256" -Encoding ascii | |
| "zip=$zipPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "sha=$sha" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "name=$zipName" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| Write-Host "SHA256: $sha" | |
| - name: Install WiX | |
| shell: pwsh | |
| run: | | |
| dotnet tool install --global wix --version 5.* | |
| if ($LASTEXITCODE -ne 0) { throw "wix install failed" } | |
| "$env:USERPROFILE\.dotnet\tools" | Out-File -FilePath $env:GITHUB_PATH -Append | |
| - name: Build MSI | |
| id: msi | |
| shell: pwsh | |
| run: | | |
| $version = "${{ steps.ver.outputs.version }}" | |
| $productVersion = "${{ steps.ver.outputs.vMaj }}.${{ steps.ver.outputs.vMin }}.${{ steps.ver.outputs.vPat }}.${{ steps.ver.outputs.vBld }}" | |
| $stage = Join-Path $env:GITHUB_WORKSPACE 'dist\FileDO' | |
| $msiName = "FileDO-$version-windows-x64.msi" | |
| $msiPath = Join-Path $env:GITHUB_WORKSPACE "dist\$msiName" | |
| $iconFile = Join-Path $env:GITHUB_WORKSPACE 'assets\icon.ico' | |
| wix build packaging\wix\FileDO.wxs ` | |
| -arch x64 ` | |
| -d "ProductVersion=$productVersion" ` | |
| -d "StageDir=$stage" ` | |
| -d "IconFile=$iconFile" ` | |
| -o $msiPath | |
| if ($LASTEXITCODE -ne 0) { throw "wix build failed" } | |
| $sha = (Get-FileHash -Algorithm SHA256 $msiPath).Hash | |
| "$sha $msiName" | Out-File -FilePath "dist\$msiName.sha256" -Encoding ascii | |
| "msi=$msiPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "sha=$sha" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "name=$msiName" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| Write-Host "MSI SHA256: $sha" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.ver.outputs.tag }} | |
| name: FileDO ${{ steps.ver.outputs.version }} | |
| generate_release_notes: true | |
| files: | | |
| dist/${{ steps.pkg.outputs.name }} | |
| dist/${{ steps.pkg.outputs.name }}.sha256 | |
| dist/${{ steps.msi.outputs.name }} | |
| dist/${{ steps.msi.outputs.name }}.sha256 | |
| body: | | |
| **SHA256** (`${{ steps.pkg.outputs.name }}`): | |
| `${{ steps.pkg.outputs.sha }}` | |
| **SHA256** (`${{ steps.msi.outputs.name }}`): | |
| `${{ steps.msi.outputs.sha }}` |