mermaid-cli 0.10.2

Open-source AI pair programmer with agentic capabilities. Local-first with Ollama, native tool calling, and beautiful TUI.
Documentation
name: Release

on:
  push:
    tags:
      - 'v*.*.*'
  workflow_dispatch:
    inputs:
      version:
        description: 'Version to release (e.g., v0.1.0)'
        required: true
        type: string

env:
  CARGO_TERM_COLOR: always

jobs:
  # Create release and build binaries
  release:
    name: Release - ${{ matrix.platform.release_for }}
    strategy:
      fail-fast: false
      matrix:
        platform:
          - release_for: Linux-x86_64
            os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            bin: mermaid
            daemon_bin: mermaidd
            package_suffix: linux-x86_64
            name: mermaid-linux-x86_64.tar.gz
            command: build

          - release_for: Linux-aarch64
            os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            bin: mermaid
            daemon_bin: mermaidd
            package_suffix: linux-aarch64
            name: mermaid-linux-aarch64.tar.gz
            command: build

          - release_for: Windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            bin: mermaid.exe
            daemon_bin: mermaidd.exe
            name: mermaid-windows-x86_64.zip
            command: build

          - release_for: macOS-x86_64
            os: macos-latest
            target: x86_64-apple-darwin
            bin: mermaid
            daemon_bin: mermaidd
            name: mermaid-macos-x86_64.tar.gz
            command: build

          - release_for: macOS-aarch64
            os: macos-latest
            target: aarch64-apple-darwin
            bin: mermaid
            daemon_bin: mermaidd
            name: mermaid-macos-aarch64.tar.gz
            command: build

    runs-on: ${{ matrix.platform.os }}
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@67ef31d5b988238dd797d409d6f9574278e20537 # master
        with:
          toolchain: stable
          targets: ${{ matrix.platform.target }}

      - name: Cache cargo registry
        uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2

      # Install cross-compilation tools for Linux ARM64
      - name: Install cross-compilation tools
        if: matrix.platform.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Build binary
        shell: bash
        run: |
          if [ "${{ matrix.platform.target }}" = "aarch64-unknown-linux-gnu" ]; then
            export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
          fi
          cargo build --verbose --release --target ${{ matrix.platform.target }}

      - name: Package as archive (Linux/macOS)
        if: contains(matrix.platform.os, 'ubuntu') || contains(matrix.platform.os, 'macos')
        run: |
          cd target/${{ matrix.platform.target }}/release
          tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} ${{ matrix.platform.daemon_bin }}
          cd -

      - name: Package as ZIP (Windows)
        if: contains(matrix.platform.os, 'windows')
        run: |
          cd target/${{ matrix.platform.target }}/release
          7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} ${{ matrix.platform.daemon_bin }}
          cd -

      - name: Install Linux packaging tools
        if: contains(matrix.platform.os, 'ubuntu')
        run: |
          cargo install cargo-deb --locked
          cargo install cargo-generate-rpm --locked

      - name: Package Linux distro artifacts
        if: contains(matrix.platform.os, 'ubuntu')
        shell: bash
        run: |
          cargo deb --no-build --target ${{ matrix.platform.target }} --output mermaid-cli-${{ matrix.platform.package_suffix }}.deb
          cargo generate-rpm --target ${{ matrix.platform.target }} --output mermaid-cli-${{ matrix.platform.package_suffix }}.rpm

      - name: Upload artifacts
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: ${{ matrix.platform.name }}
          path: ${{ matrix.platform.name }}

      - name: Upload Linux distro artifacts
        if: contains(matrix.platform.os, 'ubuntu')
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: mermaid-packages-${{ matrix.platform.package_suffix }}
          path: |
            mermaid-cli-${{ matrix.platform.package_suffix }}.deb
            mermaid-cli-${{ matrix.platform.package_suffix }}.rpm

  # Create GitHub release and attach binaries
  publish:
    name: Publish Release
    needs: [release]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

      - name: Download artifacts
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          path: ./artifacts

      - name: Generate changelog
        id: changelog
        run: |
          # Get the previous tag
          PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
          if [ -z "$PREV_TAG" ]; then
            echo "First release" > CHANGELOG.md
          else
            echo "## Changes since $PREV_TAG" > CHANGELOG.md
            git log $PREV_TAG..HEAD --pretty=format:"- %s" >> CHANGELOG.md
          fi

      - name: Generate SHA256 checksums
        run: |
          find artifacts -type f | while IFS= read -r f; do
            ( cd "$(dirname "$f")" && sha256sum "$(basename "$f")" )
          done | sort -k2 > SHA256SUMS
          cat SHA256SUMS

      - name: Create Release
        uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
        with:
          files: |
            ./artifacts/**/*
            SHA256SUMS
          draft: false
          prerelease: false
          generate_release_notes: true
          body_path: CHANGELOG.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  # Optional: Publish to crates.io
  publish-crate:
    name: Publish to crates.io
    needs: [release]
    runs-on: ubuntu-latest
    # Only run if explicitly enabled (requires CARGO_REGISTRY_TOKEN secret)
    if: ${{ vars.PUBLISH_TO_CRATES_IO == 'true' }}
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@67ef31d5b988238dd797d409d6f9574278e20537 # master
        with:
          toolchain: stable

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          # Publish the workspace library first, then the binary crate that
          # depends on it. Recent cargo waits for the dependency to appear on
          # the index before publishing the dependent crate.
          cargo publish -p mermaid-runtime
          cargo publish -p mermaid-cli