Forkgram v7.1.0 #1150
Workflow file for this run
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: Linux. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version label (e.g., v5.15.3)' | |
| required: false | |
| type: string | |
| release: | |
| types: [published] | |
| repository_dispatch: | |
| types: ["Restart linux workflow."] | |
| push: | |
| paths-ignore: | |
| - 'docs/**' | |
| - '**.md' | |
| - 'changelog.txt' | |
| - 'LEGAL' | |
| - 'LICENSE' | |
| - '.github/**' | |
| - '!.github/workflows/linux.yml' | |
| - 'snap/**' | |
| - 'Telegram/build/**' | |
| - '!Telegram/build/docker/centos_env/**' | |
| - 'Telegram/Resources/uwp/**' | |
| - 'Telegram/Resources/winrc/**' | |
| - 'Telegram/SourceFiles/platform/win/**' | |
| - 'Telegram/SourceFiles/platform/mac/**' | |
| - 'Telegram/Telegram/**' | |
| - 'Telegram/configure.bat' | |
| - 'Telegram/Telegram.plist' | |
| pull_request: | |
| paths-ignore: | |
| - 'docs/**' | |
| - '**.md' | |
| - 'changelog.txt' | |
| - 'LEGAL' | |
| - 'LICENSE' | |
| - '.github/**' | |
| - '!.github/workflows/linux.yml' | |
| - 'snap/**' | |
| - 'Telegram/build/**' | |
| - '!Telegram/build/docker/centos_env/**' | |
| - 'Telegram/Resources/uwp/**' | |
| - 'Telegram/Resources/winrc/**' | |
| - 'Telegram/SourceFiles/platform/win/**' | |
| - 'Telegram/SourceFiles/platform/mac/**' | |
| - 'Telegram/Telegram/**' | |
| - 'Telegram/configure.bat' | |
| - 'Telegram/Telegram.plist' | |
| jobs: | |
| linux: | |
| name: Rocky Linux 8 | |
| runs-on: ${{ (github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/nightly') && 'depot-ubuntu-latest-16' || 'ubuntu-latest' }} | |
| strategy: | |
| matrix: | |
| defines: | |
| - "" | |
| env: | |
| UPLOAD_ARTIFACT: "true" | |
| ONLY_CACHE: "false" | |
| IMAGE_TAG: tdesktop:centos_env | |
| steps: | |
| - name: Validate upload secret parts. | |
| env: | |
| UPDATER_UPLOAD_BASE64: ${{ secrets.UPDATER_UPLOAD_BASE64 }} | |
| UPDATER_UPLOAD_BASE64_PART1: ${{ secrets.UPDATER_UPLOAD_BASE64_PART1 }} | |
| UPDATER_UPLOAD_BASE64_PART2: ${{ secrets.UPDATER_UPLOAD_BASE64_PART2 }} | |
| UPDATER_UPLOAD_BASE64_PART3: ${{ secrets.UPDATER_UPLOAD_BASE64_PART3 }} | |
| run: | | |
| echo "UPDATER_UPLOAD_BASE64 length: ${#UPDATER_UPLOAD_BASE64}" | |
| echo "UPDATER_UPLOAD_BASE64_PART1 length: ${#UPDATER_UPLOAD_BASE64_PART1}" | |
| echo "UPDATER_UPLOAD_BASE64_PART2 length: ${#UPDATER_UPLOAD_BASE64_PART2}" | |
| echo "UPDATER_UPLOAD_BASE64_PART3 length: ${#UPDATER_UPLOAD_BASE64_PART3}" | |
| MERGED_UPLOAD_BASE64="${UPDATER_UPLOAD_BASE64_PART1}${UPDATER_UPLOAD_BASE64_PART2}${UPDATER_UPLOAD_BASE64_PART3}" | |
| if [ -z "${MERGED_UPLOAD_BASE64}" ]; then | |
| MERGED_UPLOAD_BASE64="${UPDATER_UPLOAD_BASE64}" | |
| fi | |
| echo "Merged parts length: ${#MERGED_UPLOAD_BASE64}" | |
| if [ -z "${MERGED_UPLOAD_BASE64}" ]; then | |
| echo "No upload base64 payload provided." | |
| exit 0 | |
| fi | |
| if ! printf "%s" "${MERGED_UPLOAD_BASE64}" | base64 --decode > /tmp/updater_upload_check.zip 2>/tmp/updater_upload_check.err; then | |
| echo "Base64 decode failed." | |
| cat /tmp/updater_upload_check.err | |
| exit 1 | |
| fi | |
| if [ ! -s /tmp/updater_upload_check.zip ]; then | |
| echo "Decoded payload is empty." | |
| exit 1 | |
| fi | |
| echo "Decoded file info: $(file -b /tmp/updater_upload_check.zip)" | |
| - name: Clone. | |
| uses: actions/checkout@v7 | |
| with: | |
| submodules: recursive | |
| - name: First set up. | |
| run: | | |
| sudo apt update | |
| curl -sSL https://install.python-poetry.org | python3 - | |
| curl -sSL https://github.com/ccache/ccache/releases/download/v4.13.6/ccache-4.13.6-linux-x86_64-glibc.tar.xz \ | |
| | sudo tar xJ -C /usr/local/bin --strip-components=1 ccache-4.13.6-linux-x86_64-glibc/ccache | |
| echo "CCACHE_DIR=$RUNNER_TEMP/.tdesktop-cache" >> $GITHUB_ENV | |
| cd Telegram/build/docker/centos_env | |
| poetry install | |
| DOCKERFILE=$(DEBUG= LTO= poetry run gen_dockerfile) | |
| echo "$DOCKERFILE" > Dockerfile | |
| rm -rf __pycache__ | |
| sudo apt -y install wget 7zip unzip | |
| cd $GITHUB_WORKSPACE/.. | |
| rm -rf DesktopPrivate | |
| mkdir -p DesktopPrivate | |
| if [ -n "${{ secrets.DESKTOP_PRIVATE_BASE64 }}" ]; then | |
| echo "${{ secrets.DESKTOP_PRIVATE_BASE64 }}" | base64 --decode > desktop_private.zip | |
| unzip -oq desktop_private.zip -d DesktopPrivate | |
| else | |
| cd DesktopPrivate | |
| echo "#pragma once" > alpha_private.h | |
| echo "#pragma once" > packer_private.h | |
| echo '${{ secrets.ALPHA_PRIVATE }}' >> alpha_private.h | |
| echo '${{ secrets.PACKER_PRIVATE }}' >> packer_private.h | |
| cd .. | |
| fi | |
| wget ${{ secrets.PACK_FILE }} -O p.7z | |
| 7za x p.7z -p${{ secrets.PACK_FILE_PASSWORD }} | |
| - name: Free up some disk space. | |
| uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be | |
| with: | |
| tool-cache: true | |
| - name: Set up Docker Buildx. | |
| id: setup-buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Libraries cache. | |
| id: cache-libs | |
| uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ${{ runner.temp }}/.buildx-cache | |
| ${{ runner.temp }}/.mount-cache | |
| key: ${{ runner.OS }}-libs-${{ hashFiles('Telegram/build/docker/centos_env/**') }} | |
| restore-keys: ${{ runner.OS }}-libs- | |
| - name: Restore Docker cache mounts. | |
| uses: reproducible-containers/buildkit-cache-dance@5422eac04292c961a382e0f584ea0f03ad9da723 | |
| with: | |
| builder: ${{ steps.setup-buildx.outputs.name }} | |
| cache-dir: ${{ runner.temp }}/.mount-cache | |
| dockerfile: Telegram/build/docker/centos_env/Dockerfile | |
| skip-extraction: ${{ steps.cache-libs.outputs.cache-hit }} | |
| - name: Libraries. | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: Telegram/build/docker/centos_env | |
| load: ${{ env.ONLY_CACHE == 'false' }} | |
| tags: ${{ env.IMAGE_TAG }} | |
| cache-from: type=local,src=${{ runner.temp }}/.buildx-cache | |
| cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max | |
| - name: Move cache. | |
| run: | | |
| rm -rf ${{ runner.temp }}/.buildx-cache | |
| mv ${{ runner.temp }}/.buildx-cache{-new,} | |
| - name: Restore Telegram Desktop cache. | |
| id: cache-tdesktop | |
| if: env.ONLY_CACHE == 'false' | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: ${{ env.CCACHE_DIR }} | |
| key: ${{ runner.OS }}-tdesktop-${{ matrix.defines || 'null' }}-${{ github.run_id }} | |
| restore-keys: ${{ runner.OS }}-tdesktop-${{ matrix.defines || 'null' }}- | |
| - name: Telegram Desktop build. | |
| if: env.ONLY_CACHE == 'false' | |
| run: | | |
| DEFINE="" | |
| if [ -n "${{ matrix.defines }}" ]; then | |
| DEFINE="-D ${{ matrix.defines }}=ON" | |
| echo Define from matrix: $DEFINE | |
| echo "ARTIFACT_NAME=Telegram ${{ matrix.defines }}" >> $GITHUB_ENV | |
| else | |
| echo "ARTIFACT_NAME=Telegram" >> $GITHUB_ENV | |
| fi | |
| ccache -z | |
| docker run --rm \ | |
| -u $(id -u) \ | |
| -v $PWD:/usr/src/tdesktop \ | |
| -v ${{ env.CCACHE_DIR }}:/var/cache/ccache \ | |
| -e CONFIG=Debug \ | |
| -e CCACHE_SLOPPINESS=pch_defines,time_macros \ | |
| $IMAGE_TAG \ | |
| /usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \ | |
| -D TDESKTOP_API_ID=${{ secrets.API_ID }} \ | |
| -D TDESKTOP_API_HASH=${{ secrets.API_HASH }} \ | |
| -D DESKTOP_APP_SPECIAL_TARGET=linux \ | |
| $DEFINE | |
| - name: Count ccache misses. | |
| id: ccache-stats | |
| if: env.ONLY_CACHE == 'false' | |
| run: | | |
| MISSES=$(ccache --print-stats | sed -n 's/^cache_miss\t//p' | head -1) | |
| case "$MISSES" in (*[!0-9]*|'') MISSES=0;; esac | |
| echo "misses=$MISSES" >> $GITHUB_OUTPUT | |
| echo "ccache misses this run: $MISSES" | |
| - name: Trim Telegram Desktop cache. | |
| if: > | |
| env.ONLY_CACHE == 'false' | |
| && github.ref_name == github.event.repository.default_branch | |
| && fromJSON(steps.ccache-stats.outputs.misses) > 300 | |
| run: ccache --evict-older-than 1d | |
| - name: Save Telegram Desktop cache. | |
| if: > | |
| env.ONLY_CACHE == 'false' | |
| && github.ref_name == github.event.repository.default_branch | |
| && fromJSON(steps.ccache-stats.outputs.misses) > 300 | |
| uses: actions/cache/save@v6 | |
| with: | |
| path: ${{ env.CCACHE_DIR }} | |
| key: ${{ steps.cache-tdesktop.outputs.cache-primary-key }} | |
| - name: Check. | |
| if: env.ONLY_CACHE == 'false' | |
| run: | | |
| filePath="out/MinSizeRel/Forkgram" | |
| if test -f "$filePath"; then | |
| echo "Build successfully done! :)" | |
| size=$(stat -c %s "$filePath") | |
| echo "File size of ${filePath}: ${size} Bytes." | |
| else | |
| echo "Build error, output file does not exist." | |
| exit 1 | |
| fi | |
| - name: Compress. | |
| if: (github.event_name == 'release') | |
| run: tar -cJvf Forkgram.tar.xz -C out/MinSizeRel Forkgram Updater | |
| - name: Pack updater files. | |
| if: (github.event_name == 'release') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'repository_dispatch') | |
| run: | | |
| verPacker=$(awk '$1 == "AppVersion" { print $2 }' Telegram/build/version) | |
| cd out/MinSizeRel | |
| BEFORE=$(mktemp) | |
| AFTER=$(mktemp) | |
| ls -1 tlinuxupd* 2>/dev/null | sort > "$BEFORE" || true | |
| ./Packer -path Forkgram -path Updater -version "$verPacker" | |
| ls -1 tlinuxupd* 2>/dev/null | sort > "$AFTER" || true | |
| UPDATE_FILE=$(comm -13 "$BEFORE" "$AFTER" | tail -n 1) | |
| if [ -z "$UPDATE_FILE" ]; then | |
| UPDATE_FILE=$(ls -1t tlinuxupd* | head -n 1) | |
| fi | |
| if [ -z "$UPDATE_FILE" ] || [ ! -f "$UPDATE_FILE" ]; then | |
| echo "Packed update file was not generated." | |
| exit 1 | |
| fi | |
| echo "PACKED_UPDATE_FILE=$GITHUB_WORKSPACE/out/MinSizeRel/$UPDATE_FILE" >> $GITHUB_ENV | |
| echo "PACKED_UPDATE_BASENAME=$UPDATE_FILE" >> $GITHUB_ENV | |
| echo "VER_PACKER=$verPacker" >> $GITHUB_ENV | |
| - name: Upload packed updater to Telegram channel. | |
| if: (github.event_name == 'release') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'repository_dispatch') | |
| env: | |
| UPDATER_UPLOAD_BASE64: ${{ secrets.UPDATER_UPLOAD_BASE64 }} | |
| UPDATER_UPLOAD_BASE64_PART1: ${{ secrets.UPDATER_UPLOAD_BASE64_PART1 }} | |
| UPDATER_UPLOAD_BASE64_PART2: ${{ secrets.UPDATER_UPLOAD_BASE64_PART2 }} | |
| UPDATER_UPLOAD_BASE64_PART3: ${{ secrets.UPDATER_UPLOAD_BASE64_PART3 }} | |
| run: | | |
| MERGED_UPLOAD_BASE64="${UPDATER_UPLOAD_BASE64_PART1}${UPDATER_UPLOAD_BASE64_PART2}${UPDATER_UPLOAD_BASE64_PART3}" | |
| if [ -z "${MERGED_UPLOAD_BASE64}" ]; then | |
| MERGED_UPLOAD_BASE64="${UPDATER_UPLOAD_BASE64}" | |
| fi | |
| if [ -z "${MERGED_UPLOAD_BASE64}" ]; then | |
| echo "UPDATER_UPLOAD_BASE64(_PART1/_PART2/_PART3) is empty, skip channel upload." | |
| exit 0 | |
| fi | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install requests tgcrypto-pyrofork Kurigram | |
| rm -rf updater_channel_upload | |
| mkdir -p updater_channel_upload | |
| printf "%s" "${MERGED_UPLOAD_BASE64}" | base64 --decode > updater_upload.raw | |
| if unzip -tqq updater_upload.raw >/dev/null 2>&1; then | |
| unzip -oq updater_upload.raw -d updater_channel_upload | |
| elif tar -tzf updater_upload.raw >/dev/null 2>&1; then | |
| tar -xzf updater_upload.raw -C updater_channel_upload | |
| elif tar -tf updater_upload.raw >/dev/null 2>&1; then | |
| tar -xf updater_upload.raw -C updater_channel_upload | |
| else | |
| echo "Unsupported upload bundle format: $(file -b updater_upload.raw)" | |
| exit 1 | |
| fi | |
| ( | |
| cd updater_channel_upload | |
| 7za a -tzip -mx=0 ../updater_upload.zip . >/dev/null | |
| ) | |
| SCRIPT_PATH=$(find updater_channel_upload -type f -name linux_pack_upl.py | head -n 1) | |
| if [ -z "$SCRIPT_PATH" ]; then | |
| echo "linux_pack_upl.py not found in UPDATER_UPLOAD_BASE64 bundle." | |
| exit 1 | |
| fi | |
| SCRIPT_DIR=$(dirname "$SCRIPT_PATH") | |
| cp "$PACKED_UPDATE_FILE" "$SCRIPT_DIR/" | |
| cp updater_upload.zip "$SCRIPT_DIR/" | |
| cd "$SCRIPT_DIR" | |
| if [ -f requirements.txt ]; then | |
| python3 -m pip install -r requirements.txt | |
| fi | |
| python3 linux_pack_upl.py "tlinuxupd${VER_PACKER}" | |
| - name: Upload. | |
| if: (github.event_name == 'release') | |
| uses: svenstaro/upload-release-action@2.11.4 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ./Forkgram.tar.xz | |
| tag: ${{ github.event.release.tag_name }} | |
| asset_name: Forkgram.tar.xz |