pdmt 1.0.1

High-performance, deterministic templating library for Model Context Protocol (MCP) applications with comprehensive todo validation and quality enforcement
name: Release

on:
  push:
    tags:
      - 'v*.*.*'

env:
  CARGO_TERM_COLOR: always

jobs:
  create-release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Extract version from tag
      id: extract_version
      run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        body: |
          ## What's Changed
          
          See [CHANGELOG.md](https://github.com/noahshinn/pdmt/blob/main/CHANGELOG.md) for full details.
          
          ## Installation
          
          ```toml
          [dependencies]
          pdmt = "${{ steps.extract_version.outputs.VERSION }}"
          ```
          
          ## Verification
          
          All releases are signed and can be verified with:
          
          ```bash
          cargo install pdmt --version ${{ steps.extract_version.outputs.VERSION }}
          ```
        draft: false
        prerelease: false

  test-release:
    name: Test Release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

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

    - name: Run full test suite
      run: |
        cargo test --all-features --release
        cargo run --example todo_generation --features="all" --release

    - name: Test documentation
      run: cargo test --doc --all-features --release

  publish-crates:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: [create-release, test-release]
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

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

    - name: Verify version matches tag
      run: |
        TAG_VERSION=${GITHUB_REF#refs/tags/v}
        CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
        if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
          echo "Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
          exit 1
        fi

    - name: Login to crates.io
      run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}

    - name: Publish to crates.io
      run: cargo publish --all-features

    - name: Verify publication
      run: |
        sleep 30  # Wait for crates.io to process
        TAG_VERSION=${GITHUB_REF#refs/tags/v}
        cargo search pdmt | grep "pdmt = \"$TAG_VERSION\""

  build-binaries:
    name: Build Release Binaries
    runs-on: ${{ matrix.os }}
    needs: create-release
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            name: pdmt-x86_64-linux.tar.gz
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            name: pdmt-x86_64-windows.zip
          - os: macos-latest
            target: x86_64-apple-darwin
            name: pdmt-x86_64-macos.tar.gz

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

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

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

    - name: Create archive (Unix)
      if: matrix.os != 'windows-latest'
      run: |
        cd target/${{ matrix.target }}/release
        tar czf ../../../${{ matrix.name }} pdmt
        cd -

    - name: Create archive (Windows)
      if: matrix.os == 'windows-latest'
      run: |
        cd target/${{ matrix.target }}/release
        7z a ../../../${{ matrix.name }} pdmt.exe
        cd -

    - name: Upload release asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ needs.create-release.outputs.upload_url }}
        asset_path: ./${{ matrix.name }}
        asset_name: ${{ matrix.name }}
        asset_content_type: application/octet-stream