From b9dd673518c4fdefbf2f2f73c6d7e0bf4bdba39b Mon Sep 17 00:00:00 2001 From: Ylarod Date: Mon, 16 Jan 2023 18:15:35 +0800 Subject: [PATCH] ci: add version to tg msg (#75) --- .github/workflows/build-kernel-5.10.yml | 1 + .github/workflows/build-kernel-5.15.yml | 1 + .github/workflows/build-manager.yml | 1 + .github/workflows/build-su.yml | 1 + scripts/ksubot.py | 6 ++++++ 5 files changed, 10 insertions(+) diff --git a/.github/workflows/build-kernel-5.10.yml b/.github/workflows/build-kernel-5.10.yml index e63b64f7..98706b68 100644 --- a/.github/workflows/build-kernel-5.10.yml +++ b/.github/workflows/build-kernel-5.10.yml @@ -139,6 +139,7 @@ jobs: TITLE: kernel-aarch64-${{ matrix.version }} run: | if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + export VERSION=$(git describe --tags --always) OUTDIR=android-kernel/out/android12-5.10/dist IMAGE_GZ=${{ matrix.version }}-Image.gz BOOT=${{ matrix.version }}-boot.img.zip diff --git a/.github/workflows/build-kernel-5.15.yml b/.github/workflows/build-kernel-5.15.yml index a59da464..814cb503 100644 --- a/.github/workflows/build-kernel-5.15.yml +++ b/.github/workflows/build-kernel-5.15.yml @@ -96,6 +96,7 @@ jobs: TITLE: kernel-aarch64-${{ matrix.version }} run: | if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + export VERSION=$(git describe --tags --always) OUTDIR=android-kernel/out/android13-5.15/dist BOOT=${{ matrix.version }}-boot.img.zip zip $BOOT -j -r $OUTDIR/boot.img diff --git a/.github/workflows/build-manager.yml b/.github/workflows/build-manager.yml index 4a9761fe..e7c5e94c 100644 --- a/.github/workflows/build-manager.yml +++ b/.github/workflows/build-manager.yml @@ -84,6 +84,7 @@ jobs: TITLE: Manager run: | if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + export VERSION=$(git describe --tags --always) APK=$(find ./app/build/outputs/apk/release -name "*.apk") pip3 install python-telegram-bot python3 $GITHUB_WORKSPACE/scripts/ksubot.py $APK diff --git a/.github/workflows/build-su.yml b/.github/workflows/build-su.yml index f2ae6cf5..68e1e3d9 100644 --- a/.github/workflows/build-su.yml +++ b/.github/workflows/build-su.yml @@ -44,6 +44,7 @@ jobs: TITLE: SU run: | if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + export VERSION=$(git describe --tags --always) pip3 install python-telegram-bot mv ./userspace/su/libs/arm64-v8a/su su-arm64 mv ./userspace/su/libs/x86_64/su su-x86_64 diff --git a/scripts/ksubot.py b/scripts/ksubot.py index 099ff73a..90fbe8ce 100644 --- a/scripts/ksubot.py +++ b/scripts/ksubot.py @@ -13,8 +13,10 @@ COMMIT_URL = os.environ.get("COMMIT_URL") COMMIT_MESSAGE = os.environ.get("COMMIT_MESSAGE") RUN_URL = os.environ.get("RUN_URL") TITLE = os.environ.get("TITLE") +VERSION = os.environ.get("VERSION") MSG_TEMPLATE = """ *{title}* +_{version}_ ``` {commit_message} ``` @@ -26,6 +28,7 @@ MSG_TEMPLATE = """ def get_caption(): msg = MSG_TEMPLATE.format( title=helpers.escape_markdown(TITLE, 2), + version=helpers.escape_markdown(VERSION, 2), commit_message=helpers.escape_markdown(COMMIT_MESSAGE, 2, telegram.MessageEntity.PRE), commit_url=helpers.escape_markdown(COMMIT_URL, 2, telegram.MessageEntity.TEXT_LINK), run_url=helpers.escape_markdown(RUN_URL, 2, telegram.MessageEntity.TEXT_LINK) @@ -57,6 +60,9 @@ def check_environ(): if TITLE is None: print("[-] Invalid TITLE") exit(1) + if VERSION is None: + print("[-] Invalid VERSION") + exit(1) async def main():