forked from LawnchairLauncher/lawnicons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import asyncio | ||
import os | ||
import sys | ||
from telethon import TelegramClient | ||
from telethon.tl.functions.help import GetConfigRequest | ||
|
||
API_ID = os.environ.get("API_ID") | ||
API_HASH = os.environ.get("API_HASH") | ||
|
||
CHAT_ID = int(os.environ.get("CHAT_ID")) | ||
MESSAGE_THREAD_ID = int(os.environ.get("MESSAGE_THREAD_ID")) | ||
BOT_TOKEN = os.environ.get("BOT_TOKEN") | ||
VERSION = os.environ.get("VERSION") | ||
COMMIT = os.environ.get("COMMIT") | ||
MSG_TEMPLATE = """ | ||
{version} | ||
Commit: | ||
{commit} | ||
[source fork](https://github.com/LawnchairLauncher/lawnicons) | ||
#Android #apk #icon #pack | ||
""".strip() | ||
|
||
def get_caption(): | ||
msg = MSG_TEMPLATE.format( | ||
version=VERSION, | ||
commit=COMMIT | ||
) | ||
if len(msg) > 1024: | ||
return COMMIT | ||
return msg | ||
|
||
def check_environ(): | ||
if BOT_TOKEN is None: | ||
print("[-] Invalid BOT_TOKEN") | ||
exit(1) | ||
if CHAT_ID is None: | ||
print("[-] Invalid CHAT_ID") | ||
exit(1) | ||
if MESSAGE_THREAD_ID is None: | ||
print("[-] Invalid MESSAGE_THREAD_ID") | ||
exit(1) | ||
if VERSION is None: | ||
print("[-] Invalid VERSION") | ||
exit(1) | ||
if COMMIT is None: | ||
print("[-] Invalid COMMIT") | ||
exit(1) | ||
|
||
async def main(): | ||
print("[+] Uploading to telegram") | ||
check_environ() | ||
files = sys.argv[1:] | ||
print("[+] Files:", files) | ||
if len(files) <= 0: | ||
print("[-] No files to upload") | ||
exit(1) | ||
print("[+] Logging in Telegram with bot") | ||
script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) | ||
session_dir = os.path.join(script_dir, "bot.session") | ||
async with await TelegramClient(session=session_dir, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot: | ||
caption = [""] * len(files) | ||
caption[-1] = get_caption() | ||
print("[+] Caption: ") | ||
print("---") | ||
print(caption) | ||
print("---") | ||
print("[+] Sending") | ||
sent_messages = await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown") | ||
|
||
# Pin the last sent message | ||
if sent_messages: | ||
last_message_id = sent_messages[-1].id | ||
await bot.pin_message(entity=CHAT_ID, message=last_message_id) | ||
|
||
print("[+] Done!") | ||
|
||
if __name__ == "__main__": | ||
try: | ||
asyncio.run(main()) | ||
except Exception as e: | ||
print(f"[-] An error occurred: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Build APK | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
build-release-apk: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
|
||
- uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-home-cache-cleanup: true | ||
|
||
- name: write sign info | ||
run: | | ||
if [ ! -z "${{ secrets.KEYSTORE_CONTENT }}" ]; then | ||
echo storePassword='${{ secrets.KEYSTORE_PASSWORD }}' >> keystore.properties | ||
echo keyAlias='${{ secrets.KEY_ALIAS }}' >> keystore.properties | ||
echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> keystore.properties | ||
echo storeFile='${{ github.workspace }}/key.jks' >> keystore.properties | ||
echo ${{ secrets.KEYSTORE_CONTENT }} | base64 --decode > key.jks | ||
fi | ||
- name: prepare prebuild | ||
run: | | ||
chmod +x gradlew | ||
./gradlew svg-processor:run | ||
- name: build with gradle | ||
run: | | ||
./gradlew app:assembleRelease | ||
- name: checking release version | ||
id: version | ||
run: | | ||
echo ::set-output name=release_version::$(cat app/build.gradle.kts | grep -o "versionName = \"[0-9.]*\"" | grep -o "[0-9.]*") | ||
echo ::set-output name=release_patch::$(git rev-parse --short HEAD) | ||
- name: rename apks | ||
run: | | ||
APK="lawn_icons_v${{ steps.version.outputs.release_version }}_${{ steps.version.outputs.release_patch }}.apk" | ||
mv -f app/build/outputs/apk/app/release/*.apk app/build/outputs/apk/app/release/$APK | ||
- name: upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Release apk | ||
path: app/build/outputs/apk/app/release/*.apk | ||
|
||
- uses: andreaswilli/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: Prerelease | ||
deleteOnlyFromDrafts: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: richardsimko/[email protected] | ||
with: | ||
tag_name: Prerelease | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: Prerelease | ||
files: app/build/outputs/apk/app/release/*.apk | ||
draft: false | ||
prerelease: true | ||
generate_release_notes: true | ||
|
||
# - name: upload to telegram | ||
# if: ${{ success() }} | ||
# env: | ||
# CHAT_ID: "-1001597117128" | ||
# MESSAGE_THREAD_ID: "282263" | ||
# API_HASH: ${{ secrets.API_HASH }} | ||
# API_ID: ${{ secrets.API_ID }} | ||
# BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
# run: | | ||
# if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then | ||
# export VERSION="lawn_icons_v${{ steps.version.outputs.release_version }}_${{ steps.version.outputs.release_patch }}" | ||
# export COMMIT=$(git log --oneline -n 10 --no-decorate | sed 's/^[0-9a-f]* //' | sed 's/^/— /') | ||
# FILE=$(find ./app/build/outputs/apk/app/release -name "*.apk") | ||
# pip3 install telethon==1.31.1 | ||
# python3 $GITHUB_WORKSPACE/.github/taamarinbot.py $FILE | ||
# fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.