name: Build updateResolver and publish

on:
  push:
    tags:
    - 'v*'
   
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: Create build
      run: ./publish.sh
    
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        draft: false
        prerelease: false
    # Upload Linux
    - name: Upload Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        asset_path: ./publish/NebulaLauncher_linux64.zip
        asset_name: NebulaLauncher_linux64.zip
        asset_content_type: application/zip

    # Upload Windows
    - name: Upload Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        asset_path: ./publish/NebulaLauncher_win64.zip
        asset_name: NebulaLauncher_win64.zip
        asset_content_type: application/zip
