wryme 1.7.5

wryme • that small, calm window where agents come to meet you
name: Release

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

permissions:
  contents: write

jobs:
  publish-crates:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Publish to crates.io
        run: cargo publish --allow-dirty
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

  desktop:
    needs: [publish-crates]
    defaults:
      run:
        shell: bash
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: macos-14
            target: aarch64-apple-darwin
            package: desktop/package-macos.sh
            artifact: wryme-darwin-arm64.zip
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            package: desktop/package-windows.sh
            artifact: wryme-windows-x86_64.zip
          - os: ubuntu-22.04
            target: x86_64-unknown-linux-gnu
            package: desktop/package-linux.sh
            artifact: wryme-linux-x86_64.deb
    runs-on: ${{ matrix.os }}
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4

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

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

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

      - name: Locate built binary
        id: binary
        run: |
          bin="target/${{ matrix.target }}/release/wme"
          if [[ "${{ runner.os }}" == "Windows" ]]; then bin="$bin.exe"; fi
          echo "BIN=$bin" >> "$GITHUB_ENV"
          [[ -f "$bin" ]] || { echo "missing $bin" >&2; exit 1; }

      - name: Package desktop bundle
        run: |
          bash "${{ matrix.package }}" "${GITHUB_REF_NAME#v}" "${{ matrix.target }}"
          ls -la dist/* wryme* *.zip *.tar.gz *.deb 2>/dev/null || true
          # normalize: package scripts may put artifacts in dist/ or cwd, ensure cwd has it for upload
          for f in dist/*.zip dist/*.tar.gz dist/*.deb; do [[ -f "$f" ]] && cp "$f" . 2>/dev/null || true; done
          ls -la *.zip *.tar.gz *.deb 2>/dev/null || true

      - name: Upload bundle artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: |
            dist/${{ matrix.artifact }}
            ${{ matrix.artifact }}
          if-no-files-found: error

  release:
    needs: [publish-crates, desktop]
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4

      - name: Download all bundles
        uses: actions/download-artifact@v4
        with:
          path: bundles
          merge-multiple: true

      - name: Create GitHub release with bundles
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          TAG="${GITHUB_REF_NAME}"
          FILES=()
          for f in bundles/*.zip bundles/*.tar.gz bundles/*.deb; do
            [[ -f "$f" ]] && FILES+=("$f")
          done
          gh release create "$TAG" \
            --title "$TAG" \
            --generate-notes \
            "${FILES[@]}"