WebUI: Show file filter when Content tab selected on load
[qBittorrent.git] / .github / workflows / ci_windows.yaml
blobfa43a38cb247c8aa7fad4b65222224738eb497d6
1 name: CI - Windows
3 on: [pull_request, push]
5 permissions:
6   actions: write
8 concurrency:
9   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10   cancel-in-progress: ${{ github.head_ref != '' }}
12 jobs:
13   ci:
14     name: Build
15     runs-on: windows-latest
17     strategy:
18       fail-fast: false
19       matrix:
20         libt_version: ["2.0.10", "1.2.19"]
22     env:
23       boost_path: "${{ github.workspace }}/../boost"
24       libtorrent_path: "${{ github.workspace }}/../libtorrent"
25       vcpkg_path: "c:/vcpkg"
27     steps:
28       - name: Checkout repository
29         uses: actions/checkout@v4
31       - name: Setup devcmd
32         uses: ilammy/msvc-dev-cmd@v1
34       - name: Install build tools
35         run: |
36           if ((Get-Command "ninja.exe" -ErrorAction SilentlyContinue) -eq $null)
37           {
38              choco install ninja
39           }
40           where.exe ninja
41           ninja --version
43       # https://learn.microsoft.com/en-us/vcpkg/users/binarycaching#gha
44       - name: Set variables for vcpkg
45         uses: actions/github-script@v7
46         with:
47           script: |
48             core.exportVariable('ACTIONS_CACHE_URL', (process.env.ACTIONS_CACHE_URL || ''));
49             core.exportVariable('ACTIONS_RUNTIME_TOKEN', (process.env.ACTIONS_RUNTIME_TOKEN || ''));
51       - name: Install dependencies with vcpkg
52         run: |
53           # create our own triplet
54           New-Item `
55             -Force `
56             -ItemType File `
57             -Path "${{ env.vcpkg_path }}/triplets_overlay/x64-windows-static-md-release.cmake"
58           # OpenSSL isn't compatible with `/guard:cf` flag so we omit it for now, see: https://github.com/openssl/openssl/issues/22554
59           Add-Content `
60             -Path "${{ env.vcpkg_path }}/triplets_overlay/x64-windows-static-md-release.cmake" `
61             -Value @("set(VCPKG_TARGET_ARCHITECTURE x64)",
62               "set(VCPKG_LIBRARY_LINKAGE static)",
63               "set(VCPKG_CRT_LINKAGE dynamic)",
64               "set(VCPKG_BUILD_TYPE release)")
65           # clear buildtrees after each package installation to reduce disk space requirements
66           $packages = `
67             "openssl:x64-windows-static-md-release",
68             "zlib:x64-windows-static-md-release"
69           ${{ env.vcpkg_path }}/vcpkg.exe upgrade `
70             --no-dry-run `
71             --overlay-triplets="${{ env.vcpkg_path }}/triplets_overlay"
72           ${{ env.vcpkg_path }}/vcpkg.exe install `
73             --binarysource="clear;x-gha,readwrite" `
74             --clean-after-build `
75             --overlay-triplets="${{ env.vcpkg_path }}/triplets_overlay" `
76             $packages
78       - name: Install boost
79         env:
80           BOOST_MAJOR_VERSION: "1"
81           BOOST_MINOR_VERSION: "86"
82           BOOST_PATCH_VERSION: "0"
83         run: |
84           $boost_url="https://boostorg.jfrog.io/artifactory/main/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
85           $boost_url2="https://sourceforge.net/projects/boost/files/boost/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
86           curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
87           tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."
88           if ($LastExitCode -ne 0)
89           {
90             curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url2"
91             tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."
92           }
93           move "${{ github.workspace }}/../boost_*" "${{ env.boost_path }}"
95       - name: Install Qt
96         uses: jurplel/install-qt-action@v4
97         with:
98           version: "6.8.0"
99           arch: win64_msvc2022_64
100           archives: qtbase qtsvg qttools
101           cache: true
103       - name: Install libtorrent
104         run: |
105           git clone `
106             --branch v${{ matrix.libt_version }} `
107             --depth 1 `
108             --recurse-submodules `
109             https://github.com/arvidn/libtorrent.git `
110             ${{ env.libtorrent_path }}
111           cd ${{ env.libtorrent_path }}
112           $env:CXXFLAGS+=" /guard:cf"
113           $env:LDFLAGS+=" /guard:cf"
114           cmake `
115             -B build `
116             -G "Ninja" `
117             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
118             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
119             -DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}/install" `
120             -DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
121             -DBOOST_ROOT="${{ env.boost_path }}" `
122             -DBUILD_SHARED_LIBS=OFF `
123             -Ddeprecated-functions=OFF `
124             -Dstatic_runtime=OFF `
125             -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-release
126           cmake --build build
127           cmake --install build
129       - name: Build qBittorrent
130         run: |
131           $env:CXXFLAGS+="/DQT_FORCE_ASSERTS /WX"
132           cmake `
133             -B build `
134             -G "Ninja" `
135             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
136             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
137             -DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
138             -DBOOST_ROOT="${{ env.boost_path }}" `
139             -DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/install/lib/cmake/LibtorrentRasterbar" `
140             -DMSVC_RUNTIME_DYNAMIC=ON `
141             -DTESTING=ON `
142             -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-release `
143             -DVERBOSE_CONFIGURE=ON `
144             --graphviz=build/target_graph.dot
145           cmake --build build --target qbt_update_translations
146           cmake --build build
147           cmake --build build --target check
149       - name: Prepare build artifacts
150         run: |
151           mkdir upload
152           mkdir upload/qBittorrent
153           copy build/qbittorrent.exe upload/qBittorrent
154           copy build/qbittorrent.pdb upload/qBittorrent
155           copy dist/windows/qt.conf upload/qBittorrent
156           # runtimes
157           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Core.dll" upload/qBittorrent
158           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Gui.dll" upload/qBittorrent
159           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Network.dll" upload/qBittorrent
160           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Sql.dll" upload/qBittorrent
161           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Svg.dll" upload/qBittorrent
162           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Widgets.dll" upload/qBittorrent
163           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Xml.dll" upload/qBittorrent
164           mkdir upload/qBittorrent/plugins/iconengines
165           copy "${{ env.Qt_ROOT_DIR }}/plugins/iconengines/qsvgicon.dll" upload/qBittorrent/plugins/iconengines
166           mkdir upload/qBittorrent/plugins/imageformats
167           copy "${{ env.Qt_ROOT_DIR }}/plugins/imageformats/qico.dll" upload/qBittorrent/plugins/imageformats
168           copy "${{ env.Qt_ROOT_DIR }}/plugins/imageformats/qsvg.dll" upload/qBittorrent/plugins/imageformats
169           mkdir upload/qBittorrent/plugins/platforms
170           copy "${{ env.Qt_ROOT_DIR }}/plugins/platforms/qwindows.dll" upload/qBittorrent/plugins/platforms
171           mkdir upload/qBittorrent/plugins/sqldrivers
172           copy "${{ env.Qt_ROOT_DIR }}/plugins/sqldrivers/qsqlite.dll" upload/qBittorrent/plugins/sqldrivers
173           mkdir upload/qBittorrent/plugins/styles
174           copy "${{ env.Qt_ROOT_DIR }}/plugins/styles/qmodernwindowsstyle.dll" upload/qBittorrent/plugins/styles
175           mkdir upload/qBittorrent/plugins/tls
176           copy "${{ env.Qt_ROOT_DIR }}/plugins/tls/qschannelbackend.dll" upload/qBittorrent/plugins/tls
177           # cmake additionals
178           mkdir upload/cmake
179           copy build/compile_commands.json upload/cmake
180           copy build/target_graph.dot upload/cmake
181           mkdir upload/cmake/libtorrent
182           copy ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
184       - name: Upload build artifacts
185         uses: actions/upload-artifact@v4
186         with:
187           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}
188           path: upload
190       - name: Create installer
191         run: |
192           7z x -o"dist/windows/" "dist/windows/NSISPlugins.zip"
193           makensis /DQBT_DIST_DIR="../../upload/qBittorrent" /WX dist/windows/qbittorrent.nsi
195       - name: Upload installer
196         uses: actions/upload-artifact@v4
197         with:
198           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}-setup
199           path: dist/windows/qbittorrent_*_setup.exe