Arquivos
tdesktop/.github/workflows/linux.yml
T
2026-05-08 09:40:20 +03:00

299 linhas
11 KiB
YAML

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/')) && '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@v6
with:
submodules: recursive
- name: First set up.
run: |
sudo apt update
curl -sSL https://install.python-poetry.org | python3 -
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.
uses: docker/setup-buildx-action@v4
- name: Libraries cache.
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/.buildx-cache
key: ${{ runner.OS }}-libs-${{ hashFiles('Telegram/build/docker/centos_env/**') }}
restore-keys: ${{ runner.OS }}-libs-
- 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: 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
docker run --rm \
-u $(id -u) \
-v $PWD:/usr/src/tdesktop \
-v $PWD/../DesktopPrivate:/usr/src/DesktopPrivate \
$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
strip -s out/MinSizeRel/Forkgram
- 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