fix: MSIX version regex replacing XML declaration #45
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*" | |
| permissions: | |
| contents: write | |
| env: | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| MODEL_URL: "https://huggingface.co/alex-dinh/PP-DocLayoutV3-ONNX/resolve/main/PP-DocLayoutV3.onnx" | |
| MODEL_NAME: "PP-DocLayoutV3.onnx" | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Install AppImage dependencies | |
| run: sudo apt-get update && sudo apt-get install -y fuse libfuse2 | |
| - name: Publish | |
| run: dotnet publish src/RailReader2/RailReader2.csproj -c Release -r linux-x64 --self-contained -o publish/ | |
| - name: Download ONNX model | |
| run: | | |
| mkdir -p models | |
| curl -fL --retry 3 --retry-delay 5 -o "models/$MODEL_NAME" "$MODEL_URL" | |
| - name: Download appimagetool | |
| run: | | |
| curl -fL --retry 3 --retry-delay 5 -o appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage | |
| chmod +x appimagetool | |
| - name: Build AppImage | |
| run: | | |
| mkdir -p AppDir/usr/bin AppDir/models | |
| cp -r publish/* AppDir/usr/bin/ | |
| cp models/$MODEL_NAME AppDir/models/ | |
| # Desktop file and icon | |
| mkdir -p AppDir/usr/share/applications AppDir/usr/share/icons/hicolor/256x256/apps | |
| cp assets/railreader2.desktop AppDir/usr/share/applications/ | |
| cp assets/railreader2.png AppDir/usr/share/icons/hicolor/256x256/apps/ | |
| cp assets/railreader2.desktop AppDir/ | |
| cp assets/railreader2.png AppDir/ | |
| # AppRun entry point | |
| cat > AppDir/AppRun <<'EOF' | |
| #!/bin/bash | |
| SELF="$(readlink -f "$0")" | |
| HERE="${SELF%/*}" | |
| export PATH="${HERE}/usr/bin:${PATH}" | |
| exec "${HERE}/usr/bin/RailReader2" "$@" | |
| EOF | |
| chmod +x AppDir/AppRun | |
| ARCH=x86_64 ./appimagetool AppDir railreader2-linux-x86_64.AppImage | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-appimage | |
| path: railreader2-linux-x86_64.AppImage | |
| build-windows: | |
| 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 Inno Setup | |
| run: choco install innosetup -y | |
| - name: Publish | |
| run: dotnet publish src/RailReader2/RailReader2.csproj -c Release -r win-x64 --self-contained -o publish/ | |
| - name: Download ONNX model | |
| run: | | |
| New-Item -ItemType Directory -Force -Path publish\models | |
| Invoke-WebRequest -Uri "$env:MODEL_URL" -OutFile "publish\models\$env:MODEL_NAME" | |
| - name: Convert PNG to ICO | |
| run: magick assets/railreader2.png -define icon:auto-resize=256,128,64,48,32,16 installer/icon.ico | |
| - name: Build installer | |
| run: | | |
| $version = "${{ github.ref_name }}".TrimStart('v') | |
| & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DAPP_VERSION="$version" installer\railreader2.iss | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-setup | |
| path: installer/output/railreader2-setup-x64.exe | |
| build-msix: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Publish | |
| run: dotnet publish src/RailReader2/RailReader2.csproj -c Release -r win-x64 --self-contained -o publish/msix/ | |
| - name: Download ONNX model | |
| run: | | |
| New-Item -ItemType Directory -Force -Path publish\msix\models | |
| Invoke-WebRequest -Uri "$env:MODEL_URL" -OutFile "publish\msix\models\$env:MODEL_NAME" | |
| - name: Copy MSIX manifest and assets | |
| run: | | |
| Copy-Item msix\Package.appxmanifest -Destination publish\msix\AppxManifest.xml | |
| New-Item -ItemType Directory -Force -Path publish\msix\Assets | |
| Copy-Item msix\Assets\* -Destination publish\msix\Assets\ | |
| - name: Update manifest version | |
| run: | | |
| $version = "${{ github.ref_name }}".TrimStart('v') | |
| # MSIX requires 4-part version (x.y.z.0) | |
| $parts = $version.Split('.') | |
| while ($parts.Count -lt 4) { $parts += '0' } | |
| $msixVersion = ($parts[0..3]) -join '.' | |
| $manifest = Get-Content publish\msix\AppxManifest.xml -Raw | |
| $manifest = $manifest -replace '(<Identity[^>]*)\bVersion="[^"]*"', "`$1Version=`"$msixVersion`"" | |
| [System.IO.File]::WriteAllText("publish\msix\AppxManifest.xml", $manifest, [System.Text.UTF8Encoding]::new($false)) | |
| - name: Build MSIX package | |
| run: | | |
| $makeappx = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\makeappx.exe" -ErrorAction SilentlyContinue | Sort-Object -Descending | Select-Object -First 1 | |
| if (-not $makeappx) { throw "makeappx.exe not found" } | |
| & $makeappx.FullName pack /d publish\msix /p railreader2-win-x64.msix /o | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-msix | |
| path: railreader2-win-x64.msix | |
| release: | |
| needs: [build-linux, build-windows, build-msix] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| make_latest: true | |
| files: | | |
| railreader2-linux-x86_64.AppImage | |
| railreader2-setup-x64.exe | |
| railreader2-win-x64.msix |