adsb-anomaly 0.2.2

A sophisticated real-time anomaly detection system for ADS-B aircraft data with multi-tier detection algorithms, real-time web dashboard, and production-grade architecture built in Rust
name: Release

on:
    push:
        branches:
            - main
        paths:
            - "Cargo.toml"

jobs:
    check-version:
        runs-on: ubuntu-latest
        outputs:
            version: ${{ steps.get-version.outputs.version }}
            version_changed: ${{ steps.check-version.outputs.changed }}
        steps:
            - name: Checkout code
              uses: actions/checkout@v3
              with:
                  fetch-depth: 2

            - name: Get current version
              id: get-version
              run: |
                  VERSION=$(grep -m 1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
                  echo "version=$VERSION" >> $GITHUB_OUTPUT

            - name: Check if version changed
              id: check-version
              run: |
                  git diff HEAD^ HEAD -- Cargo.toml | grep -q '^[+-]version = ' && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT

    release:
        needs: check-version
        if: needs.check-version.outputs.version_changed == 'true'
        runs-on: ubuntu-latest
        steps:
            - name: Checkout code
              uses: actions/checkout@v3

            - name: Set up Rust
              uses: actions-rs/toolchain@v1
              with:
                  toolchain: stable
                  override: true

            - name: Build
              run: cargo build --release

            - name: Run tests
              run: cargo test

            - name: Create tag
              run: |
                  VERSION=${{ needs.check-version.outputs.version }}
                  git config --local user.email "github-actions[bot]@users.noreply.github.com"
                  git config --local user.name "github-actions[bot]"
                  git tag -a "v$VERSION" -m "Release v$VERSION"
                  git push origin "v$VERSION"

            - name: Create GitHub Release
              uses: softprops/action-gh-release@v1
              with:
                  tag_name: v${{ needs.check-version.outputs.version }}
                  name: Release v${{ needs.check-version.outputs.version }}
                  draft: false
                  prerelease: false
                  generate_release_notes: true
              env:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

            - name: Publish to crates.io
              uses: katyo/publish-crates@v2
              with:
                  registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}