name: Build and Upload apt-ostree Debian Package

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  release:
    types: [ published ]

jobs:
  build:
    runs-on: ubuntu-24.04
    
    steps:
    - uses: actions/checkout@v4
    
    - name: Install dependencies
      run: |
        sudo apt update
        sudo apt install -y build-essential devscripts debhelper dh-cargo cargo rustc pkg-config
        sudo apt install -y libostree-dev libglib2.0-dev libcurl4-gnutls-dev libssl-dev libsystemd-dev libmount-dev libselinux1-dev
    
    - name: Build package
      run: |
        ./build.sh
    
    - name: Upload artifacts
      uses: actions/upload-artifact@v4
      with:
        name: apt-ostree-deb-packages
        path: output/
    
    - name: Upload to Forgejo (on release)
      if: github.event_name == 'release'
      run: |
        # Upload to Forgejo Debian repository
        # This would use your Forgejo API token
        echo "Uploading to Forgejo repository..."
        # curl -X POST -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
        #   -F "package=@output/apt-ostree_*.deb" \
        #   https://git.raines.xyz/api/packages/robojerk/debian/upload 