diff --git a/.gitea/workflows/darwin.yaml b/.gitea/workflows/darwin.yaml new file mode 100644 index 0000000..89705c4 --- /dev/null +++ b/.gitea/workflows/darwin.yaml @@ -0,0 +1,72 @@ +name: MacOS Kernel Build + +#Запускаем только кнопкой "Run workflow" в Actions -> Build MacOS +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'lib/**' + +jobs: + build: + runs-on: macos + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + + # Кэш npm (тарифы грузятся из ~/.npm-cache на macOS) + - name: Cache npm cache + uses: actions/cache@v5 + with: + path: ${{ env.HOME }}/.npm-cache + key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-npm- + if-no-files-found: ignore + # Кэш для electron-builder + - name: Cache electron-builder + uses: actions/cache@v5 + with: + path: | + ${{ env.HOME }}/Library/Caches/electron-builder + ${{ env.HOME }}/Library/Caches/electron + key: ${{ runner.os }}-electron-builder-${{ hashFiles('**/electron-builder.yml') }} + restore-keys: | + ${{ runner.os }}-electron-builder- + if-no-files-found: ignore + - name: NPM offline setup + shell: bash + run: | + npm config set cache "$HOME/.npm-cache" --global + npm config set prefer-offline true --global + - name: Install npm dependencies + run: npm install --prefer-offline --no-audit --no-fund + - name: Build the application + run: npm run kernel:mac + #Загружаем на удаленный сервер по SSH используя scp и пароль из секретов + #Загружаем из двух папок dist/builds/darwin/x64 и dist/builds/darwin/arm64, так как electron-builder может создавать разные файлы для разных архитектур + #Вызываем файл sshupload.sh и передаем ему параметры из секретов, чтобы не хранить пароль в открытом виде в workflow + - name: Upload to SSH using scp + shell: bash + run: | + chmod +x "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" + sh "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" \ + -l "$GITHUB_WORKSPACE/dist/builds/darwin/x64/Rosetta-*.pkg" \ + -r "${{ secrets.SSH_TARGET_DIR }}/darwin/x64" \ + -s "${{ secrets.SSH_HOST }}" \ + -u "${{ secrets.SSH_USERNAME }}" \ + -p '${{ secrets.SSH_PASSWORD }}' + sh "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" \ + -l "$GITHUB_WORKSPACE/dist/builds/darwin/arm64/Rosetta-*.pkg" \ + -r "${{ secrets.SSH_TARGET_DIR }}/darwin/arm64" \ + -s "${{ secrets.SSH_HOST }}" \ + -u "${{ secrets.SSH_USERNAME }}" \ + -p '${{ secrets.SSH_PASSWORD }}' + \ No newline at end of file diff --git a/.gitea/workflows/linux.yaml b/.gitea/workflows/linux.yaml new file mode 100644 index 0000000..ed1951a --- /dev/null +++ b/.gitea/workflows/linux.yaml @@ -0,0 +1,72 @@ +name: Linux Kernel Build + +#Запускаем только кнопкой "Run workflow" в Actions +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'lib/**' + +jobs: + build: + runs-on: macos + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + + # Кэш npm (тарифы грузятся из ~/.npm-cache на macOS) + - name: Cache npm cache + uses: actions/cache@v5 + with: + path: ${{ env.HOME }}/.npm-cache + key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-npm- + if-no-files-found: ignore + # Кэш для electron-builder + - name: Cache electron-builder + uses: actions/cache@v5 + with: + path: | + ${{ env.HOME }}/Library/Caches/electron-builder + ${{ env.HOME }}/Library/Caches/electron + key: ${{ runner.os }}-electron-builder-${{ hashFiles('**/electron-builder.yml') }} + restore-keys: | + ${{ runner.os }}-electron-builder- + if-no-files-found: ignore + - name: NPM offline setup + shell: bash + run: | + npm config set cache "$HOME/.npm-cache" --global + npm config set prefer-offline true --global + - name: Install npm dependencies + run: npm install --prefer-offline --no-audit --no-fund + - name: Build the application + run: npm run kernel:linux + #Загружаем на удаленный сервер по SSH используя scp и пароль из секретов + #Загружаем из двух папок dist/builds/darwin/x64 и dist/builds/darwin/arm64, так как electron-builder может создавать разные файлы для разных архитектур + #Вызываем файл sshupload.sh и передаем ему параметры из секретов, чтобы не хранить пароль в открытом виде в workflow + - name: Upload to SSH + shell: bash + run: | + chmod +x "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" + sh "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" \ + -l "$GITHUB_WORKSPACE/dist/builds/linux/x64/Rosetta-*.AppImage" \ + -r "${{ secrets.SSH_TARGET_DIR }}/linux/x64" \ + -s "${{ secrets.SSH_HOST }}" \ + -u "${{ secrets.SSH_USERNAME }}" \ + -p '${{ secrets.SSH_PASSWORD }}' + sh "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" \ + -l "$GITHUB_WORKSPACE/dist/builds/linux/arm64/Rosetta-*.AppImage" \ + -r "${{ secrets.SSH_TARGET_DIR }}/linux/arm64" \ + -s "${{ secrets.SSH_HOST }}" \ + -u "${{ secrets.SSH_USERNAME }}" \ + -p '${{ secrets.SSH_PASSWORD }}' + \ No newline at end of file diff --git a/.gitea/workflows/service-packs.yaml b/.gitea/workflows/service-packs.yaml new file mode 100644 index 0000000..008d538 --- /dev/null +++ b/.gitea/workflows/service-packs.yaml @@ -0,0 +1,74 @@ +name: SP Builds + +#Запускаем только кнопкой "Run workflow" в Actions -> Build MacOS +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'lib/**' + +jobs: + build: + runs-on: macos + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + # Кэш npm (тарифы грузятся из ~/.npm-cache на macOS) + - name: Cache npm cache + uses: actions/cache@v5 + with: + path: ${{ env.HOME }}/.npm-cache + key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-npm- + if-no-files-found: ignore + # Кэш для electron-builder (macOS) + - name: Cache electron-builder (macOS) + uses: actions/cache@v5 + with: + path: | + ${{ env.HOME }}/Library/Caches/electron-builder + ${{ env.HOME }}/Library/Caches/electron + key: ${{ runner.os }}-electron-builder-${{ hashFiles('**/electron-builder.yml') }} + restore-keys: | + ${{ runner.os }}-electron-builder- + if-no-files-found: ignore + + - name: NPM offline setup + shell: bash + run: | + npm config set cache "$HOME/.npm-cache" --global + npm config set prefer-offline true --global + + - name: Install npm dependencies + run: npm install --prefer-offline --no-audit --no-fund + + #Собираем Kernel чтобы свежие файлы попали в папку out + - name: Build the application + run: npm run kernel:linux + + #Собираем сервисные пакеты для всех платформ + - name: Build SP + shell: bash + run: | + chmod +x "$GITHUB_WORKSPACE/build-packs.sh" + sh "$GITHUB_WORKSPACE/build-packs.sh" + #Загружаем на удаленный сервер по SSH используя scp и пароль из секретов + #Загружаем из двух папок dist/builds/darwin/x64 и dist/builds/darwin/arm64, так как electron-builder может создавать разные файлы для разных архитектур + - name: Upload to SSH + shell: bash + run: | + chmod +x "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" + sh "$GITHUB_WORKSPACE/.gitea/workflows/sshupload.sh" \ + -l "$GITHUB_WORKSPACE/packs/*" \ + -r "${{ secrets.SDU_SSH_PACKS }}" \ + -s "${{ secrets.SSH_HOST }}" \ + -u "${{ secrets.SSH_USERNAME }}" \ + -p '${{ secrets.SSH_PASSWORD }}' \ No newline at end of file diff --git a/.gitea/workflows/sshupload.ps1 b/.gitea/workflows/sshupload.ps1 new file mode 100644 index 0000000..11281a3 --- /dev/null +++ b/.gitea/workflows/sshupload.ps1 @@ -0,0 +1,355 @@ +# PowerShell script to upload files to SFTP server with remote folder cleanup +# Works on clean Windows without additional utilities (uses WinSCP) + +# ========================================== +# PARAMETERS (can override config values via command line) +# ========================================== +param( + [Parameter(Mandatory=$false, HelpMessage="SFTP server IP address or hostname")] + [string]$ServerAddress, + + [Parameter(Mandatory=$false, HelpMessage="Username for connection")] + [string]$Username, + + [Parameter(Mandatory=$false, HelpMessage="Password for connection")] + [string]$PasswordParam, + + [Parameter(Mandatory=$false, HelpMessage="Local file path or pattern (e.g., C:\files\* or dist/builds/x64/Rosetta-*.exe)")] + [string]$LocalFilePath, + + [Parameter(Mandatory=$false, HelpMessage="Remote folder on server")] + [string]$RemoteFolderPath, + + [Parameter(Mandatory=$false, HelpMessage="SSH port")] + [int]$Port, + + [Parameter(Mandatory=$false, HelpMessage="Path to WinSCP executable (auto-detect if not provided)")] + [string]$WinSCPPath +) + +# ========================================== +# CONFIGURATION - Default fallback values +# ========================================== +# These values are used only if not provided via command-line parameters or environment variables +$CONFIG_ServerAddress = "" +$CONFIG_Username = "" +$CONFIG_Password = "" +$CONFIG_LocalFilePath = "" +$CONFIG_RemoteFolderPath = "" +$CONFIG_Port = 22 +$CONFIG_WinSCPPath = "" + +# Priority: Command-line Parameters (highest) > Environment Variables > Config Values (lowest) +# If parameter not provided via command line, check environment variable, then use config value +if (-not $ServerAddress) { + $ServerAddress = if ($env:SFTP_SERVER) { $env:SFTP_SERVER } else { $CONFIG_ServerAddress } +} +if (-not $Username) { + $Username = if ($env:SFTP_USERNAME) { $env:SFTP_USERNAME } else { $CONFIG_Username } +} +# Если пароль передан через CLI (-PasswordParam), используем его даже если пустая строка +if (-not $PSBoundParameters.ContainsKey('PasswordParam')) { + $PasswordParam = if ($env:SFTP_PASSWORD) { $env:SFTP_PASSWORD } else { $CONFIG_Password } +} +if (-not $LocalFilePath) { + $LocalFilePath = if ($env:SFTP_LOCAL_PATH) { $env:SFTP_LOCAL_PATH } else { $CONFIG_LocalFilePath } +} +if (-not $RemoteFolderPath) { + $RemoteFolderPath = if ($env:SFTP_REMOTE_PATH) { $env:SFTP_REMOTE_PATH } else { $CONFIG_RemoteFolderPath } +} +if (-not $Port -or $Port -eq 0) { + $Port = if ($env:SFTP_PORT) { [int]$env:SFTP_PORT } else { $CONFIG_Port } +} +if (-not $WinSCPPath) { + $WinSCPPath = if ($env:WINSCP_PATH) { $env:WINSCP_PATH } else { $CONFIG_WinSCPPath } +} + +# Validate required parameters +$requiredParams = @( + @{Name = "ServerAddress"; Value = $ServerAddress}, + @{Name = "Username"; Value = $Username}, + @{Name = "PasswordParam"; Value = $PasswordParam}, + @{Name = "LocalFilePath"; Value = $LocalFilePath}, + @{Name = "RemoteFolderPath"; Value = $RemoteFolderPath} +) + +$missingParams = @() +foreach ($param in $requiredParams) { + if ([string]::IsNullOrWhiteSpace($param.Value)) { + $missingParams += $param.Name + } +} + +if ($missingParams.Count -gt 0) { + Write-Host "ERROR: Missing required parameters: $($missingParams -join ', ')" -ForegroundColor Red + Write-Host "Please configure values in the script CONFIG section or pass them as parameters." -ForegroundColor Red + exit 1 +} + +# Logging function +function Write-Log { + param( + [Parameter(Mandatory=$false)] + [string]$Message = "(empty message)", + + [Parameter(Mandatory=$false)] + [ValidateSet("Info", "Warning", "Error", "Success")] + [string]$Level = "Info" + ) + + # Handle null or empty messages + if ([string]::IsNullOrWhiteSpace($Message)) { + $Message = "(empty message)" + } + + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + $color = switch ($Level) { + "Error" { "Red" } + "Warning" { "Yellow" } + "Success" { "Green" } + default { "White" } + } + + Write-Host "[$timestamp] [$Level] $Message" -ForegroundColor $color +} + +# Function to find WinSCP installation +function Find-WinSCP { + $possiblePaths = @( + "C:\Program Files\WinSCP\WinSCP.com", + "C:\Program Files (x86)\WinSCP\WinSCP.com", + "C:\Program Files\WinSCP\WinSCP.exe", + "C:\Program Files (x86)\WinSCP\WinSCP.exe", + "C:\Program Files\WinSCP\WinSCPPortable.exe", + "C:\Program Files (x86)\WinSCP\WinSCPPortable.exe" + ) + + foreach ($path in $possiblePaths) { + if (Test-Path $path) { + Write-Log "Found WinSCP at: $path" "Info" + return $path + } + } + + Write-Log "WinSCP not found. Please install it from https://winscp.net/" "Error" + return $null +} + +# Main upload function using WinSCP +function Upload-ToSFTP { + param( + [Parameter(Mandatory=$true)] + [string]$Server, + + [Parameter(Mandatory=$true)] + [string]$User, + + [Parameter(Mandatory=$true)] + [string]$Pass, + + [Parameter(Mandatory=$true)] + [string[]]$FileList, + + [Parameter(Mandatory=$true)] + [string]$RemotePath, + + [Parameter(Mandatory=$true)] + [int]$PortNum, + + [Parameter(Mandatory=$true)] + [string]$WinSCPExe + ) + + # Decode once if URL-encoded; we will pass plain password via -password switch (no extra encoding needed) + $decodedPassword = if ($Pass -match '%[0-9A-Fa-f]{2}') { [System.Net.WebUtility]::UrlDecode($Pass) } else { $Pass } + + # Create temporary file paths BEFORE script content (needed for variable expansion) + $timestamp = Get-Date -Format 'yyyyMMdd_HHmmss_fff' + $debugDir = Join-Path $env:TEMP "winscp_debug" + if (-not (Test-Path $debugDir)) { + New-Item -ItemType Directory -Path $debugDir -Force | Out-Null + } + $scriptPath = Join-Path $debugDir "script_$timestamp.txt" + $logFile = Join-Path $debugDir "log_$timestamp.txt" + $outputPath = Join-Path $debugDir "output_$timestamp.txt" + $errorPath = Join-Path $debugDir "error_$timestamp.txt" + + # Create WinSCP script file WITH password (use @"..."@ to expand variables) + $scriptContent = @" +option batch abort +option confirm off +option echo off +option reconnecttime 3 +"@ + + # Add connection string with auto-accept of host key; pass password via -password to avoid URL encoding issues + $scriptContent += "`r`nopen sftp://$User@$Server`:$PortNum/ -password=`"$decodedPassword`" -hostkey=`"*`"`r`n" + # Try to clear remote folder by removing all .exe files (ignore if none exist) + $scriptContent += "call rm -f $RemotePath/*.exe`r`n" + + # Add files to WinSCP script + if ($FileList.Count -eq 0) { + Write-Log "No files found matching pattern" "Warning" + $scriptContent += "exit`r`n" + } + else { + foreach ($filePath in $FileList) { + # For local Windows paths, keep backslashes as-is (don't convert to forward slashes) + # WinSCP needs native Windows paths for local files + $remoteFilename = Split-Path $filePath -Leaf + $scriptContent += "put `"$filePath`" `"$RemotePath/$remoteFilename`"`r`n" + } + $scriptContent += "close`r`nexit`r`n" + } + + # Save script to temporary file + try { + Set-Content -Path $scriptPath -Value $scriptContent -Encoding UTF8 + + Write-Log "Created WinSCP script at: $scriptPath" "Info" + Write-Log "Script content:" "Info" + Get-Content $scriptPath | ForEach-Object { Write-Log "$_" "Info" } + + Write-Log "Executing WinSCP: $WinSCPExe" "Info" + + try { + # Determine if this is .com (command-line) or .exe (GUI) + $isCom = $WinSCPExe -like "*.com" + + if ($isCom) { + # WinSCP.com uses /log= for logging + $process = Start-Process -FilePath $WinSCPExe ` + -ArgumentList "/log=$logFile /script=$scriptPath" ` + -NoNewWindow ` + -PassThru ` + -Wait ` + -RedirectStandardOutput $outputPath ` + -RedirectStandardError $errorPath + } + else { + # WinSCP.exe (GUI) - needs option logfile in script + $scriptContent += "`r`noption logfile=$logFile" + Set-Content -Path $scriptPath -Value $scriptContent -Encoding UTF8 + + $process = Start-Process -FilePath $WinSCPExe ` + -ArgumentList "/console /script=$scriptPath" ` + -NoNewWindow ` + -PassThru ` + -Wait ` + -RedirectStandardOutput $outputPath ` + -RedirectStandardError $errorPath + } + } + catch { + Write-Log "Error starting process: $_" "Error" + throw + } + + Write-Log "WinSCP process finished with exit code: $($process.ExitCode)" "Info" + + # Read WinSCP logs + $winscp_log = Get-Content $logFile -ErrorAction SilentlyContinue -Raw + $output = Get-Content $outputPath -ErrorAction SilentlyContinue -Raw + $error_output = Get-Content $errorPath -ErrorAction SilentlyContinue -Raw + + if ($winscp_log) { + Write-Log "WinSCP Log:`r`n$winscp_log" "Info" + } + + if ($output) { + Write-Log "Output:`r`n$output" "Info" + } + else { + Write-Log "No standard output from WinSCP" "Info" + } + + if ($error_output) { + Write-Log "Standard Error:`r`n$error_output" "Error" + } + + if ($process.ExitCode -eq 0) { + Write-Log "Upload completed successfully" "Success" + return $true + } + else { + Write-Log "Upload failed with exit code: $($process.ExitCode)" "Error" + return $false + } + } + catch { + Write-Log "Error during upload: $_" "Error" + return $false + } + finally { + # Cleanup temporary files + Start-Sleep -Milliseconds 500 + if (Test-Path $scriptPath) { + Remove-Item $scriptPath -Force -ErrorAction SilentlyContinue + } + if (Test-Path $logFile) { + Remove-Item $logFile -Force -ErrorAction SilentlyContinue + } + if (Test-Path $outputPath) { + Remove-Item $outputPath -Force -ErrorAction SilentlyContinue + } + if (Test-Path $errorPath) { + Remove-Item $errorPath -Force -ErrorAction SilentlyContinue + } + } +} + +# ================= +# MAIN LOGIC +# ================= + +Write-Log "========== STARTING FILE UPLOAD PROCESS ==========" "Info" +Write-Log "Server: $ServerAddress`:$Port" "Info" +Write-Log "Username: $Username" "Info" +Write-Log "File pattern: $LocalFilePath" "Info" +Write-Log "Remote folder: $RemoteFolderPath" "Info" +Write-Log "=============================================" "Info" + +# Find WinSCP if path not provided +if (-not $WinSCPPath) { + $WinSCPPath = Find-WinSCP + if (-not $WinSCPPath) { + exit 1 + } +} + +# Verify WinSCP exists +if (-not (Test-Path $WinSCPPath)) { + Write-Log "Error: WinSCP not found at: $WinSCPPath" "Error" + exit 1 +} + +# Get files matching pattern +$files = @(Get-Item -Path $LocalFilePath -ErrorAction SilentlyContinue | Where-Object {-not $_.PSIsContainer}) + +if ($files.Count -eq 0) { + Write-Log "Error: No files found matching pattern: $LocalFilePath" "Error" + Write-Log "Current directory: $(Get-Location)" "Error" + Write-Log "Checking if path exists: $(Test-Path $LocalFilePath)" "Error" + exit 1 +} + +Write-Log "Found $($files.Count) file(s) to upload" "Info" +$filePathList = @($files | ForEach-Object {$_.FullName}) + +# Perform upload +$success = Upload-ToSFTP -Server $ServerAddress ` + -User $Username ` + -Pass $PasswordParam ` + -FileList $filePathList ` + -RemotePath $RemoteFolderPath ` + -PortNum $Port ` + -WinSCPExe $WinSCPPath + +Write-Log "========== PROCESS COMPLETED ==========" "Info" + +if ($success) { + exit 0 +} +else { + exit 1 +} diff --git a/.gitea/workflows/sshupload.sh b/.gitea/workflows/sshupload.sh new file mode 100644 index 0000000..9ecf450 --- /dev/null +++ b/.gitea/workflows/sshupload.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + cat <<'EOF' +Usage: sshupload.sh -l -r -s -u -p +EOF +} + +local_glob="" +remote_dir="" +server="" +user="" +password="" + +while [[ $# -gt 0 ]]; do + case "$1" in + -l|--local) local_glob="$2"; shift 2;; + -r|--remote) remote_dir="$2"; shift 2;; + -s|--server) server="$2"; shift 2;; + -u|--user) user="$2"; shift 2;; + -p|--password) password="$2"; shift 2;; + -h|--help) usage; exit 0;; + *) echo "Unknown arg: $1" >&2; usage; exit 1;; + esac +done + +if [[ -z "$local_glob" || -z "$remote_dir" || -z "$server" || -z "$user" || -z "$password" ]]; then + echo "Missing required params" >&2 + usage + exit 1 +fi + +# Ensure sshpass installed +if ! command -v sshpass >/dev/null 2>&1; then + if command -v brew >/dev/null 2>&1; then + brew update + brew install hudochenkov/sshpass/sshpass + elif command -v apt-get >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y sshpass + else + echo "sshpass not found and no supported package manager" >&2 + exit 1 + fi +fi + +user_host="${user}@${server}" + +# Ensure remote dir exists and clear it +sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user_host" "mkdir -p '$remote_dir' && rm -f '$remote_dir'/*" + +# Expand glob (supports ~ and patterns) and upload each file (compatible with macOS bash 3.x) +shopt -s nullglob +eval "files=( ${local_glob} )" +shopt -u nullglob + +if [[ ${#files[@]} -eq 0 ]]; then + echo "No files matched: $local_glob" >&2 + exit 1 +fi + +for f in "${files[@]}"; do + sshpass -p "$password" scp -o StrictHostKeyChecking=no "$f" "$user_host:$remote_dir/" +done + +echo "Upload completed" diff --git a/.gitea/workflows/windows.yaml b/.gitea/workflows/windows.yaml new file mode 100644 index 0000000..89c6f7a --- /dev/null +++ b/.gitea/workflows/windows.yaml @@ -0,0 +1,59 @@ +name: Windows Kernel Build + +#Запускаем только кнопкой "Run workflow" в Actions -> Build Windows +#Или если есть коммпит в папку lib в ветке main +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'lib/**' + + + +jobs: + build: + runs-on: Windows + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + + # Кэш для electron-builder + - name: Cache electron-builder + uses: actions/cache@v5 + with: + path: | + ${{ env.LOCALAPPDATA }}\\electron-builder\\Cache + ${{ env.LOCALAPPDATA }}\\electron\\Cache + key: ${{ runner.os }}-electron-builder-${{ hashFiles('**/electron-builder.yml') }} + restore-keys: | + ${{ runner.os }}-electron-builder- + if-no-files-found: ignore + + - name: NPM offline setup + shell: powershell + run: | + npm config set cache "$env:LOCALAPPDATA\npm-cache" --global + npm config set prefer-offline true --global + + - name: Install npm dependencies + run: npm install --prefer-offline --no-audit --no-fund + + - name: Build the application + run: npm run kernel:win + + - name: Upload to SSH using WinSCP Powershell + shell: powershell + run: | + & "$env:GITHUB_WORKSPACE\.gitea\workflows\sshupload.ps1" ` + -LocalFilePath "dist/builds/win/x64/Rosetta-*.exe" ` + -RemoteFolderPath "${{ secrets.SSH_TARGET_DIR }}/win32/x64" ` + -ServerAddress "${{ secrets.SSH_HOST }}" ` + -Username "${{ secrets.SSH_USERNAME }}" ` + -PasswordParam '${{ secrets.SSH_PASSWORD }}' diff --git a/app/servers.ts b/app/servers.ts new file mode 100644 index 0000000..aa52cbb --- /dev/null +++ b/app/servers.ts @@ -0,0 +1,11 @@ +export const SERVERS = [ + //'wss://cdn.rosetta-im.com', + //'ws://10.211.55.2:3000', + //'ws://127.0.0.1:3000', + 'wss://wss.rosetta.im' +]; + +export function selectServer(): string { + const idx = Math.floor(Math.random() * SERVERS.length); + return SERVERS[idx]; +} \ No newline at end of file diff --git a/build-packs.sh b/build-packs.sh index e9c2cde..0640b9a 100644 --- a/build-packs.sh +++ b/build-packs.sh @@ -1,8 +1,7 @@ #/bin/bash echo "Using directory: $(pwd)" current_dir=$(pwd) -# Run npm with a timeout using perl (cross-platform alternative to 'timeout') -perl -e 'alarm shift; $SIG{ALRM}=sub{kill INT => -$$}; exec @ARGV' 10 npm run start + echo "Build complete. Packing service packs..." APP_VERSION=$(grep -o 'APP_VERSION *= *"[^"]*' "$current_dir/app/version.ts" | sed 's/APP_VERSION *= *"//') diff --git a/package.json b/package.json index e57a6ff..cb48eb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Rosetta", - "version": "1.4.8", + "version": "1.4.9", "description": "Rosetta Messenger", "main": "./out/main/main.js", "license": "MIT", @@ -17,10 +17,9 @@ "appId": "im.rosetta", "icon": "icons/mac/icon.icns", "target": [ - "zip", "pkg" ], - "artifactName": "/builds/darwin/${arch}/Rosetta-${version}.${ext}", + "artifactName": "builds/darwin/${arch}/Rosetta-${version}.${ext}", "publish": null }, "pkg": { @@ -34,15 +33,15 @@ "icon": "icons/png/256x256.png", "target": [ "AppImage" - ] + ], + "artifactName": "builds/linux/${arch}/Rosetta-${version}.${ext}" }, "win": { "icon": "icons/win/icon.ico", "target": [ - "zip", "nsis" ], - "artifactName": "/builds/win/${arch}/Rosetta-${version}.${ext}" + "artifactName": "builds/win/${arch}/Rosetta-${version}.${ext}" }, "nsis": { "oneClick": false, @@ -60,11 +59,11 @@ "start": "electron-vite preview", "postinstall": "electron-builder install-app-deps", "build:unpack": "electron-vite build && electron-builder --dir", - "kernel:win": "electron-vite build && electron-builder --win --x64", + "kernel:win": "mkdir -p dist/builds/win32/x64 && electron-vite build && electron-builder --win --x64", "kernel:darwin-arm64": "electron-vite build && electron-builder --mac --arm64", "kernel:darwin-x64": "electron-vite build && electron-builder --mac --x64", - "kernel:mac": "npm run kernel:darwin-x64 && npm run kernel:darwin-arm64", - "kernel:linux": "electron-vite build && electron-builder --linux --x64 --arm64" + "kernel:mac": "mkdir -p dist/builds/darwin/arm64 dist/builds/darwin/x64 && npm run kernel:darwin-x64 && npm run kernel:darwin-arm64", + "kernel:linux": "mkdir -p dist/builds/linux/x64 dist/builds/linux/arm64 dist/builds/linux/x86_64 && electron-vite build && electron-builder --linux --x64 --arm64 && if [ -d dist/builds/linux/x86_64 ]; then mkdir -p dist/builds/linux/x64 && mv dist/builds/linux/x86_64/* dist/builds/linux/x64/ 2>/dev/null || true; rmdir dist/builds/linux/x86_64 2>/dev/null || true; fi" }, "dependencies": { "@electron-toolkit/preload": "^3.0.1",