Windows #510
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Windows | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| windows: | |
| name: Windows | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| arch: [x64] | |
| qt: [qt6] | |
| generator: [""] | |
| env: | |
| UPLOAD_ARTIFACT: "true" | |
| ONLY_CACHE: "false" | |
| PREPARE_PATH: "Telegram/build/prepare/prepare.py" | |
| defaults: | |
| run: | |
| shell: cmd | |
| steps: | |
| - name: Prepare directories. | |
| run: | | |
| mkdir %userprofile%\TBuild\Libraries | |
| mklink /d %GITHUB_WORKSPACE%\TBuild %userprofile%\TBuild | |
| echo TBUILD=%GITHUB_WORKSPACE%\TBuild>>%GITHUB_ENV% | |
| echo LibrariesPath=%GITHUB_WORKSPACE%\TBuild\Libraries${{ matrix.arch == 'x64' && '\win64' || '' }}>>%GITHUB_ENV% | |
| - name: Get repository name. | |
| shell: bash | |
| run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV | |
| - name: Clone. | |
| uses: actions/checkout@v7 | |
| with: | |
| submodules: recursive | |
| path: ${{ env.TBUILD }}\${{ env.REPO_NAME }} | |
| - name: First set up. | |
| shell: bash | |
| run: | | |
| DOCPATH=$TBUILD/$REPO_NAME/docs/building-win.md | |
| SDK="$(grep "SDK version" $DOCPATH | sed -r 's/.*\*\*(.*)\*\* SDK version.*/\1/')" | |
| echo "SDK=$SDK" >> $GITHUB_ENV | |
| sed -i '/CMAKE_${lang}_FLAGS_DEBUG_INIT/s/${_Zi}//' "$PROGRAMFILES"/CMake/share/cmake*/Modules/Platform/Windows-MSVC.cmake | |
| echo "$(sha256sum $TBUILD/$REPO_NAME/$PREPARE_PATH | awk '{ print $1 }')" >> CACHE_KEY.txt | |
| echo "$SDK" >> CACHE_KEY.txt | |
| echo "CACHE_KEY=$(sha256sum CACHE_KEY.txt | awk '{ print $1 }')" >> $GITHUB_ENV | |
| echo "Configurate git for cherry-picks." | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "Sample" | |
| - uses: Eden-CI/msvc-dev-cmd@master | |
| name: Native Tools Command Prompt. | |
| with: | |
| arch: ${{ matrix.arch }} | |
| sdk: ${{ env.SDK }} | |
| - name: NuGet sources. | |
| run: | | |
| nuget sources Disable -Name "Microsoft Visual Studio Offline Packages" | |
| nuget sources Add -Source https://api.nuget.org/v3/index.json & exit 0 | |
| - name: ThirdParty cache. | |
| id: cache-third-party | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ env.TBUILD }}\ThirdParty | |
| key: ${{ runner.OS }}-${{ matrix.arch }}-vs2026-third-party-${{ env.CACHE_KEY }} | |
| restore-keys: ${{ runner.OS }}-${{ matrix.arch }}-vs2026-third-party- | |
| - name: Libraries cache. | |
| id: cache-libs | |
| uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ${{ env.LibrariesPath }}\* | |
| !${{ env.LibrariesPath }}\cache_keys | |
| !${{ env.LibrariesPath }}\[qQ]t[_-]* | |
| ${{ env.LibrariesPath }}\cache_keys\* | |
| !${{ env.LibrariesPath }}\cache_keys\[qQ]t[_-]* | |
| key: ${{ runner.OS }}-${{ matrix.arch }}-vs2026-libs-${{ env.CACHE_KEY }} | |
| restore-keys: ${{ runner.OS }}-${{ matrix.arch }}-vs2026-libs- | |
| - name: Qt cache. | |
| id: cache-qt | |
| uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ${{ env.LibrariesPath }}\[qQ]t[_-]* | |
| ${{ env.LibrariesPath }}\cache_keys\[qQ]t[_-]* | |
| key: ${{ runner.OS }}-${{ matrix.arch }}-vs2026-${{ matrix.qt || 'qt' }}-${{ env.CACHE_KEY }} | |
| restore-keys: ${{ runner.OS }}-${{ matrix.arch }}-vs2026-${{ matrix.qt || 'qt' }}- | |
| - name: Libraries. | |
| env: | |
| GYP_MSVS_OVERRIDE_PATH: 'C:\Program Files\Microsoft Visual Studio\18\Enterprise\' | |
| GYP_MSVS_VERSION: 2026 | |
| run: | | |
| cd %TBUILD% | |
| %REPO_NAME%\Telegram\build\prepare\win.bat silent skip-debug ${{ matrix.qt }} | |
| - name: Read configuration matrix. | |
| shell: bash | |
| run: | | |
| ARTIFACT_NAME="AyuGram" | |
| ARCH="" | |
| if [ -n "${{ matrix.arch }}" ]; then | |
| case "${{ matrix.arch }}" in | |
| Win32) ARCH="x86";; | |
| *) ARCH="${{ matrix.arch }}";; | |
| esac | |
| echo "Architecture from matrix: $ARCH" | |
| ARTIFACT_NAME="${ARTIFACT_NAME} ${{ matrix.arch }}" | |
| fi | |
| if [ -n "${{ matrix.qt }}" ]; then | |
| ARTIFACT_NAME="${ARTIFACT_NAME} ${{ matrix.qt }}" | |
| fi | |
| GENERATOR="" | |
| if [ -n "${{ matrix.generator }}" ]; then | |
| GENERATOR="-G \"${{ matrix.generator }}\"" | |
| echo "Generator from matrix: $GENERATOR" | |
| ARTIFACT_NAME="${ARTIFACT_NAME} ${{ matrix.generator }}" | |
| fi | |
| echo "TDESKTOP_BUILD_GENERATOR=$GENERATOR" >> $GITHUB_ENV | |
| [ -n "$GENERATOR" ] && ARCH="" | |
| echo "TDESKTOP_BUILD_ARCH=$ARCH" >> $GITHUB_ENV | |
| DEFINE="" | |
| if [ -n "${{ matrix.defines }}" ]; then | |
| DEFINE="-D ${{ matrix.defines }}=ON" | |
| echo "Define from matrix: $DEFINE" | |
| ARTIFACT_NAME="${ARTIFACT_NAME} ${{ matrix.defines }}" | |
| fi | |
| echo "TDESKTOP_BUILD_DEFINE=$DEFINE" >> $GITHUB_ENV | |
| echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV | |
| - name: Free up some disk space. | |
| shell: bash | |
| run: find $LibrariesPath '(' '(' ! '(' -name '*.lib' -o -name '*.a' -o -name '*.exe' -o -name '*.h' -o -name '*.hpp' -o -name '*.inc' -o -name '*.cmake' -o -path '*/include/*' -o -path '*/objects-*' -o -path '*/cache_keys/*' -o -path '*/patches/*' ')' -type f ')' -o -empty ')' -delete | |
| - name: Telegram Desktop build. | |
| if: env.ONLY_CACHE == 'false' | |
| run: | | |
| cd %TBUILD%\%REPO_NAME%\Telegram | |
| call configure.bat ^ | |
| %TDESKTOP_BUILD_GENERATOR% ^ | |
| %TDESKTOP_BUILD_ARCH% ^ | |
| ${{ matrix.qt }} ^ | |
| -D TDESKTOP_API_ID=2040 ^ | |
| -D TDESKTOP_API_HASH=b18441a1ff607e10a989891a5462e627 ^ | |
| -D DESKTOP_APP_DISABLE_AUTOUPDATE=ON ^ | |
| -D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF ^ | |
| -D "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=" ^ | |
| -D DESKTOP_APP_NO_PDB=ON ^ | |
| %TDESKTOP_BUILD_DEFINE% | |
| cmake --build ..\out --config Release --parallel | |
| - name: Move artifact. | |
| if: (env.UPLOAD_ARTIFACT == 'true') || (github.ref == 'refs/heads/nightly') | |
| run: | | |
| set OUT=%TBUILD%\%REPO_NAME%\out\Release | |
| mkdir artifact | |
| move %OUT%\AyuGram.exe artifact/ | |
| if exist %OUT%\modules xcopy %OUT%\modules artifact\modules\ /E /I /Y | |
| - uses: actions/upload-artifact@v7 | |
| name: Upload artifact. | |
| if: (env.UPLOAD_ARTIFACT == 'true') || (github.ref == 'refs/heads/nightly') | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: artifact\ |