From 9a0ea4ee7cd2b93398f188249d573e11e307efce Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sat, 17 Sep 2022 23:28:46 +0530 Subject: [PATCH 01/14] Centralise Builds to Archive --- .github/pkg.py | 25 +++++++++++++++++++++++++ .github/workflows/api-compiler.yml | 6 +++--- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++-- .github/workflows/tg-bot.yml | 20 +++++--------------- 4 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 .github/pkg.py diff --git a/.github/pkg.py b/.github/pkg.py new file mode 100644 index 000000000..7cc4fc63d --- /dev/null +++ b/.github/pkg.py @@ -0,0 +1,25 @@ +import subprocess + +while True: + outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output ~/app-x86-debug.apk", shell=True) + if "Not Found" not in outputStr: + print("Build [x86] Downloaded") + break + +while True: + outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86_64-debug.apk --output ~/app-x86_64-debug.apk", shell=True) + if "Not Found" not in outputStr: + print("Build [x86_64] Downloaded") + break + +while True: + outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v7a-debug.apk --output ~/app-armeabi-v7a-debug.apk", shell=True) + if "Not Found" not in outputStr: + print("Build [arm7] Downloaded") + break + +while True: + outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v8a-debug.apk --output ~/app-armeabi-v8a-debug.apk", shell=True) + if "Not Found" not in outputStr: + print("Build [arm8] Downloaded") + break \ No newline at end of file diff --git a/.github/workflows/api-compiler.yml b/.github/workflows/api-compiler.yml index 176c2d079..850ab5a6a 100644 --- a/.github/workflows/api-compiler.yml +++ b/.github/workflows/api-compiler.yml @@ -21,10 +21,10 @@ jobs: chmod 755 .github/compiler.sh .github/compiler.sh - - name: Binary Archive + - name: Upload to Archive run: | - git clone https://github.com/LibreTubeAlpha/Telegram-BotAPI bot-api - rm -rf bot-api/* + git clone https://github.com/LibreTubeAlpha/Archive bot-api + rm -rf bot-api/exec mv ~/telegram-bot-api/bin/telegram-bot-api bot-api/exec cd bot-api git add -f * diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3300df239..e9d2d4f35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,13 +22,27 @@ jobs: - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 - - name: set up JDK 11 + - name: Check for Execution Orders + run: | + cd .github + curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json + python checkrun.py + cd .. + + - name: Set up JDK 11 uses: actions/setup-java@v3 with: java-version: 11 distribution: "temurin" cache: "gradle" + - name: Prepare for Compilation + run: | + git config --global user.name "XelXen" + git config --global user.email "78258352+XelXen@users.noreply.github.com" + git config --global credential.helper store + echo "https://XelXen:${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials + - name: Patch and Compile run: | cd .github @@ -36,8 +50,19 @@ jobs: cd .. ./gradlew assembleDebug + - name: Upload to Archive + run: | + git clone https://github.com/LibreTubeAlpha/Archive archive + rm -rf archive/*.apk + mv app/build/outputs/apk/debug/*.apk archive/ + cd archive + git add -f * + git commit -m "WORKFLOW: ALPHA BUILDS" + git push -u + cd .. + - name: Upload APK uses: actions/upload-artifact@v3 with: name: app - path: app/build/outputs/apk/debug/*.apk + path: archive/*.apk diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml index 9f142fec7..6a911834b 100644 --- a/.github/workflows/tg-bot.yml +++ b/.github/workflows/tg-bot.yml @@ -14,7 +14,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - uses: actions/setup-python@v3 with: python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax @@ -27,28 +26,19 @@ jobs: python checkrun.py cd .. - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: "temurin" - cache: "gradle" - - - name: Patch and Compile + - name: Download packages run: | cd .github - python patch.py + python pkg.py cd .. - ./gradlew assembleDebug - name: Telegram Bot continue-on-error: true run: | - mv ./app/build/outputs/apk/debug/*.apk .github/ - cd .github + cd ~ curl https://libre-tube.github.io/images/LibreAlpha.png --output alpha.png - curl https://raw.githubusercontent.com/LibreTubeAlpha/Telegram-BotAPI/main/exec --output ~/bot-api - chmod 755 ~/bot-api + curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/exec --output ~/bot-api + chmod 755 ./bot-api echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" > tgconfig.py echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py From ecd41f7db3837267abc8c186d5ff5eef14df72a2 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sat, 17 Sep 2022 23:37:44 +0530 Subject: [PATCH 02/14] Fix Collecting Shell Output --- .github/pkg.py | 14 +++++++++----- .github/workflows/tg-bot.yml | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/pkg.py b/.github/pkg.py index 7cc4fc63d..b52625542 100644 --- a/.github/pkg.py +++ b/.github/pkg.py @@ -1,25 +1,29 @@ -import subprocess +import os while True: - outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output ~/app-x86-debug.apk", shell=True) + os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output app-x86-debug.apk") + outputStr = open("app-x86-debug.apk","r").read() if "Not Found" not in outputStr: print("Build [x86] Downloaded") break while True: - outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86_64-debug.apk --output ~/app-x86_64-debug.apk", shell=True) + os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86_64-debug.apk --output app-x86_64-debug.apk") + outputStr = open("app-x86_64-debug.apk","r").read() if "Not Found" not in outputStr: print("Build [x86_64] Downloaded") break while True: - outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v7a-debug.apk --output ~/app-armeabi-v7a-debug.apk", shell=True) + os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v7a-debug.apk --output app-armeabi-v7a-debug.apk") + outputStr = open("app-armeabi-v7a-debug.apk","r").read() if "Not Found" not in outputStr: print("Build [arm7] Downloaded") break while True: - outputStr = subprocess.call("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v8a-debug.apk --output ~/app-armeabi-v8a-debug.apk", shell=True) + os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v8a-debug.apk --output app-armeabi-v8a-debug.apk") + outputStr = open("app-armeabi-v8a-debug.apk","r").read() if "Not Found" not in outputStr: print("Build [arm8] Downloaded") break \ No newline at end of file diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml index 6a911834b..2dbf46704 100644 --- a/.github/workflows/tg-bot.yml +++ b/.github/workflows/tg-bot.yml @@ -28,7 +28,7 @@ jobs: - name: Download packages run: | - cd .github + cd ~ python pkg.py cd .. From 08a546c0b5fa1ba9c6977f8ec8f419005299c582 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sat, 17 Sep 2022 23:41:03 +0530 Subject: [PATCH 03/14] Fix paths --- .github/workflows/tg-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml index 2dbf46704..1aefcc42f 100644 --- a/.github/workflows/tg-bot.yml +++ b/.github/workflows/tg-bot.yml @@ -29,8 +29,8 @@ jobs: - name: Download packages run: | cd ~ + mv .github/pkg.py . python pkg.py - cd .. - name: Telegram Bot continue-on-error: true From df133f0a36cc2b27d7b83080946b070f0bde8655 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 10:47:24 +0530 Subject: [PATCH 04/14] Enable SHA Checking --- .github/checkrun.py | 3 +-- .github/pkg.py | 39 ++++++++++++++++-------------------- .github/sign.py | 4 ++++ .github/tg.py | 4 ++-- .github/workflows/ci.yml | 5 ++++- .github/workflows/tg-bot.yml | 10 +++++---- 6 files changed, 34 insertions(+), 31 deletions(-) create mode 100644 .github/sign.py diff --git a/.github/checkrun.py b/.github/checkrun.py index e04e0f6fa..17dc114ea 100644 --- a/.github/checkrun.py +++ b/.github/checkrun.py @@ -13,5 +13,4 @@ if "\n\n" in message: else: print("Silence not found") else: - print("Empty Description") - + print("Empty Description") \ No newline at end of file diff --git a/.github/pkg.py b/.github/pkg.py index b52625542..f40440d9d 100644 --- a/.github/pkg.py +++ b/.github/pkg.py @@ -1,29 +1,24 @@ import os +from json import load +data = load(open('commit.json')) while True: - os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output app-x86-debug.apk") - outputStr = open("app-x86-debug.apk","r").read() - if "Not Found" not in outputStr: - print("Build [x86] Downloaded") + os.system('curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/sign.txt --output sign.txt') + f = open('sign.txt') + if f == data['sha'][0:7]: break -while True: - os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86_64-debug.apk --output app-x86_64-debug.apk") - outputStr = open("app-x86_64-debug.apk","r").read() - if "Not Found" not in outputStr: - print("Build [x86_64] Downloaded") - break +os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output app-x86-debug.apk") +print("Build [x86] Downloaded") -while True: - os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v7a-debug.apk --output app-armeabi-v7a-debug.apk") - outputStr = open("app-armeabi-v7a-debug.apk","r").read() - if "Not Found" not in outputStr: - print("Build [arm7] Downloaded") - break +os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86_64-debug.apk --output app-x86_64-debug.apk") +print("Build [x86_64] Downloaded") -while True: - os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v8a-debug.apk --output app-armeabi-v8a-debug.apk") - outputStr = open("app-armeabi-v8a-debug.apk","r").read() - if "Not Found" not in outputStr: - print("Build [arm8] Downloaded") - break \ No newline at end of file +os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v7a-debug.apk --output app-armeabi-v7a-debug.apk") +print("Build [arm7] Downloaded") + +os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v8a-debug.apk --output app-armeabi-v8a-debug.apk") +print("Build [arm8] Downloaded") + +os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-universal-debug.apk --output app-armeabi-v8a-debug.apk") +print("Build [universal] Downloaded") \ No newline at end of file diff --git a/.github/sign.py b/.github/sign.py new file mode 100644 index 000000000..9f5d8d311 --- /dev/null +++ b/.github/sign.py @@ -0,0 +1,4 @@ +from json import load + +f = open('sign.txt', "w") +f.write(data['sha'][0:7]) \ No newline at end of file diff --git a/.github/tg.py b/.github/tg.py index dc68d1166..e6dae39d4 100644 --- a/.github/tg.py +++ b/.github/tg.py @@ -6,7 +6,7 @@ from os import system from time import sleep as wait def deploy(): - system(f'~/bot-api --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') + system(f'./bot-api --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') def bot(): wait(10) @@ -21,7 +21,7 @@ def bot(): Signed-off-by: {data['commit']['author']['name']} ''', parse_mode=telegram.ParseMode.MARKDOWN) - bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) + bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-universal-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) system('killall -9 python') if __name__ == '__main__': diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9d2d4f35..ae6cb5374 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,10 @@ jobs: - name: Check for Execution Orders run: | cd .github + touch sign.txt curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json python checkrun.py + python sign.py cd .. - name: Set up JDK 11 @@ -53,8 +55,9 @@ jobs: - name: Upload to Archive run: | git clone https://github.com/LibreTubeAlpha/Archive archive - rm -rf archive/*.apk + rm -rf archive/*.apk archive/sign.txt mv app/build/outputs/apk/debug/*.apk archive/ + mv .github/sign.txt archive/ cd archive git add -f * git commit -m "WORKFLOW: ALPHA BUILDS" diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml index 1aefcc42f..ce73ad213 100644 --- a/.github/workflows/tg-bot.yml +++ b/.github/workflows/tg-bot.yml @@ -22,22 +22,24 @@ jobs: - name: Check for Execution Orders run: | cd .github + mv checkrun.py ~ + cd ~ curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json python checkrun.py cd .. - name: Download packages run: | - cd ~ - mv .github/pkg.py . + cd .github python pkg.py + cd .. - name: Telegram Bot continue-on-error: true run: | - cd ~ + cd .github curl https://libre-tube.github.io/images/LibreAlpha.png --output alpha.png - curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/exec --output ~/bot-api + curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/exec --output bot-api chmod 755 ./bot-api echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" > tgconfig.py echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py From 0f02b7cd9fc375cfcf48d7009f7b3fe1bc87d97d Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 10:48:30 +0530 Subject: [PATCH 05/14] Fix paths --- .github/workflows/tg-bot.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml index ce73ad213..d5da55b15 100644 --- a/.github/workflows/tg-bot.yml +++ b/.github/workflows/tg-bot.yml @@ -22,8 +22,6 @@ jobs: - name: Check for Execution Orders run: | cd .github - mv checkrun.py ~ - cd ~ curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json python checkrun.py cd .. From 725389bce46adfd76d8c02491c1bff72e5af51f1 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 10:50:28 +0530 Subject: [PATCH 06/14] Load commit.json in signer --- .github/sign.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/sign.py b/.github/sign.py index 9f5d8d311..b8fadf61d 100644 --- a/.github/sign.py +++ b/.github/sign.py @@ -1,4 +1,5 @@ from json import load +data = load(open(commit.json)) f = open('sign.txt', "w") f.write(data['sha'][0:7]) \ No newline at end of file From a1fa3cafea9f3adb4e7ae25564c918044e94d4e0 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 10:51:39 +0530 Subject: [PATCH 07/14] Fix syntax --- .github/sign.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/sign.py b/.github/sign.py index b8fadf61d..47cb0d5a6 100644 --- a/.github/sign.py +++ b/.github/sign.py @@ -1,5 +1,5 @@ from json import load -data = load(open(commit.json)) +data = load(open("commit.json")) f = open('sign.txt', "w") f.write(data['sha'][0:7]) \ No newline at end of file From a843e7770d8d7e410fd1a3c3e9bc4aa4dc9f98b2 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 11:18:22 +0530 Subject: [PATCH 08/14] Rearrange Upload Pattern --- .github/tg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/tg.py b/.github/tg.py index e6dae39d4..5c6f7c409 100644 --- a/.github/tg.py +++ b/.github/tg.py @@ -21,7 +21,7 @@ def bot(): Signed-off-by: {data['commit']['author']['name']} ''', parse_mode=telegram.ParseMode.MARKDOWN) - bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-universal-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) + bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-universal-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) system('killall -9 python') if __name__ == '__main__': From 09f27aaebfa90967a12c391438c2f11ffe7ca3a6 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 11:20:46 +0530 Subject: [PATCH 09/14] print sha --- .github/pkg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/pkg.py b/.github/pkg.py index f40440d9d..419d2c0ae 100644 --- a/.github/pkg.py +++ b/.github/pkg.py @@ -5,6 +5,8 @@ data = load(open('commit.json')) while True: os.system('curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/sign.txt --output sign.txt') f = open('sign.txt') + print(f) + print(data['sha'][0:7]) if f == data['sha'][0:7]: break From 214c2235cced98fe6c483b1ad62ec2aa7bf6fb06 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 11:23:26 +0530 Subject: [PATCH 10/14] Add Sleep to collector --- .github/pkg.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/pkg.py b/.github/pkg.py index 419d2c0ae..930a04aec 100644 --- a/.github/pkg.py +++ b/.github/pkg.py @@ -1,5 +1,6 @@ import os from json import load +import time data = load(open('commit.json')) while True: @@ -9,6 +10,8 @@ while True: print(data['sha'][0:7]) if f == data['sha'][0:7]: break + else: + time.sleep(10) os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output app-x86-debug.apk") print("Build [x86] Downloaded") From 99d2fc0a36ccc744c3fc1edb1518701d614b36cb Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 14:28:54 +0530 Subject: [PATCH 11/14] Centralise Builders --- .github/checkrun.py | 2 +- .github/pkg.py | 29 ---------------------- .github/sign.py | 5 ---- .github/workflows/ci.yml | 26 +++++++++++++++---- .github/workflows/tg-bot.yml | 48 ------------------------------------ 5 files changed, 22 insertions(+), 88 deletions(-) delete mode 100644 .github/pkg.py delete mode 100644 .github/sign.py delete mode 100644 .github/workflows/tg-bot.yml diff --git a/.github/checkrun.py b/.github/checkrun.py index 17dc114ea..043cd0441 100644 --- a/.github/checkrun.py +++ b/.github/checkrun.py @@ -5,7 +5,7 @@ f = open('commit.json') data = load(f) f.close() -message = data['commit']['message'] +data = data['commit']['message'] if "\n\n" in message: if message.split("\n\n",1)[-1].split()[0] == "[SILENT]": diff --git a/.github/pkg.py b/.github/pkg.py deleted file mode 100644 index 930a04aec..000000000 --- a/.github/pkg.py +++ /dev/null @@ -1,29 +0,0 @@ -import os -from json import load -import time - -data = load(open('commit.json')) -while True: - os.system('curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/sign.txt --output sign.txt') - f = open('sign.txt') - print(f) - print(data['sha'][0:7]) - if f == data['sha'][0:7]: - break - else: - time.sleep(10) - -os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86-debug.apk --output app-x86-debug.apk") -print("Build [x86] Downloaded") - -os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-x86_64-debug.apk --output app-x86_64-debug.apk") -print("Build [x86_64] Downloaded") - -os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v7a-debug.apk --output app-armeabi-v7a-debug.apk") -print("Build [arm7] Downloaded") - -os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-armeabi-v8a-debug.apk --output app-armeabi-v8a-debug.apk") -print("Build [arm8] Downloaded") - -os.system("curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/latestBuild/app-universal-debug.apk --output app-armeabi-v8a-debug.apk") -print("Build [universal] Downloaded") \ No newline at end of file diff --git a/.github/sign.py b/.github/sign.py deleted file mode 100644 index 47cb0d5a6..000000000 --- a/.github/sign.py +++ /dev/null @@ -1,5 +0,0 @@ -from json import load - -data = load(open("commit.json")) -f = open('sign.txt', "w") -f.write(data['sha'][0:7]) \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae6cb5374..3a6cdd93b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,14 +21,16 @@ jobs: steps: - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 + - uses: actions/setup-python@v3 + with: + 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 run: | cd .github - touch sign.txt curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json python checkrun.py - python sign.py cd .. - name: Set up JDK 11 @@ -53,16 +55,30 @@ jobs: ./gradlew assembleDebug - name: Upload to Archive + continue-on-error: true run: | git clone https://github.com/LibreTubeAlpha/Archive archive - rm -rf archive/*.apk archive/sign.txt + rm -rf archive/*.apk mv app/build/outputs/apk/debug/*.apk archive/ - mv .github/sign.txt archive/ cd archive git add -f * git commit -m "WORKFLOW: ALPHA BUILDS" git push -u - cd .. + + - name: Telegram Bot + continue-on-error: true + run: | + cd archive + curl https://libre-tube.github.io/images/LibreAlpha.png --output alpha.png + curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/exec --output bot-api + chmod 755 ./bot-api + echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" > tgconfig.py + echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py + echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py + echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py + python -m pip install --upgrade pip + pip install python-telegram-bot + python tg.py - name: Upload APK uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml deleted file mode 100644 index d5da55b15..000000000 --- a/.github/workflows/tg-bot.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Telegram Bot - -on: - workflow_dispatch: - push: - paths-ignore: - - "README*.md" - - "fastlane/**" - - "assets/**" - - ".github/**/*.md" - -jobs: - debug-builds: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - with: - 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 - run: | - cd .github - curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json - python checkrun.py - cd .. - - - name: Download packages - run: | - cd .github - python pkg.py - cd .. - - - name: Telegram Bot - continue-on-error: true - run: | - cd .github - curl https://libre-tube.github.io/images/LibreAlpha.png --output alpha.png - curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/exec --output bot-api - chmod 755 ./bot-api - echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" > tgconfig.py - echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py - echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py - echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py - python -m pip install --upgrade pip - pip install python-telegram-bot - python tg.py From 34822c172892b04b84ab3f5d1661915aaeed3aab Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 14:32:02 +0530 Subject: [PATCH 12/14] Fix variable name --- .github/checkrun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/checkrun.py b/.github/checkrun.py index 043cd0441..c8c0f1a2e 100644 --- a/.github/checkrun.py +++ b/.github/checkrun.py @@ -7,8 +7,8 @@ f.close() data = data['commit']['message'] -if "\n\n" in message: - if message.split("\n\n",1)[-1].split()[0] == "[SILENT]": +if "\n\n" in data: + if data.split("\n\n",1)[-1].split()[0] == "[SILENT]": system('killall -9 python') else: print("Silence not found") From 8db8eff1c12981fa28390a405449971d31870b78 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 14:39:12 +0530 Subject: [PATCH 13/14] Fix Bot Executor Path --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a6cdd93b..0cde77a41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,7 @@ jobs: echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py python -m pip install --upgrade pip pip install python-telegram-bot + mv ../.github/tg.py . python tg.py - name: Upload APK From d2e08c5f6d81aa69f1a10802c0e070dd515d9201 Mon Sep 17 00:00:00 2001 From: XelXen <78258352+XelXen@users.noreply.github.com> Date: Sun, 18 Sep 2022 14:44:12 +0530 Subject: [PATCH 14/14] Fix commit info Path --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cde77a41..3c6a667b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,6 +79,7 @@ jobs: python -m pip install --upgrade pip pip install python-telegram-bot mv ../.github/tg.py . + mv ../.github/commit.json . python tg.py - name: Upload APK