name: Build updateResolver and publish

on:
  workflow_dispatch:
  # schedule:
   # - cron: '0 10 * * *'
   
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Install dependencies
      run: sudo apt-get install -y python3-paramiko python3-lxml
    - uses: actions/checkout@v3.6.0
      with:
        submodules: 'recursive'
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v3.2.0
      with:
        dotnet-version: 9.0.x
    - name: Install dependencies
      run: dotnet restore
    - name: Build Update resolver
      run: dotnet publish -c Release -r win-x64 -o ~/publish -p:IncludeNativeLibrariesForSelfExtract=true Nebula.UpdateResolver
    - name: Build Updater for linux
      run: dotnet publish -c Release -r linux-x64 -o ~/publish -p:IncludeNativeLibrariesForSelfExtract=true Nebula.UpdateResolver
    - name: Rename file
      run: mv ~/publish/Nebula.UpdateResolver.exe ~/publish/NebulaLauncher.exe
    - name: Rename file
      run: mv ~/publish/Nebula.UpdateResolver.pdb ~/publish/NebulaLauncher.pdb
    - name: Rename file
      run: mv ~/publish/Nebula.UpdateResolver ~/publish/NebulaLauncher
    - name: FTP Deploy Release
      uses: SamKirkland/FTP-Deploy-Action@v4.3.5
      with:
        server: ${{ secrets.FTP_SERVER }}
        username: ${{ secrets.FTP_USERNAME }}
        password: ${{ secrets.FTP_PASSWORD }}
        local-dir: /home/runner/publish/
        server-dir: ./publish/
