GHA CI: Bump boost dependency and revise install method
[qBittorrent.git] / .github / workflows / ci_macos.yaml
blob07ed35e7e1ec015467f1af557714a0aed8ded417
1 name: CI - macOS
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: macos-latest
17     strategy:
18       fail-fast: false
19       matrix:
20         libt_version: ["2.0.9", "1.2.19"]
21         qbt_gui: ["GUI=ON", "GUI=OFF"]
22         qt_version: ["6.5.2"]
24     env:
25       boost_path: "${{ github.workspace }}/../boost"
26       openssl_root: /usr/local/opt/openssl@3
27       libtorrent_path: "${{ github.workspace }}/../libtorrent"
29     steps:
30       - name: Checkout repository
31         uses: actions/checkout@v4
33       - name: Install dependencies
34         uses: Wandalen/wretry.action@v1
35         env:
36            HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
37            HOMEBREW_NO_INSTALL_CLEANUP: 1
38         with:
39           attempt_delay: 20000
40           attempt_limit: 6
41           command: |
42             brew update > /dev/null
43             brew install \
44               cmake ninja \
45               openssl@3 zlib
47       - name: Setup ccache
48         uses: Chocobo1/setup-ccache-action@v1
49         with:
50           store_cache: ${{ startsWith(github.ref, 'refs/heads/') }}
51           update_packager_index: false
53       - name: Install boost
54         env:
55           BOOST_MAJOR_VERSION: "1"
56           BOOST_MINOR_VERSION: "84"
57           BOOST_PATCH_VERSION: "0"
58         run: |
59           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"
60           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"
61           set +e
62           curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
63           tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
64           if [ "$_exitCode" -ne "0" ]; then
65             curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url2"
66             tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
67           fi
68           mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
70       - name: Install Qt
71         uses: jurplel/install-qt-action@v3
72         with:
73           version: ${{ matrix.qt_version }}
74           archives: qtbase qtdeclarative qtsvg qttools
75           # Not sure why Qt made a hard dependency on qtdeclarative, try removing it when Qt > 6.4.0
76           cache: true
78       - name: Install libtorrent
79         run: |
80           git clone \
81             --branch v${{ matrix.libt_version }} \
82             --depth 1 \
83             --recurse-submodules \
84             https://github.com/arvidn/libtorrent.git \
85             ${{ env.libtorrent_path }}
86           cd ${{ env.libtorrent_path }}
87           cmake \
88             -B build \
89             -G "Ninja" \
90             -DBUILD_SHARED_LIBS=OFF \
91             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
92             -DCMAKE_CXX_STANDARD=17 \
93             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
94             -DBOOST_ROOT="${{ env.boost_path }}" \
95             -Ddeprecated-functions=OFF \
96             -DOPENSSL_ROOT_DIR="${{ env.openssl_root }}"
97           cmake --build build
98           sudo cmake --install build
100       - name: Build qBittorrent
101         run: |
102           CXXFLAGS="$CXXFLAGS -Werror -Wno-error=deprecated-declarations" \
103           LDFLAGS="$LDFLAGS -gz" \
104           cmake \
105             -B build \
106             -G "Ninja" \
107             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
108             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
109             -DBOOST_ROOT="${{ env.boost_path }}" \
110             -DOPENSSL_ROOT_DIR="${{ env.openssl_root }}" \
111             -DTESTING=ON \
112             -DVERBOSE_CONFIGURE=ON \
113             -D${{ matrix.qbt_gui }}
114           cmake --build build --target qbt_update_translations
115           cmake --build build
116           cmake --build build --target check
118       - name: Prepare build artifacts
119         run: |
120           # create .dmg
121           appName="qbittorrent"
122           if [ "${{ matrix.qbt_gui }}" = "GUI=OFF" ]; then
123             appName="qbittorrent-nox"
124           fi
125           pushd build
126           macdeployqt "$appName.app" -dmg -no-strip
127           popd
128           # prepare upload folder
129           mkdir upload
130           cp "build/$appName.dmg" upload
131           mkdir upload/cmake
132           cp build/compile_commands.json upload/cmake
133           mkdir upload/cmake/libtorrent
134           cp ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
136       - name: Upload build artifacts
137         uses: actions/upload-artifact@v4
138         with:
139           name: qBittorrent-CI_macOS_${{ matrix.qbt_gui }}_libtorrent-${{ matrix.libt_version }}_Qt-${{ matrix.qt_version }}
140           path: upload