From 18545d635565135f76fc445ef60d9ffa276a498c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 1 Mar 2024 13:44:15 +0200 Subject: [PATCH] Prepare portable bundle on Windows as a second option. --- appveyor.yml | 10 +++++----- scripts/appveyor-deploy.ps1 | 25 +++++++++++++++++++++++-- scripts/deploy.py | 21 +++++++++++++++++---- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ce8c42d46..24afef3d6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -349,8 +349,8 @@ for: - (python --version) # Install the build dependencies of the project. - (python -m pip install --upgrade pip) - - if "%DEPLOY%" == "true" (python -m pip install dropbox) - - python -m pip install conan==1.61.0 + - if "%DEPLOY%" == "true" (python -m pip install dropbox py7zr) + - python -m pip install conan==1.63.0 - dir "C:\" - dir "C:\Qt" - dir "C:\Qt\Tools" @@ -481,7 +481,7 @@ for: - if "%DEPLOY%" == "true" (python --version) # Install the build dependencies of the project. - if "%DEPLOY%" == "true" (python -m pip install --upgrade pip) - - if "%DEPLOY%" == "true" (python -m pip install dropbox) + - if "%DEPLOY%" == "true" (python -m pip install dropbox py7zr) # Trick qmake to not work through MSYS - del /F "C:\Program Files\Git\usr\bin\sh.exe" - del /F "C:\Program Files\Git\bin\sh.exe" @@ -643,7 +643,7 @@ for: fi - sudo python3 -m pip install --upgrade pip - - pip3 install --user --upgrade pip dropbox 'urllib3<2.0' + - pip3 install --user --upgrade pip dropbox py7zr 'urllib3<2.0' - export QTDIR=`$(brew --prefix qt6)` - export PATH="$PATH:`python3 -m site --user-base`/bin:$QTDIR/bin" - echo $PATH @@ -827,7 +827,7 @@ for: fi - sudo python3 -m pip install --upgrade pip - - pip3 install --user --upgrade pip dropbox 'urllib3<2.0' + - pip3 install --user --upgrade pip dropbox py7zr 'urllib3<2.0' - export PATH="`brew --prefix qbs`/bin:$PATH" - echo $PATH - clang --version diff --git a/scripts/appveyor-deploy.ps1 b/scripts/appveyor-deploy.ps1 index a94a95659..8cc085515 100644 --- a/scripts/appveyor-deploy.ps1 +++ b/scripts/appveyor-deploy.ps1 @@ -1,7 +1,9 @@ $env:BUILD_FOLDER = "$env:APPVEYOR_BUILD_FOLDER\build"; $env:INSTALL_ROOT = "$env:BUILD_FOLDER\install-root\valentina"; -$file_name = "valentina-$env:TARGET_PLATFORM-$env:COMPILER-$env:ARCH-$env:QT_VERSION-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_REPO_COMMIT.exe"; +$type = "$env:TARGET_PLATFORM-$env:COMPILER-$env:ARCH-$env:QT_VERSION-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_REPO_COMMIT"; +$file_name = "valentina-${type}.exe"; +$portable_file_name = "valentina-portable-${type}.7z"; if($env:DEPLOY -eq "true") { Write-Host "[CI] Preparing installer." -ForegroundColor Green; @@ -21,7 +23,7 @@ if($env:DEPLOY -eq "true") { Write-Host "[CI] Cleaning done." -ForegroundColor Green; } - Write-Host "[CI] Uploading." -ForegroundColor Green; + Write-Host "[CI] Uploading installer." -ForegroundColor Green; & $env:PYTHON\python.exe "$env:APPVEYOR_BUILD_FOLDER\scripts\deploy.py" upload $env:ACCESS_TOKEN "$env:INSTALL_ROOT\ValentinaInstaller.exe" "/0.7.x/Windows/$file_name"; if ($LastExitCode -ne 0) { Write-Error -Message "[CI] Error uploading an artifact." -Category InvalidResult; @@ -29,6 +31,25 @@ if($env:DEPLOY -eq "true") { } else { Write-Host "[CI] Uploading has been finished." -ForegroundColor Green; } + + Write-Host "[CI] Starting packing." -ForegroundColor Green; + Remove-Item -Path "$env:INSTALL_ROOT\ValentinaInstaller.exe"; + & $env:PYTHON\python.exe "$env:APPVEYOR_BUILD_FOLDER\scripts\deploy.py" pack "$env:INSTALL_ROOT" "$env:BUILD_FOLDER\install-root\$portable_file_name"; + if ($LastExitCode -ne 0) { + Write-Error -Message "[CI] Error creating an archive." -Category InvalidResult; + exit 1; + } else { + Write-Host "[CI] Done." -ForegroundColor Green; + } + + Write-Host "[CI] Uploading portable bundle." -ForegroundColor Green; + & $env:PYTHON\python.exe "$env:APPVEYOR_BUILD_FOLDER\scripts\deploy.py" upload $env:ACCESS_TOKEN "$env:BUILD_FOLDER\install-root\$portable_file_name" "/0.7.x/Windows/$portable_file_name"; + if ($LastExitCode -ne 0) { + Write-Error -Message "[CI] Error uploading an artifact." -Category InvalidResult; + exit 1; + } else { + Write-Host "[CI] Uploading has been finished." -ForegroundColor Green; + } Exit 0; } else { diff --git a/scripts/deploy.py b/scripts/deploy.py index aaec22789..f1ce19efa 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -5,6 +5,7 @@ import pathlib import re import shutil import sys +import py7zr import dropbox from dropbox import DropboxOAuth2FlowNoRedirect @@ -47,15 +48,23 @@ def run_pack(source, destination): formats = { ".zip": "zip", - ".tar.xz": "xztar" + ".tar.xz": "xztar", + ".7z": "7zip" } suffix = ''.join(pathlib.Path(base).suffixes) - format = formats.get(suffix) archive_from = pathlib.Path(source).parent archive_to = os.path.basename(source.strip(os.sep)) print(source, destination, archive_from) - shutil.make_archive(name, format, archive_from, archive_to) - shutil.move(f'{name}{suffix}', destination) + format = formats.get(suffix) + if format: + if format == "7zip": + with py7zr.SevenZipFile(f"{name}{suffix}", 'w') as archive: + archive.writeall(source, arcname=os.path.basename(source)) + else: + shutil.make_archive(name, format, archive_from, archive_to) + shutil.move(f'{name}{suffix}', destination) + else: + print("Unsupported archive format.") def run_upload(refresh_token, file, path): @@ -136,6 +145,10 @@ def run_clean(refresh_token): r'^valentina-Windows7\+-mingw-x86-Qt.*-develop-[a-f0-9]{40}\.exe$', r'^valentina-Windows10\+-msvc-x64-Qt.*-develop-[a-f0-9]{40}\.exe$', r'^valentina-Windows7\+-msvc-x86-Qt.*-develop-[a-f0-9]{40}\.exe$', + r'^valentina-portable-Windows10\+-mingw-x64-Qt.*-develop-[a-f0-9]{40}\.7z$', + r'^valentina-portable-Windows7\+-mingw-x86-Qt.*-develop-[a-f0-9]{40}\.7z$', + r'^valentina-portable-Windows10\+-msvc-x64-Qt.*-develop-[a-f0-9]{40}\.7z$', + r'^valentina-portable-Windows7\+-msvc-x86-Qt.*-develop-[a-f0-9]{40}\.7z$', r'^valentina-macOS_11\+-Qt.*-x64-develop-[a-f0-9]{40}\.dmg$', r'^valentina-macOS_11\+-Qt.*-x64-develop-multibundle-[a-f0-9]{40}\.dmg$', r'^valentina-macOS_10.13\+-Qt.*-x64-develop-[a-f0-9]{40}\.dmg$',