name: Publish
on:
push:
tags: ["v*"]
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
- 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 }}
- 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
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
- name: publish
run: cargo publish --locked --no-verify
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}