Update Directory.Build.props #54
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: Deploy Blazor WASM to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # The net10.0 test executable needs the .NET 10 runtime. | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '10.0.x' | |
| # The repo's global.json pins a .NET 11 preview SDK (rollForward: latestMajor, allowPrerelease), | |
| # so every dotnet command needs an SDK >= 11. The exact pinned build is often gone from the feed, | |
| # but rollForward accepts any newer 11.x — so install the latest 11.0 preview by channel rather | |
| # than via global-json-file (which would try to fetch that exact, missing build). | |
| - name: Setup .NET 11 (preview, required by global.json) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '11.0.x' | |
| dotnet-quality: preview | |
| # The app sets WasmEnableThreads, whose multithreaded runtime (the one carrying | |
| # JavaScriptExports.InstallMainSynchronizationContext) ships in the wasm-tools workload. Without | |
| # it the build emits a single-threaded runtime that aborts at start_runtime in the browser. | |
| - name: Install wasm-tools workload | |
| run: dotnet workload install wasm-tools | |
| - name: Build tests (also publishes the Blazor app for snapshot tests) | |
| run: dotnet build src/GeoConvert.Web.Tests --configuration Release | |
| # TUnit ships as an executable on Microsoft.Testing.Platform; run it directly rather than via | |
| # `dotnet test`, which rejects it under the VSTest path. | |
| - name: Run tests | |
| run: dotnet src/GeoConvert.Web.Tests/bin/Release/net10.0/GeoConvert.Web.Tests.dll | |
| - name: Publish | |
| run: dotnet publish src/GeoConvert.Web --configuration Release --output publish | |
| - name: Update base href for GitHub Pages | |
| run: sed -i 's|<base href="/" />|<base href="/GeoConvert/" />|g' publish/wwwroot/index.html | |
| - name: Add .nojekyll file | |
| run: touch publish/wwwroot/.nojekyll | |
| - name: Copy index.html to 404.html for SPA routing | |
| run: cp publish/wwwroot/index.html publish/wwwroot/404.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: publish/wwwroot | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |