diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 0000000000..c4c4d6df80 --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -0,0 +1,77 @@ +name: Build Linux + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' # Important if ThirdParty libs are submodules + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN is automatically created + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: ./Telegram/build/docker/centos_env + file: ./Telegram/build/docker/centos_env/Dockerfile # Assuming Dockerfile is here + push: false # Set to true if you want to push to ghcr.io + tags: ghcr.io/${{ github.repository_owner }}/tdesktop-centos-env:latest # Example tag + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # build-args: | # If Dockerfile needs build args + # SOME_ARG=value + + # This step will be executed after the image is built and (optionally) pushed + - name: Move Docker cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Run build script in Docker container + run: | + docker run --rm \ + -v ${{ github.workspace }}:/usr/src/tdesktop \ + ghcr.io/${{ github.repository_owner }}/tdesktop-centos-env:latest \ + /usr/src/tdesktop/Telegram/build/docker/build.sh + # Note: The above docker run command assumes build.sh is executable + # and all necessary paths inside the container are correct. + # It also assumes that build.sh places artifacts in a subdirectory + # of ${{ github.workspace }}/Telegram/../out/Release (e.g., /usr/src/tdesktop/out/Release) + + - name: Upload Telegram binary + uses: actions/upload-artifact@v3 + with: + name: Telegram-linux + path: ${{ github.workspace }}/out/Release/Telegram # Adjust path if necessary + if-no-files-found: error + + - name: Upload Updater binary + uses: actions/upload-artifact@v3 + with: + name: Updater-linux + path: ${{ github.workspace }}/out/Release/Updater # Adjust path if necessary + if-no-files-found: error diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000000..bff7443489 --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,74 @@ +name: Build macOS + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +jobs: + build: + runs-on: macos-12 # Using macos-12 for now, might need adjustment based on Xcode/SDK requirements + env: + MACOSX_DEPLOYMENT_TARGET: "10.13" # As seen in prepare.py + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Select Xcode version (if specific version needed) + run: sudo xcode-select -s /Applications/Xcode_13.4.1.app/Contents/Developer # Example, adjust as needed + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' # prepare.py uses python3 + + - name: Cache Dependencies + id: cache-deps + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/Libraries + ${{ github.workspace }}/ThirdParty + key: ${{ runner.os }}-deps-${{ hashFiles('Telegram/build/prepare/prepare.py', 'Telegram/build/qt_version.py') }} + restore-keys: | + ${{ runner.os }}-deps- + + - name: Install Python dependencies for prepare.py (if any) + run: | + # Assuming prepare.py and its direct imports don't have external pip dependencies + # If they do, they should be installed here. + echo "No Python dependencies to install for prepare.py itself for now." + + - name: Run prepare.py for dependencies + if: steps.cache-deps.outputs.cache-hit != 'true' + run: | + cd Telegram/build/prepare + python3 prepare.py skip-release # Adding skip-release as we only want to compile + # prepare.py will build into Libraries and ThirdParty folders at the repo root. + env: + QT: '5.15.2' # Example, this should ideally be determined by qt_version.py logic if possible + # or made a matrix variable if multiple Qt versions need support. + + - name: Configure build (emulating build.sh steps) + run: | + cd Telegram # build.sh runs configure.sh from Telegram directory + # Forcing specific architectures for CI; can be parameterized or matrix later + # Using x86_64 for macos-12 runner for broader compatibility for now + ./configure.sh -D DESKTOP_APP_MAC_ARCH="x86_64" -D DESKTOP_APP_DISABLE_JEMALLOC=ON + # DESKTOP_APP_DISABLE_JEMALLOC=ON is often useful for CI/dev builds + + - name: Build Telegram + run: | + cd out # configure.sh creates an 'out' directory at the repo root + cmake --build . --config Release --target Telegram -j $(sysctl -n hw.ncpu) + + - name: Upload Telegram.app + uses: actions/upload-artifact@v4 + with: + name: Telegram-macOS-x86_64.app + path: ${{ github.workspace }}/out/Release/Telegram.app + if-no-files-found: error diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 0000000000..924b902153 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,101 @@ +name: Build Windows + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +jobs: + build: + runs-on: windows-2019 # Using windows-2019 for VS 2019, adjust if VS 2022 (windows-2022) is needed + env: + # Variables needed by prepare.py and build scripts + # Platform: x86, x64, arm64. This is usually set by the VS Native Tools Command Prompt. + # We'll use setup-msvc to achieve a similar environment. + # QT: As seen in prepare.py, this might be needed. + CHOCOLATEY_VERBOSITY: "fatal" # Make choco less noisy + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' # prepare.py uses python + + - name: Set up MSVC developer environment + uses: microsoft/setup-msvc-dev@v1 + with: + arch: 'x64' # Or 'x86', 'arm64'. This sets up the %Platform% env var. + # vs-version: '16.0' # For VS 2019. For VS 2022 use '17.0' and windows-2022 runner. + + - name: Install Inno Setup (if tsetup*.exe packaging is strictly part of compilation) + run: choco install innosetup --no-progress + # This is from build.bat, may not be needed if we only compile Telegram.exe and Updater.exe + + - name: Install 7-Zip (if tportable*.zip packaging is strictly part of compilation) + run: choco install 7zip.install --no-progress + # This is from build.bat, may not be needed + + - name: Cache Dependencies + id: cache-deps + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/Libraries + ${{ github.workspace }}/ThirdParty + key: ${{ runner.os }}-${{ env.Platform }}-deps-${{ hashFiles('Telegram/build/prepare/prepare.py', 'Telegram/build/qt_version.py') }} + restore-keys: | + ${{ runner.os }}-${{ env.Platform }}-deps- + + - name: Run prepare.py for dependencies + if: steps.cache-deps.outputs.cache-hit != 'true' + shell: cmd # prepare.py and its stages might use cmd-specific commands or rely on VS env + run: | + cd Telegram\build\prepare + python prepare.py skip-release + # prepare.py will build into Libraries and ThirdParty folders at the repo root. + env: + QT: '5.15.2' # Example, adjust as needed or determine from qt_version.py + + - name: Configure build (emulating build.bat steps) + shell: cmd + run: | + cd Telegram + call configure.bat + # configure.bat should set up the 'out' directory. + # It uses %Platform% which is set by setup-msvc-dev. + + - name: Build Telegram + shell: cmd + run: | + cd out + call cmake --build . --config Release --target Telegram -- /m:%NUMBER_OF_PROCESSORS% + # Using /m for parallel build with MSBuild (which CMake generates for VS) + + - name: Upload Telegram.exe + uses: actions/upload-artifact@v4 + with: + name: Telegram-windows-${{ env.Platform }}.exe + path: ${{ github.workspace }}/out/Release/Telegram.exe + if-no-files-found: error + + - name: Upload Updater.exe + uses: actions/upload-artifact@v4 + with: + name: Updater-windows-${{ env.Platform }}.exe + path: ${{ github.workspace }}/out/Release/Updater.exe + if-no-files-found: error + + - name: Upload PDBs (optional) + uses: actions/upload-artifact@v4 + with: + name: Symbols-windows-${{ env.Platform }} + path: | + ${{ github.workspace }}/out/Release/Telegram.pdb + ${{ github.workspace }}/out/Release/Updater.pdb + if-no-files-found: warn