valentina/.github/workflows/windows.yml
2024-04-27 09:06:27 +03:00

232 lines
8.3 KiB
YAML

name: Windows build
on:
push:
branches:
- 'master'
- 'develop'
tags:
- 'v*'
pull_request:
branches:
- 'master'
- 'develop'
defaults:
run:
shell: cmd
env:
SOURCE_DIR: ${{ github.workspace }}
INSTALL_QT: 6.7.0
QBS_VERSION: 2.2.2
VALENTINA_VERSION: 0_7_52
ACCESS_TOKEN: ${{ secrets.DROPBOX_ACCESS_TOKEN }}
jobs:
Windows_Qt_6_7_MSVC_x64:
name: Windows Qt 6.7 (MSVC x64)
runs-on: windows-latest
env:
DEPLOY: 'true'
RUN_TESTS: 'true'
WITH_CRASH_REPORTING: 'True'
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.INSTALL_QT }}
host: 'windows'
target: 'desktop'
arch: win64_msvc2019_64
dir: ${{ runner.temp }}
modules: 'qtimageformats'
cache: true
tools: 'tools_cmake tools_opensslv3_x64'
setup-python: false
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
architecture: "x64"
cache: 'pip'
cache-dependency-path: '**/requirements-ci.txt'
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Install Python dependencies
run: |
python --version
python -m pip install --upgrade setuptools
python -m pip install -r share/requirements-ci.txt
- name: Cache Chocolatey
uses: actions/cache@v4
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
# This caches the cache, no need to make sure that this is invalidated
# chocolatey will do that for us.
key: chocolatey-cache
- name: Install Chocolatey dependencies
run: |
choco install qbs -y --version=${{ env.QBS_VERSION }}
qbs --version
- name: Find cl.exe
id: cl-path
shell: pwsh
run: |
function Locate-VSWhere {
$path = Get-Command 'vswhere' -ErrorAction SilentlyContinue
if ($path) {
$path.Path
} else {
Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio' 'Installer' 'vswhere'
}
}
function Locate-VS {
# vswhere doesn't search for Build Tools by default, God knows why.
# https://github.com/microsoft/vswhere/issues/22
$products = 'Community','Professional','Enterprise','BuildTools' | %{ "Microsoft.VisualStudio.Product.$_" }
$vswhere = Locate-VSWhere
& $vswhere -products $products -latest -format json | ConvertFrom-Json
}
function Locate-CLPath {
$vsInfo = Locate-VS
if ($vsInfo) {
$vsInstallPath = $vsInfo[0].installationPath
$clPath = Join-Path $vsInstallPath 'VC\Tools\MSVC'
$latestVersion = (Get-ChildItem -Path $clPath | Where-Object { $_.PSIsContainer } | Sort-Object -Property Name -Descending)[0].Name
$clPath = Join-Path $clPath $latestVersion
$clPath = Join-Path $clPath 'bin\Hostx64\x64\cl.exe'
return $clPath
} else {
Write-Output "Visual Studio not found."
return $null
}
}
$clPath = Locate-CLPath
echo "Found Cl at $clPath"
echo "cl-path=$clPath" >> $env:GITHUB_OUTPUT
# To cache Conan 1.x packages in GitHub Actions, you can save the .conan/data directory for every OS like this:
- name: Setup path to Conan home folder
run: echo CONAN_USER_HOME=${{ runner.temp }} >> ${{ github.env }}
- name: Cache Conan packages
uses: actions/cache@v4
with:
path: ${{ env.CONAN_USER_HOME }}\.conan\data
key: conan-packages-${{ runner.os }}-v1-${{ hashFiles('**/conanfile.py') }}
restore-keys: conan-packages-${{ runner.os }}-
# For Conan 2.0 setting conan_home=./.conan2 in the .conanrc file and saving .conan2/p directory seems to work as well.
- name: Before build
run: |
qbs-setup-toolchains --detect
qbs-setup-qt %Qt6_DIR%\bin\qmake.exe qt6
qbs-config defaultProfile qt6
qbs-setup-toolchains.exe --type msvc "${{ steps.cl-path.outputs.cl-path }}" msvc
qbs-config.exe profiles.qt6.baseProfile msvc
conan config install https://gist.github.com/dismine/0abab496338183c36661e635c2aeab8d.git
type ${{ env.CONAN_USER_HOME }}\.conan\settings.yml
conan profile new valentina
conan profile update settings.build_type=Release valentina
conan profile update settings.os=Windows valentina
conan profile update settings.arch=x86_64 valentina
conan profile update settings.compiler=msvc valentina
conan profile update settings.compiler.cppstd=17 valentina
conan profile update settings.compiler.runtime=dynamic valentina
conan profile update settings.compiler.runtime_type=Release valentina
conan profile update settings.compiler.version=192 valentina
qbs-config --list profiles
conan profile list
- name: Build Conan dependencies
run: conan install . -s os=Windows --build=missing -o with_crash_reporting=${{ env.WITH_CRASH_REPORTING }} -o with_xerces=True -pr=valentina
- name: Build Valentina
run: >
qbs build
-f valentina.qbs
-d ${{ runner.temp }}\build
config:release
qbs.installRoot:${{ runner.temp }}\build\install-root\valentina
profile:qt6
project.enableConan:true
project.conanWithCrashReporting:${{ env.WITH_CRASH_REPORTING }}
project.conanWithXerces:true
project.conanProfiles:valentina
modules.buildconfig.enablePCH:true
modules.windeployqt.compilerRuntime:true
modules.windeployqt.noCompilerRuntime:false
- name: Tests
if: env.RUN_TESTS == 'true'
run: qbs -p autotest-runner -d ${{ runner.temp }}\build profile:qt6 config:release
- name: Deploy symbols
if: env.WITH_CRASH_REPORTING == 'True'
shell: pwsh
run: |
$qmakeOutput = & "$env:Qt6_DIR\bin\qmake.exe" -query QT_VERSION
$majorMinorVersion = $qmakeOutput -replace '(\d+)\.(\d+).*', '$1_$2'
$env:CRASH_QT_VERSION = $majorMinorVersion
$env:CRASH_SHORT_SHA = git log --pretty=format:%h -n 1
./scripts/install_dump_sysms.ps1
& python ./scripts/symupload.py ${{ runner.temp }}\build\install-root\valentina $env:VALENTINA_VERSION g$env:CRASH_SHORT_SHA $env:CRASH_QT_VERSION --clean
- name: Create installer
if: github.event_name != 'pull_request' && env.DEPLOY == 'true'
run: >
qbs build
-f valentina.qbs
-d ${{ runner.temp }}\build
-p ValentinaSetup
config:release
qbs.installRoot:${{ runner.temp }}\build\install-root\valentina
profile:qt6
project.enableConan:true
project.conanWithCrashReporting:${{ env.WITH_CRASH_REPORTING }}
project.conanWithXerces:true
project.conanProfiles:valentina
modules.buildconfig.enablePCH:true
modules.windeployqt.compilerRuntime:true
modules.windeployqt.noCompilerRuntime:false
- name: Commit hash
id: commit
if: github.event_name != 'pull_request' && env.DEPLOY == 'true'
uses: prompt/actions-commit-hash@v3
- name: Deploy
if: github.event_name != 'pull_request' && env.DEPLOY == 'true'
shell: pwsh
env:
VALENTINA_BUILD_FOLDER: ${{ runner.temp }}\build
APPVEYOR_BUILD_FOLDER: ${{ env.SOURCE_DIR }}
APPVEYOR_REPO_BRANCH: ${{ github.base_ref || github.ref_name }}
APPVEYOR_REPO_COMMIT: ${{ steps.commit.outputs.hash }}
PYTHON: ${{ env.Python3_ROOT_DIR }}
TARGET_PLATFORM: "Windows10+"
ARCH: x64
COMPILER: msvc
QT_VERSION: Qt6_7
run: ./scripts/appveyor-deploy.ps1