I am dumb #75
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: Windows Build | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'Valour/Client.Maui/**' | |
| - 'Valour/Client/**' | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version_changed: ${{ steps.check.outputs.changed }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check if release already exists | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| CURRENT=$(grep -oP '(?<=<ApplicationDisplayVersion>)[^<]+' Valour/Client.Maui/Valour.Client.Maui.csproj) | |
| echo "version=$CURRENT" >> $GITHUB_OUTPUT | |
| if gh release view "v$CURRENT" > /dev/null 2>&1; then | |
| echo "Release v$CURRENT already exists, skipping build" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "No release for v$CURRENT, will build" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| build-windows: | |
| needs: check-version | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Install MAUI workloads | |
| run: dotnet workload install maui-windows maui-android | |
| - name: Get short SHA | |
| id: short-sha | |
| shell: bash | |
| run: echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
| - name: Replace asset version hashes | |
| uses: mingjun97/file-regex-replace@v1 | |
| with: | |
| regex: '\$\(SHORTHASH\)' | |
| replacement: '${{ steps.short-sha.outputs.short_sha }}' | |
| flags: "g" | |
| include: '\.(js|cs|razor|cshtml|html)$' | |
| exclude: '.^' | |
| encoding: 'utf8' | |
| path: '.' | |
| - name: Restore dependencies | |
| run: | | |
| dotnet restore Valour/BuildTools/CssBundler/CssBundler.csproj | |
| dotnet restore Valour/Client/Valour.Client.csproj | |
| - name: Build Client (generates CSS bundle) | |
| run: dotnet build Valour/Client/Valour.Client.csproj -c Release --no-restore | |
| - name: Publish Windows App | |
| run: > | |
| dotnet publish Valour/Client.Maui/Valour.Client.Maui.csproj | |
| -f net10.0-windows10.0.19041.0 | |
| -c Release | |
| -o ./artifacts/windows | |
| -p:RuntimeIdentifierOverride=win10-x64 | |
| -p:SelfContained=true | |
| -p:WindowsAppSDKSelfContained=true | |
| - name: Verify published assets | |
| shell: pwsh | |
| run: | | |
| if (!(Test-Path "./artifacts/windows/Valour.exe")) { | |
| throw "Expected ./artifacts/windows/Valour.exe was not produced." | |
| } | |
| if (!(Test-Path "./artifacts/windows/wwwroot/_content/Valour.Client/css/bundled.min.css")) { | |
| throw "Expected Blazor static assets were not found in publish output." | |
| } | |
| - name: Verify launcher icon | |
| shell: pwsh | |
| run: | | |
| $icoPath = Join-Path $PWD "Valour/Client.Maui/Platforms/Windows/trayicon.ico" | |
| if (!(Test-Path $icoPath)) { | |
| throw "Launcher icon was not found." | |
| } | |
| - name: Create payload archive | |
| shell: pwsh | |
| run: Compress-Archive -Path ./artifacts/windows/* -DestinationPath ./artifacts/valour-payload.zip -Force | |
| - name: Publish launcher | |
| run: > | |
| dotnet publish Valour/BuildTools/WindowsLauncher/Valour.WindowsLauncher.csproj | |
| -c Release | |
| -r win-x64 | |
| -p:Version=${{ needs.check-version.outputs.version }} | |
| -p:InformationalVersion=v${{ needs.check-version.outputs.version }} | |
| -o ./artifacts/launcher | |
| - name: Build release executable | |
| shell: pwsh | |
| run: | | |
| $launcherPath = Join-Path $PWD "artifacts/launcher/Valour.exe" | |
| $payloadPath = Join-Path $PWD "artifacts/valour-payload.zip" | |
| $launcherOutputPath = Join-Path $PWD "artifacts/ValourLauncher.exe" | |
| $outputPath = Join-Path $PWD "artifacts/Valour-full.exe" | |
| Copy-Item $launcherPath $launcherOutputPath -Force | |
| Copy-Item $launcherPath $outputPath -Force | |
| $payloadLength = (Get-Item $payloadPath).Length | |
| $lengthBytes = [System.BitConverter]::GetBytes([Int64]$payloadLength) | |
| $markerBytes = [System.Text.Encoding]::ASCII.GetBytes("VALOURP1") | |
| $outStream = [System.IO.File]::Open($outputPath, [System.IO.FileMode]::Append, [System.IO.FileAccess]::Write, [System.IO.FileShare]::Read) | |
| $payloadStream = [System.IO.File]::OpenRead($payloadPath) | |
| $payloadStream.CopyTo($outStream) | |
| $outStream.Write($lengthBytes, 0, $lengthBytes.Length) | |
| $outStream.Write($markerBytes, 0, $markerBytes.Length) | |
| $payloadStream.Dispose() | |
| $outStream.Dispose() | |
| if (!(Test-Path $outputPath)) { | |
| throw "Final full release executable was not created." | |
| } | |
| if (!(Test-Path $launcherOutputPath)) { | |
| throw "Final launcher executable was not created." | |
| } | |
| - name: Zip full release executable | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path ./artifacts/Valour-full.exe -DestinationPath ./artifacts/Valour-full.zip -Force | |
| if (!(Test-Path "./artifacts/Valour-full.zip")) { | |
| throw "Final full release archive was not created." | |
| } | |
| # TODO: Enable once SSL.com cert is validated and eSigner is enrolled | |
| # - name: Sign executable | |
| # uses: sslcom/esigner-codesign@develop | |
| # with: | |
| # command: sign | |
| # username: ${{ secrets.ES_USERNAME }} | |
| # password: ${{ secrets.ES_PASSWORD }} | |
| # credential_id: ${{ secrets.ES_CREDENTIAL_ID }} | |
| # totp_secret: ${{ secrets.ES_TOTP_SECRET }} | |
| # file_path: ./artifacts/Valour-full.exe | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| name: Valour v${{ needs.check-version.outputs.version }} | |
| files: | | |
| ./artifacts/Valour-full.zip | |
| ./artifacts/ValourLauncher.exe | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |