feat: add ESM static component assets (#360) #176
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: Publish Release | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # ── Step 1: Detect version change ───────────────────────────────────── | |
| check-version: | |
| name: Check Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_publish: ${{ steps.check.outputs.should_publish }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Compare version with latest tag | |
| id: check | |
| run: | | |
| VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)"/\1/') | |
| TAG="v${VERSION}" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists — skipping publish" | |
| echo "should_publish=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Tag $TAG not found — will publish" | |
| echo "should_publish=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| # ── Step 2: Build and stage native artifacts (3 runners, 2 targets each) ─ | |
| # | |
| # Each runner builds native + cross targets, then stages only the native files | |
| # for its platforms into package/runtime directories. The release job later | |
| # merges those staged files and packs npm/NuGet (.nupkg + .snupkg)/crates/WASM once on Linux. | |
| # | |
| # ubuntu-latest (x64) → linux-x64 + linux-arm64 | |
| # macos-latest-large (arm) → darwin-arm64 + darwin-x64 | |
| # windows-latest (x64) → win32-x64 + win32-arm64 | |
| build-linux: | |
| name: Build (Linux x64 + arm64) | |
| needs: check-version | |
| if: needs.check-version.outputs.should_publish == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/build | |
| with: | |
| shared-cache-key: publish-linux | |
| rust-targets: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu | |
| skip-build: 'true' | |
| - name: Install cross-compilation tools (arm64 linker) | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| run: | | |
| sudo apt-get update -q | |
| sudo apt-get install -y -q gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" | |
| - name: Build x64 | |
| run: > | |
| cargo build --release | |
| --target x86_64-unknown-linux-gnu | |
| -p microsoft-webui-cli | |
| -p microsoft-webui-ffi | |
| -p microsoft-webui-node | |
| - name: Build arm64 (cross) | |
| run: > | |
| cargo build --release | |
| --target aarch64-unknown-linux-gnu | |
| -p microsoft-webui-cli | |
| -p microsoft-webui-ffi | |
| -p microsoft-webui-node | |
| - name: Stage native artifacts | |
| run: cargo xtask publish-stage --target all --profile release --native-only | |
| - name: Upload staged native assets | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: stage-linux | |
| path: | | |
| publish/native/ | |
| packages/webui-linux-x64/ | |
| packages/webui-linux-arm64/ | |
| dotnet/runtimes/linux-x64/ | |
| dotnet/runtimes/linux-arm64/ | |
| retention-days: 1 | |
| build-macos: | |
| name: Build (macOS arm64 + x64) | |
| needs: check-version | |
| if: needs.check-version.outputs.should_publish == 'true' | |
| runs-on: macos-latest-large | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/build | |
| with: | |
| shared-cache-key: publish-macos | |
| rust-targets: aarch64-apple-darwin, x86_64-apple-darwin | |
| skip-build: 'true' | |
| - name: Build arm64 (native) | |
| run: > | |
| cargo build --release | |
| --target aarch64-apple-darwin | |
| -p microsoft-webui-cli | |
| -p microsoft-webui-ffi | |
| -p microsoft-webui-node | |
| - name: Build x64 (cross) | |
| run: > | |
| cargo build --release | |
| --target x86_64-apple-darwin | |
| -p microsoft-webui-cli | |
| -p microsoft-webui-ffi | |
| -p microsoft-webui-node | |
| - name: Stage native artifacts | |
| run: cargo xtask publish-stage --target all --profile release --native-only | |
| - name: Upload staged native assets | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: stage-macos | |
| path: | | |
| publish/native/ | |
| packages/webui-darwin-arm64/ | |
| packages/webui-darwin-x64/ | |
| dotnet/runtimes/osx-arm64/ | |
| dotnet/runtimes/osx-x64/ | |
| retention-days: 1 | |
| build-windows: | |
| name: Build (Windows x64 + arm64) | |
| needs: check-version | |
| if: needs.check-version.outputs.should_publish == 'true' | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/build | |
| with: | |
| shared-cache-key: publish-windows | |
| rust-targets: x86_64-pc-windows-msvc, aarch64-pc-windows-msvc | |
| skip-build: 'true' | |
| - name: Build x64 (native) | |
| run: > | |
| cargo build --release | |
| --target x86_64-pc-windows-msvc | |
| -p microsoft-webui-cli | |
| -p microsoft-webui-ffi | |
| -p microsoft-webui-node | |
| - name: Build arm64 (cross) | |
| run: > | |
| cargo build --release | |
| --target aarch64-pc-windows-msvc | |
| -p microsoft-webui-cli | |
| -p microsoft-webui-ffi | |
| -p microsoft-webui-node | |
| - name: Stage native artifacts | |
| run: cargo xtask publish-stage --target all --profile release --native-only | |
| - name: Upload staged native assets | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: stage-windows | |
| path: | | |
| publish/native/ | |
| packages/webui-win32-x64/ | |
| packages/webui-win32-arm64/ | |
| dotnet/runtimes/win-x64/ | |
| dotnet/runtimes/win-arm64/ | |
| retention-days: 1 | |
| # ── Step 3: Merge native assets, pack once, tag, and create release ─── | |
| release: | |
| name: Create Release | |
| needs: [check-version, build-linux, build-macos, build-windows] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/build | |
| with: | |
| shared-cache-key: publish-release | |
| dotnet: '8.0.x' | |
| skip-build: 'true' | |
| # Download and merge all staged native assets from the 3 runners | |
| - name: Download staged native artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: stage-* | |
| path: . | |
| merge-multiple: true | |
| - name: Pack unified release artifacts | |
| run: cargo xtask publish-stage --pack-only --profile release | |
| # List all artifacts for verification | |
| - name: List publish artifacts | |
| run: find publish/ -type f | sort | |
| # Create git tag (re-check to guard against concurrent runs) | |
| - name: Create git tag | |
| env: | |
| VERSION: ${{ needs.check-version.outputs.version }} | |
| run: | | |
| git fetch --tags | |
| if git rev-parse "v${VERSION}" >/dev/null 2>&1; then | |
| echo "::warning::Tag v${VERSION} already exists (concurrent run?). Skipping." | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${VERSION}" -m "Release v${VERSION}" | |
| git push origin "v${VERSION}" | |
| fi | |
| # Create GitHub Release with all artifacts. NuGet artifacts are staged | |
| # here for manual nuget.org publishing until ESRP supports automated | |
| # NuGet publishing for this project. Manual publish still requires | |
| # approved Microsoft package ownership, Microsoft-certificate signing for | |
| # each .nupkg, and signed Authenticode-capable package contents. | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| name: v${{ needs.check-version.outputs.version }} | |
| generate_release_notes: true | |
| files: | | |
| publish/native/* | |
| publish/npm/* | |
| publish/nuget/* | |
| publish/crates/* | |
| publish/wasm/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |