name: Build Library
run-name: ${{ gitea.actor }}
on:
  push:
    branches:
    - RustImplementation
    paths:
    - airlock_libs/**

jobs:
  Build Library:
    runs-on: debian-stable
    steps:
      - name: Install Prerequisites
        run: |
          apt update
          apt install curl git python3 pip pkg-config openssl libssl-dev patchelf binutils-mingw-w64-x86-64 mingw-w64 -y
          curl https://sh.rustup.rs -sSf | sh -s -- -y
          pip install maturin twine --break-system-packages

      - name: Pull Repository
        run: |
          git clone https://brotoskyj:${{ secrets.RUNNER_TOKEN }}@git.racooncity.org/brotoskyj/AirlockTools --branch RustImplementation

      - name: Compile Library and Upload
        run: |
          export TWINE_USERNAME=brotoskyj
          export TWINE_PASSWORD=${{ secrets.RUNNER_TOKEN }}
          export TWINE_REPOSITORY_URL=https://git.racooncity.org/api/packages/brotoskyj/pypi
          . "$HOME/.cargo/env"
          rustup target add x86_64-pc-windows-gnu
          cd AirlockTools/airlock_libs
          cargo clean
          cargo fmt
          cargo clippy --fix --all-targets --allow-dirty
          maturin build --target x86_64-unknown-linux-gnu -i python3.13 --release --strip
          maturin build --target x86_64-pc-windows-gnu -i python3.13 --release --strip
          python3 -m twine upload target/wheels/*
