name: Rust

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  Linux-App:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Install deps
      run: sudo apt-get install -y binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf python3-pip python3-setuptools squashfs-tools strace util-linux zsync libgtk-3-dev
    - name: Download appimagekit
      run: sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool
    - name: Make appimagetool exec
      run: sudo chmod +x /usr/local/bin/appimagetool
    - name: Install cargo-appimage
      run: cargo install cargo-appimage
    - name: Build executable
      working-directory: ./config_app
      run: cargo build --verbose --release
    - name: Build appimage
      working-directory: ./config_app
      run: cargo appimage
    - uses: actions/upload-artifact@v3
      with:
        name: config-app-appimage
        path: config_app/*.AppImage
        
  Windows-App:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: win32
      - name: Install Rustup using win.rustup.rs
        run: |
          $ProgressPreference = "SilentlyContinue"
          Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
          .\rustup-init.exe -y --default-host=i686-pc-windows-msvc --default-toolchain=none
          del rustup-init.exe
          rustup target add i686-pc-windows-msvc
        shell: powershell
      - name: Build executable
        working-directory: ./config_app
        run: cargo build --verbose --release --target i686-pc-windows-msvc
      - uses: actions/upload-artifact@v3
        with:
          name: config-app-exe
          path: config_app/target/**/*.exe
      
          
       
