rwasm 0.4.3

ZK-friendly WebAssembly runtime optimized for blockchain and zero-knowledge applications
Documentation
name: Publish to crates.io

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+*"
  workflow_dispatch:
    inputs:
      dry_run:
        description: "Dry run only (verify without publishing)"
        required: false
        default: false
        type: boolean

env:
  CARGO_TERM_COLOR: always

jobs:
  publish:
    name: Publish to crates.io
    runs-on: [ self-hosted, linux ]

    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Extract and sanitize version
        id: extract_version
        run: |
          VERSION="${GITHUB_REF_NAME}"
          VERSION="${VERSION//\//-}"
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      - name: Verify crate version matches tag
        run: |
          tag="${{ steps.extract_version.outputs.version }}"
          tag="${tag#v}"
          cargo_ver=$(grep -m1 '^version' Cargo.toml | awk -F'=' '{print $2}' | tr -d ' "')
          [[ "$tag" == "$cargo_ver"* ]] || {
            echo "Tag $tag doesn't match the Cargo version $cargo_ver"
            exit 1
          }

      - name: Verify package
        run: cargo publish --dry-run

      - name: Publish to crates.io
        if: ${{ github.event_name != 'workflow_dispatch' || !inputs.dry_run }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish