tauri-runtime-servo 0.1.0

Servo bindings to the Tauri runtime — an experimental Tauri runtime backed by the Servo web engine
# Publishes tauri-runtime-servo to crates.io.
#
# Trusted publishing: this workflow exchanges the repository's GitHub OIDC
# token for a short-lived crates.io token (rust-lang/crates-io-auth-action),
# so no crates.io API secret is stored here. The crates.io side must have a
# matching "trusted publishing" rule — see the Publishing section of the
# README for the one-time setup.
#
# Triggered by pushing a v* tag; `workflow_dispatch` runs everything except
# the upload (use it to rehearse a release).

name: Publish

on:
  push:
    tags: ["v*"]
  # Manual runs verify the packaged crate but never publish; use them to
  # rehearse a release.
  workflow_dispatch:

concurrency:
  group: publish-${{ github.ref }}
  cancel-in-progress: false

env:
  CARGO_PROFILE_DEV_DEBUG: 0
  CARGO_PROFILE_DEV_INCREMENTAL: false

jobs:
  verify-package:
    strategy:
      fail-fast: false
      matrix:
        platform:
          - { target: x86_64-pc-windows-msvc, os: windows-latest }
          - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
          - { target: aarch64-apple-darwin, os: macos-latest }

    runs-on: ${{ matrix.platform.os }}
    timeout-minutes: 90

    steps:
      - uses: actions/checkout@v4

      # Servo's repository contains WPT test paths longer than Windows'
      # legacy MAX_PATH; see the note in ci.yml.
      - name: enable long paths (windows only)
        if: contains(matrix.platform.target, 'windows')
        run: git config --global core.longpaths true

      - name: install Servo build dependencies (ubuntu only)
        if: contains(matrix.platform.target, 'linux')
        run: |
          sudo apt-get update
          sudo apt-get install -y libdbus-1-dev libegl1-mesa-dev libfontconfig1-dev libfreetype6-dev libgtk-3-dev libharfbuzz-dev libwebkit2gtk-4.1-dev libx11-dev libxkbcommon-x11-dev lld
          echo "RUSTFLAGS=-C link-arg=-fuse-ld=lld" >> "$GITHUB_ENV"

      - name: install Rust
        uses: dtolnay/rust-toolchain@1.95.0
        with:
          targets: ${{ matrix.platform.target }}

      - uses: Swatinem/rust-cache@v2
        with:
          key: servo-${{ matrix.platform.target }}

      # Packages the crate exactly as crates.io will receive it, unpacks the
      # resulting .crate tarball, and compiles that copy — catching files
      # missing from the package before anything is uploaded. No token is
      # involved and nothing reaches the registry.
      - name: dry-run publish
        run: cargo publish --dry-run --locked --target ${{ matrix.platform.target }}

  publish-crates-io:
    name: Publish to crates.io
    needs: verify-package
    if: >-
      github.event_name == 'push' &&
      startsWith(github.ref, 'refs/tags/v') &&
      needs.verify-package.result == 'success'
    runs-on: ubuntu-latest
    # Must match the environment name configured in the crates.io
    # trusted-publishing rule (README: Publishing).
    environment: crates
    permissions:
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: install Rust
        uses: dtolnay/rust-toolchain@1.95.0

      - name: check tag matches crate version
        run: |
          TAG="${GITHUB_REF_NAME#v}"
          VER="$(sed -n 's/^version *= *"\(.*\)"/\1/p' Cargo.toml | head -n1)"
          if [ "$TAG" != "$VER" ]; then
            echo "::error::tag v$TAG does not match Cargo.toml version $VER"
            exit 1
          fi

      - uses: rust-lang/crates-io-auth-action@v1
        id: auth

      # Verification already ran on all three platforms in verify-package;
      # --no-verify avoids recompiling the whole servo graph here.
      - name: publish
        run: cargo publish --locked --no-verify
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}