WebUI: Use Map instead of Mootools Hash in Torrents table
[qBittorrent.git] / .github / workflows / ci_windows.yaml
blobf4cd316e4dcf34b7fc2fc5d65c8cdbb233a4e85c
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.7.0"
99           archives: qtbase qtsvg qttools
100           cache: true
102       - name: Install libtorrent
103         run: |
104           git clone `
105             --branch v${{ matrix.libt_version }} `
106             --depth 1 `
107             --recurse-submodules `
108             https://github.com/arvidn/libtorrent.git `
109             ${{ env.libtorrent_path }}
110           cd ${{ env.libtorrent_path }}
111           $env:CXXFLAGS+=" /guard:cf"
112           $env:LDFLAGS+=" /guard:cf"
113           cmake `
114             -B build `
115             -G "Ninja" `
116             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
117             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
118             -DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}/install" `
119             -DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
120             -DBOOST_ROOT="${{ env.boost_path }}" `
121             -DBUILD_SHARED_LIBS=OFF `
122             -Ddeprecated-functions=OFF `
123             -Dstatic_runtime=OFF `
124             -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-release
125           cmake --build build
126           cmake --install build
128       - name: Build qBittorrent
129         run: |
130           $env:CXXFLAGS+=" /WX"
131           cmake `
132             -B build `
133             -G "Ninja" `
134             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
135             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
136             -DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
137             -DBOOST_ROOT="${{ env.boost_path }}" `
138             -DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/install/lib/cmake/LibtorrentRasterbar" `
139             -DMSVC_RUNTIME_DYNAMIC=ON `
140             -DTESTING=ON `
141             -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-release `
142             -DVERBOSE_CONFIGURE=ON `
143             --graphviz=build/target_graph.dot
144           cmake --build build --target qbt_update_translations
145           cmake --build build
146           cmake --build build --target check
148       - name: Prepare build artifacts
149         run: |
150           mkdir upload
151           mkdir upload/qBittorrent
152           copy build/qbittorrent.exe upload/qBittorrent
153           copy build/qbittorrent.pdb upload/qBittorrent
154           copy dist/windows/qt.conf upload/qBittorrent
155           # runtimes
156           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Core.dll" upload/qBittorrent
157           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Gui.dll" upload/qBittorrent
158           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Network.dll" upload/qBittorrent
159           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Sql.dll" upload/qBittorrent
160           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Svg.dll" upload/qBittorrent
161           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Widgets.dll" upload/qBittorrent
162           copy "${{ env.Qt_ROOT_DIR }}/bin/Qt6Xml.dll" upload/qBittorrent
163           mkdir upload/qBittorrent/plugins/iconengines
164           copy "${{ env.Qt_ROOT_DIR }}/plugins/iconengines/qsvgicon.dll" upload/qBittorrent/plugins/iconengines
165           mkdir upload/qBittorrent/plugins/imageformats
166           copy "${{ env.Qt_ROOT_DIR }}/plugins/imageformats/qico.dll" upload/qBittorrent/plugins/imageformats
167           copy "${{ env.Qt_ROOT_DIR }}/plugins/imageformats/qsvg.dll" upload/qBittorrent/plugins/imageformats
168           mkdir upload/qBittorrent/plugins/platforms
169           copy "${{ env.Qt_ROOT_DIR }}/plugins/platforms/qwindows.dll" upload/qBittorrent/plugins/platforms
170           mkdir upload/qBittorrent/plugins/sqldrivers
171           copy "${{ env.Qt_ROOT_DIR }}/plugins/sqldrivers/qsqlite.dll" upload/qBittorrent/plugins/sqldrivers
172           mkdir upload/qBittorrent/plugins/styles
173           copy "${{ env.Qt_ROOT_DIR }}/plugins/styles/qmodernwindowsstyle.dll" upload/qBittorrent/plugins/styles
174           mkdir upload/qBittorrent/plugins/tls
175           copy "${{ env.Qt_ROOT_DIR }}/plugins/tls/qschannelbackend.dll" upload/qBittorrent/plugins/tls
176           # cmake additionals
177           mkdir upload/cmake
178           copy build/compile_commands.json upload/cmake
179           copy build/target_graph.dot upload/cmake
180           mkdir upload/cmake/libtorrent
181           copy ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
183       - name: Upload build artifacts
184         uses: actions/upload-artifact@v4
185         with:
186           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}
187           path: upload
189       - name: Create installer
190         run: |
191           7z x -o"dist/windows/" "dist/windows/NSISPlugins.zip"
192           makensis /DQBT_DIST_DIR="../../upload/qBittorrent" /WX dist/windows/qbittorrent.nsi
194       - name: Upload installer
195         uses: actions/upload-artifact@v4
196         with:
197           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}-setup
198           path: dist/windows/qbittorrent_*_setup.exe