wavetools 0.1.2

Command-line tools for digital simulation waveform analysis -- read, filter, and diff FST and VCD files
Documentation
# ------------------------------------------------------------------------------
# release.yml
# Build release binaries for all Verilator CI platforms and publish GitHub
# Releases when a version tag is pushed.
#
# Trigger manually via "Run workflow" on any branch to test without releasing.
#
# SPDX-FileCopyrightText: Hudson River Trading
# SPDX-License-Identifier: MIT
# ------------------------------------------------------------------------------

name: Release

on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

permissions:
  contents: write          # needed to create GitHub Releases

jobs:
  build:
    name: Build | ${{ matrix.name }}
    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: linux-x86_64
            runner: ubuntu-22.04
            target: x86_64-unknown-linux-gnu
            archive: tar.gz
          - name: macos-arm64
            runner: macos-15
            target: aarch64-apple-darwin
            archive: tar.gz
          - name: windows-x86_64
            runner: windows-2025
            target: x86_64-pc-windows-msvc
            archive: zip

    steps:
      - uses: actions/checkout@v4

      - name: Verify tag matches Cargo.toml version
        if: github.ref_type == 'tag'
        shell: bash
        run: |
          cargo_version=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')
          tag_version="${{ github.ref_name }}"
          tag_version="${tag_version#v}"
          if [[ "$cargo_version" != "$tag_version" ]]; then
            echo "::error::Tag version ($tag_version) does not match Cargo.toml version ($cargo_version)"
            exit 1
          fi

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - uses: Swatinem/rust-cache@v2

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Determine version tag
        id: version
        shell: bash
        run: |
          if [[ "${{ github.ref_type }}" == "tag" ]]; then
            echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
          else
            echo "tag=dev-${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"
          fi

      - name: Package (unix)
        if: matrix.archive == 'tar.gz'
        shell: bash
        run: |
          dir="wavetools-${{ steps.version.outputs.tag }}-${{ matrix.name }}"
          mkdir "$dir"
          cp target/${{ matrix.target }}/release/wavecat "$dir/"
          cp target/${{ matrix.target }}/release/wavediff "$dir/"
          tar czf "${dir}.tar.gz" "$dir"

      - name: Package (windows)
        if: matrix.archive == 'zip'
        shell: bash
        run: |
          dir="wavetools-${{ steps.version.outputs.tag }}-${{ matrix.name }}"
          mkdir "$dir"
          cp target/${{ matrix.target }}/release/wavecat.exe "$dir/"
          cp target/${{ matrix.target }}/release/wavediff.exe "$dir/"
          7z a "${dir}.zip" "$dir"

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: wavetools-${{ matrix.name }}
          path: wavetools-*.${{ matrix.archive }}

  release:
    name: Publish GitHub Release
    if: github.ref_type == 'tag'
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          merge-multiple: true

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: |
            wavetools-*.tar.gz
            wavetools-*.zip

  publish:
    name: Publish to crates.io
    if: github.ref_type == 'tag'
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Verify tag is on main
        run: |
          if ! git merge-base --is-ancestor "${{ github.sha }}" origin/main; then
            echo "::error::Tag is not on the main branch -- skipping publish"
            exit 1
          fi

      - uses: dtolnay/rust-toolchain@stable

      - name: Publish
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}