diff --git a/.github/workflows/build_debug_apk.yml b/.github/workflows/build_debug_apk.yml index d27f6d6703..c05dab2036 100644 --- a/.github/workflows/build_debug_apk.yml +++ b/.github/workflows/build_debug_apk.yml @@ -78,11 +78,12 @@ jobs: name: Debug APK path: artifacts/debug-apk - name: Send notifications - run: python send_notifications.py + run: python ci.py env: GITHUB_EVENT_BEFORE: ${{ github.event.before }} - TELEGRAM_CI_BOT_TOKEN: ${{ secrets.TELEGRAM_CI_BOT_TOKEN }} + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_CI_BOT_TOKEN }} TELEGRAM_CI_CHANNEL_ID: ${{ secrets.TELEGRAM_CI_CHANNEL_ID }} TELEGRAM_TEAM_GROUP_ID: ${{ secrets.NOTIFY_CHANNEL_ID }} ARTIFACT_DIRECTORY: artifacts/debug-apk GITHUB_REF: ${{ github.ref }} + ACTION: internal_notifications diff --git a/.github/workflows/build_release_apk.yml b/.github/workflows/build_release_apk.yml index 962f474558..a4f9eb5fd6 100644 --- a/.github/workflows/build_release_apk.yml +++ b/.github/workflows/build_release_apk.yml @@ -75,11 +75,12 @@ jobs: name: Release APK path: artifacts/release-apk - name: Send notifications - run: python send_notifications.py + run: python ci.py env: GITHUB_EVENT_BEFORE: ${{ github.event.before }} - TELEGRAM_CI_BOT_TOKEN: ${{ secrets.TELEGRAM_CI_BOT_TOKEN }} + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_CI_BOT_TOKEN }} TELEGRAM_CI_CHANNEL_ID: ${{ secrets.TELEGRAM_CI_CHANNEL_ID }} TELEGRAM_TEAM_GROUP_ID: ${{ secrets.NOTIFY_CHANNEL_ID }} ARTIFACT_DIRECTORY: artifacts/release-apk - GITHUB_REF: ${{ github.ref }} \ No newline at end of file + GITHUB_REF: ${{ github.ref }} + ACTION: internal_notifications diff --git a/.github/workflows/release_update.yml b/.github/workflows/release_update.yml new file mode 100644 index 0000000000..331fea304a --- /dev/null +++ b/.github/workflows/release_update.yml @@ -0,0 +1,100 @@ +name: Release update +on: + workflow_dispatch: + inputs: + artifactName: + description: Artifact name + type: string + required: true + tagName: + description: Tag name + type: string + required: true + prerelease: + description: Prerelease + type: boolean + required: true +jobs: + build-release-apk: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2.3.4 + with: + submodules: true + - name: Restore Gradle cache + uses: actions/cache@v2.1.4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- + - name: Set up Java 11 + uses: actions/setup-java@v1.4.3 + with: + java-version: 11 + - name: Grant execution permission to Gradle Wrapper + run: chmod +x gradlew + - name: Build release APK + run: ./gradlew assembleLawnWithQuickstepRelease + - name: Sign release APK + uses: r0adkll/sign-android-release@v1 + id: sign-release-apk + with: + releaseDirectory: build/outputs/apk/lawnWithQuickstep/release + signingKeyBase64: ${{ secrets.KEYSTORE }} + alias: ${{ secrets.KEY_ALIAS }} + keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }} + keyPassword: ${{ secrets.KEY_PASSWORD }} + - name: Rename artifact + continue-on-error: true + run: mv "${{ steps.sign-release-apk.outputs.signedReleaseFile }}" "${{ github.event.inputs.artifactName }}" + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: Release APK + path: ${{ github.event.inputs.artifactName }} + publish-github-release: + runs-on: ubuntu-latest + needs: build-release-apk + permissions: + contents: write + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: Release APK + path: artifacts/release-apk + - name: Publish GitHub release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.inputs.tagName }} + prerelease: ${{ github.events.inputs.prerelease }} + draft: true + body_path: ${{ github.workspace }}/GITHUB_CHANGELOG.md + files: artifacts/release-apk${{ github.event.inputs.artifactName }} + publish-telegram-update-post: + runs-on: ubuntu-latest + needs: build-release-apk + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: Release APK + path: artifacts/release-apk + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: Install Python packages + run: | + python -m pip install --upgrade pip + pip install requests + - name: Publish Telegram update post + run: python publish_telegram_update_post.py + env: + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_CI_BOT_TOKEN }} + ARTIFACT_DIRECTORY: artifacts/release-apk + TELEGRAM_NEWS_CHANNEL_ID: ${{ secrets.TELEGRAM_NEWS_CHANNEL_ID }} + ACTION: update_announcement diff --git a/GITHUB_CHANGELOG.md b/GITHUB_CHANGELOG.md new file mode 100644 index 0000000000..b7f3db86fa --- /dev/null +++ b/GITHUB_CHANGELOG.md @@ -0,0 +1,11 @@ +Lawnchair 12.1 is here! This release is based on Launcher3 from Android 12.1 and works with +QuickSwitch on Android 12.1. In addition, it includes the following new features: + +- a new At a Glance widget +- the ability to change the search provider for the Dock search bar (thanks to @evowizz) +- multiple new shapes for Adaptive Icons (thanks to @yasandev and @DariaHamrahPaytakht) +- an option to display the notification count in Notification Dots (thanks to @yasandev and @DariaHamrahPaytakht) +- the ability to add custom fonts +- if Lawnchair is connected to QuickSwitch, an option to make the Recents background translucent + +Also included in this version are bug fixes and other improvements. Thanks go to @arter97, @npv12, @erfanoabdi, and @SuperDragonXD for their contributions. diff --git a/TELEGRAM_CHANGELOG.txt b/TELEGRAM_CHANGELOG.txt new file mode 100644 index 0000000000..4cb8ce1b98 --- /dev/null +++ b/TELEGRAM_CHANGELOG.txt @@ -0,0 +1,11 @@ +Lawnchair 12.1 is here! This release is based on Launcher3 from Android 12.1 and works with +QuickSwitch on Android 12.1. In addition, it includes the following new features: + +• a new At a Glance widget +• the ability to change the search provider for the Dock search bar (thanks to Dylan Roussel) +• multiple new shapes for Adaptive Icons (thanks to @yasandev and Daria Hamrah Paytakht) +• an option to display the notification count in Notification Dots (thanks to @yasandev and Daria Hamrah Paytakht) +• the ability to add custom fonts +• if Lawnchair is connected to QuickSwitch, an option to make the Recents background translucent + +Also included in this version are bug fixes and other improvements. Thanks go to Juhyung Park, Pranav Santhosh, Erfan Abdi, and @SuperDragonXD for their contributions. diff --git a/ci.py b/ci.py new file mode 100644 index 0000000000..b0e4ea797e --- /dev/null +++ b/ci.py @@ -0,0 +1,73 @@ +import git +import html +import os +import requests +import re + +github_event_before = os.getenv("GITHUB_EVENT_BEFORE") +github_sha = os.getenv("GITHUB_SHA") +github_repository = os.getenv("GITHUB_REPOSITORY") +github_ref = os.getenv("GITHUB_REF") + +telegram_bot_token = os.getenv("TELEGRAM_BOT_TOKEN") +telegram_ci_channel_id = os.getenv("TELEGRAM_CI_CHANNEL_ID") +telegram_team_group_id = os.getenv("TELEGRAM_TEAM_GROUP_ID") +telegram_news_channel_id = os.getenv("TELEGRAM_NEWS_CHANNEL_ID") + +artifact_directory = os.getenv("ARTIFACT_DIRECTORY") +action = os.getenv("ACTION") + +def send_message_to_telegram_chat(chat_id, message, silent): + requests.post( + url = f"https://api.telegram.org/bot{telegram_bot_token}/sendMessage", + data = { + "chat_id": chat_id, + "parse_mode": "HTML", + "text": message, + "disable_web_page_preview": "true", + "disable_notification": str(silent) + } + ) + +def send_document_to_telegram_chat(chat_id, document): + requests.post( + url = f"https://api.telegram.org/bot{telegram_bot_token}/sendDocument", + data = { "chat_id": chat_id }, + files = { "document": document } + ) + +def send_artifact_to_telegram_chat(chat_id): + with open(f"{artifact_directory}/{os.listdir(artifact_directory)[0]}", "rb") as artifact: + send_document_to_telegram_chat(chat_id=chat_id, document=artifact) + +def send_internal_notifications(): + repository = git.Repo(".") + commit_range = f"{github_event_before}...{github_sha}" + commits = list(repository.iter_commits(commit_range)) + + overview_link = f"https://github.com/{github_repository}/compare/{commit_range}" + overview_link_tag = f"""{len(commits)} new commit{"s" if len(commits) > 1 else ""}""" + message = f"""🔨 {overview_link_tag} to lawnchair:{github_ref}:\n""" + + for commit in reversed(commits): + commit_message = commit.message.split("\n")[0] + commit_link = f"https://github.com/{github_repository}/commit/{commit.hexsha}" + commit_link_tag = f"""{repository.git.rev_parse(commit.hexsha, short=7)}""" + encoded_message = html.escape(commit_message) + message += f"\n• {commit_link_tag}: {encoded_message}" + + send_message_to_telegram_chat(chat_id=telegram_ci_channel_id, message=message, silent=False) + send_message_to_telegram_chat(chat_id=telegram_team_group_id, message=message, silent=True) + send_artifact_to_telegram_chat(chat_id=telegram_ci_channel_id) + +def send_update_announcement(): + send_artifact_to_telegram_chat(chat_id=telegram_news_channel_id) + + with open("TELEGRAM_CHANGELOG.txt") as telegram_changelog: + send_message_to_telegram_chat(chat_id=telegram_news_channel_id, message=telegram_changelog.read(), silent=False) + +match action: + case "internal_notifications": + send_internal_notifications() + case "update_announcement": + send_update_announcement() diff --git a/send_notifications.py b/send_notifications.py deleted file mode 100644 index 12cea12e81..0000000000 --- a/send_notifications.py +++ /dev/null @@ -1,72 +0,0 @@ -import git -import html -import os -import requests - -github_event_before = os.getenv('GITHUB_EVENT_BEFORE') -github_sha = os.getenv('GITHUB_SHA') -github_repository = os.getenv('GITHUB_REPOSITORY') -github_ref = os.getenv('GITHUB_REF') -telegram_ci_bot_token = os.getenv('TELEGRAM_CI_BOT_TOKEN') -telegram_ci_channel_id = os.getenv('TELEGRAM_CI_CHANNEL_ID') -telegram_team_group_id = os.getenv('TELEGRAM_TEAM_GROUP_ID') -artifact_directory = os.getenv('ARTIFACT_DIRECTORY') - -def send_message_to_ci_channel(message): - data = { - 'chat_id': telegram_ci_channel_id, - 'parse_mode': 'HTML', - 'text': message, - 'disable_web_page_preview': 'true' - } - requests.post( - url = f'https://api.telegram.org/bot{telegram_ci_bot_token}/sendMessage', - data = data - ) - -def send_document_to_ci_channel(document): - data = { - 'chat_id': telegram_ci_channel_id, - } - files = { - 'document': document - } - requests.post( - url = f'https://api.telegram.org/bot{telegram_ci_bot_token}/sendDocument', - data = data, - files = files - ) - -def send_silent_message_to_team_group(message): - data = { - 'chat_id': telegram_team_group_id, - 'parse_mode': 'HTML', - 'text': message, - 'disable_web_page_preview': 'true', - 'disable_notification': 'true' - } - requests.post( - url = f'https://api.telegram.org/bot{telegram_ci_bot_token}/sendMessage', - data = data - ) - -repository = git.Repo('.') -commits_range = f'{github_event_before}...{github_sha}' -commits = list(repository.iter_commits(commits_range)) - -overview_link = f'https://github.com/{github_repository}/compare/{commits_range}' -overview_link_tag = f'''{len(commits)} new commit{'s' if len(commits) > 1 else ''}''' -message = f'''🔨 {overview_link_tag} to lawnchair:{github_ref}:\n''' - -for commit in reversed(commits): - commit_message = commit.message.split('\n')[0] - commit_link = f'https://github.com/{github_repository}/commit/{commit.hexsha}' - commit_link_tag = f'{repository.git.rev_parse(commit.hexsha, short=7)}' - encoded_message = html.escape(commit_message) - message += f'\n• {commit_link_tag}: {encoded_message}' - -send_message_to_ci_channel(message=message) -send_silent_message_to_team_group(message=message) - -with open(f'{artifact_directory}/{os.listdir(artifact_directory)[0]}', 'rb') as apk: - send_document_to_ci_channel(document=apk) \ No newline at end of file