CI/CD: Clean Up Code

This commit is contained in:
XelXen 2023-11-19 22:37:39 +05:30 committed by GitHub
parent 61d85033ee
commit 34b3e32f8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 26 deletions

View File

@ -1,21 +1,15 @@
from pyrogram import Client
from pyrogram.types import (
InlineKeyboardButton,
InlineKeyboardMarkup,
InputMediaDocument,
)
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InputMediaDocument
from requests import get
from tgconfig import TG_API_HASH, TG_API_ID, TG_TOKEN
url = "https://api.github.com/repos/Libre-Tube/LibreTube/releases/latest"
req = get(url).json()
req = get("https://api.github.com/repos/Libre-Tube/LibreTube/releases/latest").json()
TG_CHANNEL = "LibreTube"
def get_changelog():
url = "https://api.github.com/repos/libre-tube/LibreTube/contents/fastlane/metadata/android/en-US/changelogs"
data = get(url).json()
data = get("https://api.github.com/repos/libre-tube/LibreTube/contents/fastlane/metadata/android/en-US/changelogs").json()
last_log = max([int(file["name"].replace(".txt", "")) for file in data])
log = get(
f"https://github.com/libre-tube/LibreTube/raw/master/fastlane/metadata/android/en-US/changelogs/{last_log}.txt"
@ -23,12 +17,6 @@ def get_changelog():
return log
def download(url, name):
with open(name, "wb") as f:
f.write(get(url, stream=True).content)
return name
buttons = InlineKeyboardMarkup(
[
[
@ -45,13 +33,23 @@ buttons = InlineKeyboardMarkup(
)
_files, files, result, tag = req.get("assets"), [], req.get("body"), req.get("tag_name")
for file in _files:
assets, files = req.get("assets"), list()
for file in assets:
with open(name, "wb") as f:
f.write(get(file.get("browser_download_url"), stream=True).content)
files.append(
InputMediaDocument(download(file.get("browser_download_url"), file.get("name")))
InputMediaDocument(
download(
file.get("name")
)
)
)
caption = f"**LibreTube {tag} // Privacy Simplified**\n\n<u>What's Changed?</u>\n```{get_changelog()}```"
with Client("bot", TG_API_ID, TG_API_HASH, bot_token=TG_TOKEN) as app:
app.send_photo(
TG_CHANNEL,

4
.github/uploader.py vendored
View File

@ -1,6 +1,6 @@
from os import system as run, listdir, remove
from json import load
import tgconfig
import config_fie
import hashlib
with open("../.github/commit.json") as f:
@ -28,7 +28,7 @@ with open("checksums", "w") as checksums:
if tgconfig.GH_REPO.lower() == "libre-tube/libretube":
run("git add -f *")
run(f"git commit -m \"{message}\"")
run(f'git commit -m "{message}"')
run("git push -u")
else:
print("Official Repo not Detected")

View File

@ -26,7 +26,7 @@ jobs:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Check for Execution Orders
- name: Retrieve Commit Info
run: |
cd .github
curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json
@ -65,7 +65,7 @@ jobs:
continue-on-error: true
run: |
mv .github/uploader.py .
echo "GH_REPO = '${{ github.repository }}'" > tgconfig.py
echo "GH_REPO = '${{ github.repository }}'" > config_file.py
git clone --filter=blob:none https://github.com/libre-tube/NightlyBuilds nightly
rm -rf nightly/*.apk
mv app/build/outputs/apk/debug/*.apk nightly/

View File

@ -13,13 +13,11 @@ jobs:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Upload to Telegram
- name: Upload to Telegram (@LibreTube)
run: |
git clone https://github.com/${{ github.repository }} && cd LibreTube
echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py
echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py
echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py
pip install pyrogram TgCrypto requests
mv .github/runOnRelease.py .
python runOnRelease.py
python runOnRelease.py