netrain 0.2.8

Matrix-style network packet monitor with IP tracking, threat detection and real-time visualization
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:
    inputs:
      version:
        description: 'Version number (e.g., 1.0.0)'
        required: true
        type: string

permissions:
  contents: write
  packages: write
  issues: write
  pull-requests: write

jobs:
  create-release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
      version: ${{ steps.get_version.outputs.version }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        
      - name: Get version
        id: get_version
        run: |
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
          else
            echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
          fi
          
      - name: Generate changelog
        id: changelog
        uses: requarks/changelog-action@v1
        with:
          token: ${{ github.token }}
          tag: v${{ steps.get_version.outputs.version }}
          
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: v${{ steps.get_version.outputs.version }}
          release_name: NetRain v${{ steps.get_version.outputs.version }} - The Matrix Has You
          body: |
            ## ๐ŸŒง๏ธ NetRain v${{ steps.get_version.outputs.version }}
            
            > "The Matrix has you..."
            
            ### ๐ŸŽฏ Highlights
            
            - ๐Ÿš€ **212x faster** packet parsing with zero-allocation architecture
            - ๐Ÿ’š Authentic Matrix rain visualization with Japanese Katakana
            - ๐Ÿ›ก๏ธ Real-time threat detection (DDoS, port scans, suspicious traffic)
            - โšก Blazing fast performance: 60 FPS with < 1ms render cycles
            - ๐ŸŒˆ Multiple visual modes: Matrix, Rainbow, Glitch, Pulse
            - ๐ŸŽจ 3D depth effects with particle systems
            
            ### ๐Ÿ“Š Performance Stats
            
            - **Packet Parsing**: 1.2ns per packet (target: < 100ns) โœ…
            - **Threat Detection**: 29ns per analysis (target: < 50ยตs) โœ…
            - **Matrix Rain**: 142ยตs for 1000 columns (target: < 1ms) โœ…
            - **Character Operations**: 11x faster with lookup tables
            
            ${{ steps.changelog.outputs.changes }}
            
            ### ๐Ÿ”ฅ What's New
            
            See [RELEASE_NOTES.md](https://github.com/${{ github.repository }}/blob/main/RELEASE_NOTES.md) for detailed changes.
            
            ### ๐Ÿ’พ Installation
            
            Download the appropriate binary for your platform below, or install via cargo:
            
            ```bash
            cargo install netrain
            ```
            
            ### ๐Ÿš€ Quick Start
            
            ```bash
            sudo netrain --demo  # See the magic happen
            ```
            
            ---
            
            *"Welcome to the real world."*
          draft: false
          prerelease: false

  build-release:
    name: Build Release - ${{ matrix.os }}
    needs: create-release
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: netrain
            asset_name: netrain-linux-amd64
            install_deps: |
              sudo apt-get update
              sudo apt-get install -y libpcap-dev
              
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            artifact_name: netrain
            asset_name: netrain-linux-musl-amd64
            install_deps: |
              sudo apt-get update
              sudo apt-get install -y musl-tools libpcap-dev
              
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact_name: netrain
            asset_name: netrain-macos-amd64
            install_deps: |
              brew install libpcap
              
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: netrain
            asset_name: netrain-macos-arm64
            install_deps: |
              brew install libpcap
              
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact_name: netrain.exe
            asset_name: netrain-windows-amd64
            install_deps: |
              echo "Windows build - Npcap should be installed by user"
              
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        
      - name: Install dependencies
        run: ${{ matrix.install_deps }}
        
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: ${{ matrix.target }}
          override: true
          
      - name: Build release binary
        run: |
          cargo build --release --target ${{ matrix.target }}
          
      - name: Prepare binary
        run: |
          if [ "${{ matrix.os }}" = "windows-latest" ]; then
            7z a -tzip ${{ matrix.asset_name }}.zip ./target/${{ matrix.target }}/release/${{ matrix.artifact_name }} README.md LICENSE
          else
            chmod +x ./target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
            tar czf ${{ matrix.asset_name }}.tar.gz -C ./target/${{ matrix.target }}/release ${{ matrix.artifact_name }} -C ../../../ README.md LICENSE
          fi
        shell: bash
        
      - name: Upload Release Asset (tar.gz)
        if: matrix.os != 'windows-latest'
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create-release.outputs.upload_url }}
          asset_path: ./${{ matrix.asset_name }}.tar.gz
          asset_name: ${{ matrix.asset_name }}.tar.gz
          asset_content_type: application/gzip
          
      - name: Upload Release Asset (zip)
        if: matrix.os == 'windows-latest'
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create-release.outputs.upload_url }}
          asset_path: ./${{ matrix.asset_name }}.zip
          asset_name: ${{ matrix.asset_name }}.zip
          asset_content_type: application/zip

  publish-crate:
    name: Publish to crates.io
    needs: [create-release, build-release]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        
      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y libpcap-dev
          
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          cargo publish --allow-dirty
          
  create-checksums:
    name: Create Checksums
    needs: [create-release, build-release]
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/github-script@v6
        with:
          script: |
            const fs = require('fs');
            const release = await github.rest.repos.getReleaseByTag({
              owner: context.repo.owner,
              repo: context.repo.repo,
              tag: 'v${{ needs.create-release.outputs.version }}'
            });
            
            for (const asset of release.data.assets) {
              const download = await github.rest.repos.getReleaseAsset({
                owner: context.repo.owner,
                repo: context.repo.repo,
                asset_id: asset.id,
                headers: {
                  'Accept': 'application/octet-stream',
                }
              });
              
              fs.writeFileSync(asset.name, Buffer.from(download.data));
            }
            
      - name: Generate checksums
        run: |
          sha256sum netrain-*.tar.gz netrain-*.zip > checksums.txt || true
          cat checksums.txt
          
      - name: Upload checksums
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create-release.outputs.upload_url }}
          asset_path: ./checksums.txt
          asset_name: checksums.txt
          asset_content_type: text/plain