added env vars for stage/prod and updated gdrive upload for production (separate folder).

This commit is contained in:
Denys Zaitsev
2025-07-03 12:49:24 +03:00
parent bb6413c4f0
commit eac6460645
4 changed files with 84 additions and 40 deletions
+58 -7
View File
@@ -1,14 +1,39 @@
param (
[string]$Path = "."
param (
[string]$Path = ".",
[string]$BuildEnv = "Stage" # Added parameter for build environment, defaults to "Stage"
)
Write-Output "`n=== Starting Upload: Full Installer ZIP ==="
$uploadFolder = "AzaionSuiteBuilds"
Write-Output "[INFO] Target Google Drive folder: $uploadFolder"
Write-Output "[INFO] Looking for latest .zip matching 'AzaionSuite.Full.*.zip' in folder: $Path..."
# Define target Google Drive folders
$stageUploadFolder = "AzaionGoogleDrive:AzaionSuiteBuilds"
$prodUploadFolder = "AzaionGoogleDrive:AzaionSuiteLatestProduction" # Make sure this matches your actual rclone remote name and path
$fullZip = Get-ChildItem -Path $Path -Filter "AzaionSuite.Full.*.zip" |
$targetUploadPath = ""
if ($BuildEnv -eq "Prod") {
Write-Output "[INFO] Build environment is Production. Preparing to upload to: $prodUploadFolder"
# 1. Ensure the Production folder exists
Write-Output "[ACTION] Ensuring production folder '$prodUploadFolder' exists..."
rclone mkdir "$prodUploadFolder"
if ($LASTEXITCODE -ne 0) {
Write-Output "[ERROR] Failed to create or confirm existence of production folder with exit code $LASTEXITCODE. Aborting upload."
exit 1
} else {
Write-Output "[SUCCESS] Production folder confirmed/created."
}
$targetUploadPath = $prodUploadFolder
} else {
Write-Output "[INFO] Build environment is Stage. Uploading to: $stageUploadFolder"
$targetUploadPath = $stageUploadFolder
}
# Updated filter for finding the ZIP file
$filter = "AzaionSuite.Full.$BuildEnv.*.zip"
Write-Output "[INFO] Looking for latest .zip matching '$filter' in folder: $Path..."
$fullZip = Get-ChildItem -Path $Path -Filter $filter |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
@@ -17,10 +42,36 @@ if ($fullZip) {
Write-Output "[INFO] Full path: $($fullZip.FullName)"
Write-Output "[ACTION] Uploading file to Google Drive using rclone..."
rclone copy "$($fullZip.FullName)" "AzaionGoogleDrive:$uploadFolder" --progress
# 2. Upload the new build
rclone copy "$($fullZip.FullName)" "$targetUploadPath" --progress
if ($LASTEXITCODE -eq 0) {
Write-Output "[SUCCESS] Full installer ZIP uploaded successfully."
# 3. Delete all other builds except the newly uploaded one (only for Prod)
if ($BuildEnv -eq "Prod") {
Write-Output "[ACTION] Deleting old production builds, keeping only the newly uploaded file..."
$uploadedFileName = $fullZip.Name
# Get list of files in the target folder
$existingFiles = (rclone ls "$prodUploadFolder" --files-only) | ForEach-Object { $_.Trim() }
if ($LASTEXITCODE -eq 0) {
foreach ($fileName in $existingFiles) {
if ($fileName -ne $uploadedFileName) {
Write-Output "[INFO] Deleting old file: $fileName"
rclone delete "$prodUploadFolder/$fileName"
if ($LASTEXITCODE -ne 0) {
Write-Output "[WARNING] Failed to delete '$fileName' with exit code $LASTEXITCODE."
}
}
}
Write-Output "[SUCCESS] Old production builds cleanup complete."
} else {
Write-Output "[ERROR] Failed to list files in '$prodUploadFolder' for cleanup with exit code $LASTEXITCODE."
}
}
} else {
Write-Output "[ERROR] Upload failed with exit code $LASTEXITCODE."
}
-31
View File
@@ -1,31 +0,0 @@
param (
[string]$Path = "."
)
Write-Output "`n=== Starting Upload: Iterative Installer ==="
$uploadFolder = "AzaionSuiteBuilds"
Write-Output "[INFO] Target Google Drive folder: $uploadFolder"
Write-Output "[INFO] Looking for latest .exe matching 'AzaionSuite.Iterative.*.exe' in folder: $Path..."
$iterativeFile = Get-ChildItem -Path $Path -Filter "AzaionSuite.Iterative.*.exe" |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($iterativeFile) {
Write-Output "[FOUND] Iterative installer: $($iterativeFile.Name)"
Write-Output "[INFO] Full path: $($iterativeFile.FullName)"
Write-Output "[ACTION] Uploading file to Google Drive using rclone..."
rclone copy "$($iterativeFile.FullName)" "AzaionGoogleDrive:$uploadFolder" --progress
if ($LASTEXITCODE -eq 0) {
Write-Output "[SUCCESS] Iterative installer uploaded successfully."
} else {
Write-Output "[ERROR] Upload failed with exit code $LASTEXITCODE."
}
} else {
Write-Output "[WARNING] No matching Iterative installer found in folder: $Path."
}
Write-Output "=== Upload Complete: Iterative Installer ===`n"
+11 -1
View File
@@ -1,5 +1,9 @@
#define MyAppVersion GetFileVersion("..\dist-azaion\Azaion.Suite.exe")
#ifndef MY_BUILD_ENV
#define MY_BUILD_ENV "Stage" ; За замовчуванням Stage, якщо не вказано
#endif
[Setup]
AppId={{CCFEC8E2-0FCC-4B03-8EEA-00AF20D265E5}}
AppName=Azaion Suite
@@ -9,7 +13,13 @@ AppPublisher=Azaion LLC
DefaultDirName={localappdata}\Azaion\Azaion Suite
DefaultGroupName=Azaion Suite
OutputDir=..\
OutputBaseFilename=AzaionSuite.Full.{#MyAppVersion}
#if MY_BUILD_ENV == "Prod"
OutputBaseFilename=AzaionSuite.Full.Prod.{#MyAppVersion}
#else
OutputBaseFilename=AzaionSuite.Full.Stage.{#MyAppVersion} ; За замовчуванням Stage
#endif
SetupIconFile=..\dist-azaion\logo.ico
UninstallDisplayName=Azaion Suite
UninstallDisplayIcon={app}\Azaion.Suite.exe
+15 -1
View File
@@ -1,5 +1,12 @@
#define MyAppVersion GetFileVersion("..\dist-azaion\Azaion.Suite.exe")
; Define a variable for the build environment, e.g., "Stage" or "Prod"
; This will be set by your Jenkins pipeline using the /D switch.
; If not defined via /D, it defaults to "Stage".
#ifndef MY_BUILD_ENV
#define MY_BUILD_ENV "Stage" ; Default to Stage if not specified (e.g., when compiling manually without /D)
#endif
[Setup]
AppId={{CCFEC8E2-0FCC-4B03-8EEA-00AF20D265E5}}
AppName=Azaion Suite
@@ -9,7 +16,14 @@ AppPublisher=Azaion LLC
DefaultDirName={localappdata}\Azaion\Azaion Suite
DefaultGroupName=Azaion Suite
OutputDir=..\
OutputBaseFilename=AzaionSuite.Iterative.{#MyAppVersion}
; Conditional OutputBaseFilename based on MY_BUILD_ENV
#if MY_BUILD_ENV == "Prod"
OutputBaseFilename=AzaionSuite.Iterative.Prod.{#MyAppVersion}
#else
OutputBaseFilename=AzaionSuite.Iterative.Stage.{#MyAppVersion} ; Defaults to Stage if MY_BUILD_ENV is not "Prod"
#endif
SetupIconFile=..\dist-azaion\logo.ico
UninstallDisplayName=Azaion Suite
UninstallDisplayIcon={app}\Azaion.Suite.exe