fail2ban-rs 1.2.1

A pure-Rust fail2ban replacement. Single static binary, fast two-phase matching, nftables/iptables firewall backends.
Documentation
name: Release

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  CARGO_INCREMENTAL: "0"

jobs:
  build:
    name: Build ${{ matrix.os_arch }}
    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os_arch: linux-amd64
            runner: ubuntu-latest
          - os_arch: linux-arm64
            runner: ubuntu-24.04-arm

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Get version from tag
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          echo "VERSION=$VERSION" >> $GITHUB_ENV

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

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          prefix-key: "release-${{ matrix.os_arch }}"

      - name: Build
        run: cargo build --release

      - name: Strip binary
        run: strip target/release/fail2ban-rs

      - name: Package
        run: |
          ARTIFACT="fail2ban-rs-${VERSION}-${{ matrix.os_arch }}"
          mkdir -p dist/${ARTIFACT}
          cp target/release/fail2ban-rs dist/${ARTIFACT}/
          cp dist/fail2ban-rs.service dist/${ARTIFACT}/
          cp config/default.toml dist/${ARTIFACT}/config.toml
          cp LICENSE dist/${ARTIFACT}/ 2>/dev/null || true
          cp README.md dist/${ARTIFACT}/ 2>/dev/null || true
          cd dist
          tar -czf ${ARTIFACT}.tar.gz ${ARTIFACT}
          sha256sum ${ARTIFACT}.tar.gz > ${ARTIFACT}.tar.gz.sha256

      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.os_arch }}
          path: dist/fail2ban-rs-${{ env.VERSION }}-${{ matrix.os_arch }}.tar.gz*

  release:
    name: Create GitHub Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v8
        with:
          path: artifacts
          merge-multiple: true

      - name: List artifacts
        run: ls -la artifacts/

      - name: Create Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        uses: softprops/action-gh-release@v2
        with:
          files: artifacts/*
          generate_release_notes: true