agentmail 0.1.8

IMAP email client, MCP server, and CLI — read, search, delete, unsubscribe, and manage mailboxes
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

concurrency:
  group: release-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always

jobs:
  validate:
    name: Validate Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.94
        with:
          components: rustfmt, clippy

      - name: Cache cargo registry
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-release-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-release-cargo-

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Run tests
        run: cargo test --all-features

  build-binaries:
    name: Build (${{ matrix.name }})
    needs: validate
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - name: linux-x86_64
            os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            binary: agentmail
            archive: agentmail-linux-x86_64.tar.gz
          - name: linux-aarch64
            os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
            binary: agentmail
            archive: agentmail-linux-aarch64.tar.gz
          - name: macos-x86_64
            os: macos-latest
            target: x86_64-apple-darwin
            binary: agentmail
            archive: agentmail-macos-x86_64.tar.gz
          - name: macos-aarch64
            os: macos-latest
            target: aarch64-apple-darwin
            binary: agentmail
            archive: agentmail-macos-aarch64.tar.gz
          - name: windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            binary: agentmail.exe
            archive: agentmail-windows-x86_64.zip
    steps:
      - uses: actions/checkout@v6

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

      - name: Cache cargo registry
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-${{ matrix.target }}-release-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.target }}-release-cargo-

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

      - name: Package (unix)
        if: runner.os != 'Windows'
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ../../../${{ matrix.archive }} ${{ matrix.binary }}
          cd ../../..

      - name: Package (windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Compress-Archive -Path "target/${{ matrix.target }}/release/${{ matrix.binary }}" -DestinationPath "${{ matrix.archive }}"

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

  # Build macOS universal binary from the two arch-specific builds
  build-macos-universal:
    name: Build (macos-universal)
    needs: build-binaries
    runs-on: macos-latest
    steps:
      - name: Download macOS artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Create universal binary
        run: |
          mkdir -p work
          cd work
          tar xzf ../artifacts/macos-aarch64/agentmail-macos-aarch64.tar.gz
          mv agentmail agentmail-arm64
          tar xzf ../artifacts/macos-x86_64/agentmail-macos-x86_64.tar.gz
          mv agentmail agentmail-x86_64
          lipo -create -output agentmail agentmail-arm64 agentmail-x86_64
          file agentmail
          tar czf ../agentmail-macos-universal.tar.gz agentmail

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: macos-universal
          path: agentmail-macos-universal.tar.gz

  create-release:
    name: Create GitHub Release
    needs: [build-binaries, build-macos-universal]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Collect release assets
        run: |
          mkdir -p release
          cp artifacts/linux-x86_64/*.tar.gz release/
          cp artifacts/linux-aarch64/*.tar.gz release/
          cp artifacts/macos-x86_64/*.tar.gz release/
          cp artifacts/macos-aarch64/*.tar.gz release/
          cp artifacts/macos-universal/*.tar.gz release/
          cp artifacts/windows-x86_64/*.zip release/
          ls -lh release/

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: release/*

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

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

      - name: Update lockfile
        run: cargo generate-lockfile

      - name: Publish agentmail (library + binary + mcp)
        run: cargo publish -p agentmail
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}