forked from telegramdesktop/tdesktop
-
Notifications
You must be signed in to change notification settings - Fork 29
298 lines (261 loc) · 10.6 KB
/
linux.yml
File metadata and controls
298 lines (261 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
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: 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