noxy 0.0.7

HTTP forward and reverse proxy with a pluggable tower middleware pipeline
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build ${{ matrix.target }}${{ matrix.variant.suffix }}
    runs-on: ${{ matrix.runner }}
    strategy:
      matrix:
        target:
          - x86_64-unknown-linux-gnu
          - aarch64-unknown-linux-gnu
          - aarch64-apple-darwin
        variant:
          - suffix: ""
            features: cli
          - suffix: "-scripting"
            features: cli,scripting
        exclude:
          - target: aarch64-unknown-linux-gnu
            variant:
              suffix: "-scripting"
        include:
          - target: x86_64-unknown-linux-gnu
            runner: ubuntu-22.04
          - target: aarch64-unknown-linux-gnu
            runner: ubuntu-22.04
          - target: aarch64-apple-darwin
            runner: macos-latest

    steps:
      - uses: actions/checkout@v4

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

      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}${{ matrix.variant.suffix }}

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu
          echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"

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

      - name: Package
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ../../../noxy${{ matrix.variant.suffix }}-${{ matrix.target }}.tar.gz noxy
          cd ../../..

      - uses: actions/upload-artifact@v4
        with:
          name: noxy${{ matrix.variant.suffix }}-${{ matrix.target }}
          path: noxy${{ matrix.variant.suffix }}-${{ matrix.target }}.tar.gz

  docker:
    name: Docker ${{ matrix.tag-suffix || 'default' }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - dockerfile: Dockerfile
            tag-suffix: ""
          - dockerfile: Dockerfile.slim
            features: ""
            tag-suffix: "-slim"
          - dockerfile: Dockerfile.slim
            features: scripting
            tag-suffix: "-scripting"
    steps:
      - uses: actions/checkout@v4

      - uses: docker/setup-buildx-action@v3

      - uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Extract version from tag
        id: version
        run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

      - uses: docker/build-push-action@v6
        with:
          context: .
          file: ${{ matrix.dockerfile }}
          build-args: FEATURES=${{ matrix.features }}
          push: true
          tags: |
            ${{ secrets.DOCKERHUB_USERNAME }}/noxy:${{ steps.version.outputs.version }}${{ matrix.tag-suffix }}
            ${{ secrets.DOCKERHUB_USERNAME }}/noxy:latest${{ matrix.tag-suffix }}

  release:
    name: Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          merge-multiple: true

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: noxy-*.tar.gz