mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
CI/CD: Clean Up Code
This commit is contained in:
parent
61d85033ee
commit
34b3e32f8f
34
.github/runOnRelease.py
vendored
34
.github/runOnRelease.py
vendored
@ -1,21 +1,15 @@
|
|||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.types import (
|
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InputMediaDocument
|
||||||
InlineKeyboardButton,
|
|
||||||
InlineKeyboardMarkup,
|
|
||||||
InputMediaDocument,
|
|
||||||
)
|
|
||||||
from requests import get
|
from requests import get
|
||||||
from tgconfig import TG_API_HASH, TG_API_ID, TG_TOKEN
|
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"
|
TG_CHANNEL = "LibreTube"
|
||||||
|
|
||||||
|
|
||||||
def get_changelog():
|
def get_changelog():
|
||||||
url = "https://api.github.com/repos/libre-tube/LibreTube/contents/fastlane/metadata/android/en-US/changelogs"
|
data = get("https://api.github.com/repos/libre-tube/LibreTube/contents/fastlane/metadata/android/en-US/changelogs").json()
|
||||||
data = get(url).json()
|
|
||||||
last_log = max([int(file["name"].replace(".txt", "")) for file in data])
|
last_log = max([int(file["name"].replace(".txt", "")) for file in data])
|
||||||
log = get(
|
log = get(
|
||||||
f"https://github.com/libre-tube/LibreTube/raw/master/fastlane/metadata/android/en-US/changelogs/{last_log}.txt"
|
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
|
return log
|
||||||
|
|
||||||
|
|
||||||
def download(url, name):
|
|
||||||
with open(name, "wb") as f:
|
|
||||||
f.write(get(url, stream=True).content)
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
buttons = InlineKeyboardMarkup(
|
buttons = InlineKeyboardMarkup(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
@ -45,13 +33,23 @@ buttons = InlineKeyboardMarkup(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
_files, files, result, tag = req.get("assets"), [], req.get("body"), req.get("tag_name")
|
assets, files = req.get("assets"), list()
|
||||||
for file in _files:
|
|
||||||
|
for file in assets:
|
||||||
|
with open(name, "wb") as f:
|
||||||
|
f.write(get(file.get("browser_download_url"), stream=True).content)
|
||||||
|
|
||||||
files.append(
|
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()}```"
|
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:
|
with Client("bot", TG_API_ID, TG_API_HASH, bot_token=TG_TOKEN) as app:
|
||||||
app.send_photo(
|
app.send_photo(
|
||||||
TG_CHANNEL,
|
TG_CHANNEL,
|
||||||
|
4
.github/uploader.py
vendored
4
.github/uploader.py
vendored
@ -1,6 +1,6 @@
|
|||||||
from os import system as run, listdir, remove
|
from os import system as run, listdir, remove
|
||||||
from json import load
|
from json import load
|
||||||
import tgconfig
|
import config_fie
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
with open("../.github/commit.json") as f:
|
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":
|
if tgconfig.GH_REPO.lower() == "libre-tube/libretube":
|
||||||
run("git add -f *")
|
run("git add -f *")
|
||||||
run(f"git commit -m \"{message}\"")
|
run(f'git commit -m "{message}"')
|
||||||
run("git push -u")
|
run("git push -u")
|
||||||
else:
|
else:
|
||||||
print("Official Repo not Detected")
|
print("Official Repo not Detected")
|
||||||
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -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
|
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
|
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||||
|
|
||||||
- name: Check for Execution Orders
|
- name: Retrieve Commit Info
|
||||||
run: |
|
run: |
|
||||||
cd .github
|
cd .github
|
||||||
curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json
|
curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json
|
||||||
@ -65,7 +65,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
mv .github/uploader.py .
|
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
|
git clone --filter=blob:none https://github.com/libre-tube/NightlyBuilds nightly
|
||||||
rm -rf nightly/*.apk
|
rm -rf nightly/*.apk
|
||||||
mv app/build/outputs/apk/debug/*.apk nightly/
|
mv app/build/outputs/apk/debug/*.apk nightly/
|
||||||
|
6
.github/workflows/run-on-release.yml
vendored
6
.github/workflows/run-on-release.yml
vendored
@ -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
|
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
|
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||||
|
|
||||||
- name: Upload to Telegram
|
- name: Upload to Telegram (@LibreTube)
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/${{ github.repository }} && cd LibreTube
|
|
||||||
echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py
|
echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py
|
||||||
echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py
|
echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py
|
||||||
echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py
|
echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py
|
||||||
pip install pyrogram TgCrypto requests
|
pip install pyrogram TgCrypto requests
|
||||||
mv .github/runOnRelease.py .
|
mv .github/runOnRelease.py .
|
||||||
python runOnRelease.py
|
python runOnRelease.py
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user