name: Release Checks

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  semver:
    name: Semver (API stability)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: cargo-semver-checks
        uses: obi1kenobi/cargo-semver-checks-action@v2
        with:
          # Each published crate's public API is checked against the last release.
          package: plotkit, plotkit-core

  deny:
    name: cargo-deny (licenses + advisories)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: EmbarkStudios/cargo-deny-action@v2

  wasm:
    name: WASM build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown
      - uses: Swatinem/rust-cache@v2
      - name: Build wasm backend
        run: cargo build -p plotkit-render-wasm --target wasm32-unknown-unknown
