xmaster 1.8.0

Enterprise-grade X/Twitter CLI — post, reply, like, retweet, DM, search, and more
name: Release

on:
  push:
    tags: ['v*']

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: xmaster
            asset_name: xmaster-x86_64-linux
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: xmaster
            asset_name: xmaster-aarch64-darwin
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact: xmaster
            asset_name: xmaster-x86_64-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: xmaster.exe
            asset_name: xmaster-x86_64-windows.exe
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}
      - run: cargo build --release --locked --target ${{ matrix.target }}
      - name: Rename artifact
        shell: bash
        run: cp target/${{ matrix.target }}/release/${{ matrix.artifact }} ${{ matrix.asset_name }}
      - name: Upload to release
        uses: softprops/action-gh-release@v3.0.0
        with:
          files: ${{ matrix.asset_name }}

  # Publish the new version to crates.io. Idempotent: skips if already published.
  # Requires the CARGO_REGISTRY_TOKEN secret; warns and skips if it is absent.
  # Homebrew is bumped separately by the self-polling workflow in paperfoot/homebrew-tap.
  publish-crate:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          set -euo pipefail
          if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then
            echo "::warning::CARGO_REGISTRY_TOKEN not set — skipping crates.io publish."
            echo "Add it with: gh secret set CARGO_REGISTRY_TOKEN -R paperfoot/xmaster-cli"
            exit 0
          fi
          VERSION=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"(.*)".*/\1/')
          if curl -fsSL "https://index.crates.io/xm/as/xmaster" | grep -q "\"vers\":\"${VERSION}\""; then
            echo "xmaster ${VERSION} already on crates.io — skipping."
          else
            cargo publish --locked
          fi