mermaid-cli 0.7.1

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
            name: mermaid-linux-x86_64.tar.gz
            command: build

          - release_for: Linux-aarch64
            os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            bin: mermaid
            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
            name: mermaid-windows-x86_64.zip
            command: build

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

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

    runs-on: ${{ matrix.platform.os }}
    steps:
      - uses: actions/checkout@v4

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

      - name: Cache cargo registry
        uses: Swatinem/rust-cache@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 }}
          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 }}
          cd -

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.platform.name }}
          path: ${{ matrix.platform.name }}

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

      - name: Download artifacts
        uses: actions/download-artifact@v4
        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: Create Release
        uses: softprops/action-gh-release@v2
        with:
          files: ./artifacts/**/*
          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@v4

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

      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}