name: Build Windows #Запускаем только кнопкой "Run workflow" в Actions -> Build Windows on: workflow_dispatch: jobs: build: runs-on: Windows steps: - name: Checkout code uses: actions/checkout@v3 - name: Cache NPM dependencies uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - name: Install Node.js uses: actions/setup-node@v3 with: node-version: '22' - name: Install npm dependencies run: npm install - name: Build the application run: npm run kernel:win - name: Upload build to SFTP shell: powershell run: | # Установка модуля Posh-SSH [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-Module -Name Posh-SSH -Force -Scope CurrentUser -AllowClobber # Получаем файл для загрузки $file = Get-ChildItem -Path "dist/builds/win/x64/Rosetta-*.exe" | Select-Object -First 1 if (-not $file) { Write-Error "Build file not found in dist/builds/win/x64/" exit 1 } Write-Host "Found file: $($file.Name)" # Создаем credential $securePassword = ConvertTo-SecureString "${{ secrets.SSH_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("${{ secrets.SSH_USERNAME }}", $securePassword) # Подключаемся к SFTP Write-Host "Connecting to SFTP server..." $session = New-SFTPSession -ComputerName "${{ secrets.SSH_HOST }}" ` -Credential $credential ` -Port ${{ secrets.SSH_PORT }} ` -AcceptKey # Удаляем старые файлы в целевой директории Write-Host "Cleaning remote directory: ${{ secrets.SSH_TARGET_DIR }}" $remoteFiles = Get-SFTPChildItem -SessionId $session.SessionId -Path "${{ secrets.SSH_TARGET_DIR }}" foreach ($remoteFile in $remoteFiles) { Remove-SFTPItem -SessionId $session.SessionId -Path $remoteFile.FullName -Force Write-Host "Deleted: $($remoteFile.FullName)" } # Загружаем новый файл Write-Host "Uploading $($file.Name) to ${{ secrets.SSH_TARGET_DIR }}..." Set-SFTPItem -SessionId $session.SessionId ` -Path $file.FullName ` -Destination "${{ secrets.SSH_TARGET_DIR }}/$($file.Name)" # Закрываем соединение Remove-SFTPSession -SessionId $session.SessionId Write-Host "Upload completed successfully!"