memex-cli 0.1.0

A CLI tool for organizing AI-assisted development into a versioned, navigable DAG of conversation nodes.
name: Release

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

permissions:
  contents: write

jobs:
  build:
    name: build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            archive: tar.gz
          - target: aarch64-apple-darwin
            os: macos-latest
            archive: tar.gz
          - target: x86_64-apple-darwin
            os: macos-latest
            archive: tar.gz
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            archive: zip
    steps:
      - uses: actions/checkout@v4

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

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

      - name: Package (unix)
        if: matrix.archive == 'tar.gz'
        shell: bash
        run: |
          archive="memex-${GITHUB_REF_NAME}-${{ matrix.target }}.tar.gz"
          tar -C "target/${{ matrix.target }}/release" -czvf "$archive" memex
          shasum -a 256 "$archive" > "$archive.sha256"

      - name: Package (windows)
        if: matrix.archive == 'zip'
        shell: pwsh
        run: |
          $archive = "memex-$env:GITHUB_REF_NAME-${{ matrix.target }}.zip"
          Compress-Archive -Path "target\${{ matrix.target }}\release\memex.exe" -DestinationPath $archive
          $hash = (Get-FileHash -Algorithm SHA256 $archive).Hash.ToLower()
          "$hash  $archive" | Out-File -Encoding ASCII "$archive.sha256"

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: memex-${{ matrix.target }}
          path: |
            memex-*.tar.gz
            memex-*.zip
            memex-*.sha256

  release:
    name: Create GitHub release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/download-artifact@v4
        with:
          path: artifacts
          merge-multiple: true

      - name: Publish draft release
        uses: softprops/action-gh-release@v2
        with:
          draft: true
          name: ${{ github.ref_name }}
          tag_name: ${{ github.ref_name }}
          generate_release_notes: true
          files: artifacts/*

  publish-crate:
    name: Publish to crates.io
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable

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