Configure Preferential network service #61
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
name: Build APK | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
tags-ignore: | |
- '**' | |
branches-ignore: | |
- 'master' | |
jobs: | |
build: | |
name: Build CI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: '21' | |
- name: Get short commit SHA | |
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
- name: Build APK (testkey) | |
run: ./gradlew build | |
- name: Upload Debug APK (testkey) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OwnDroid-CI-${{ env.SHORT_SHA }}-debug-testkey | |
path: app/build/outputs/apk/debug/app-debug.apk | |
- name: Upload Release APK (testkey) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OwnDroid-CI-${{ env.SHORT_SHA }}-release-testkey | |
path: app/build/outputs/apk/release/app-release.apk | |
- name: Build APK | |
run: | | |
echo "${{ secrets.KEY_BASE64 }}" | base64 --decode - > app/release.jks | |
./gradlew build -PStoreFile="$(pwd)/app/release.jks" -PStorePassword="${{ secrets.KEYSTORE_PASSWORD }}" -PKeyPassword="${{ secrets.KEY_PASSWORD }}" -PKeyAlias="${{ secrets.KEY_ALIAS }}" | |
- name: Upload Debug APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OwnDroid-CI-${{ env.SHORT_SHA }}-debug-signed | |
path: app/build/outputs/apk/debug/app-debug.apk | |
- name: Upload Release APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OwnDroid-CI-${{ env.SHORT_SHA }}-release-signed | |
path: app/build/outputs/apk/release/app-release.apk | |
upload-telegram: | |
name: Upload Builds | |
if: ${{ success() }} | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Download telegram-bot-api | |
run: | | |
mkdir ./binaries | |
wget "https://github.com/jakbin/telegram-bot-api-binary/releases/download/latest/telegram-bot-api" -O ./binaries/telegram-bot-api | |
chmod +x ./binaries/telegram-bot-api | |
- name: Start API Server & Upload | |
env: | |
COMMIT_MESSAGE: |+ | |
<blockquote>${{ github.event.head_commit.message }}</blockquote> | |
<a href="${{ github.event.head_commit.url }}">See commit details here</a> | |
COMMIT_URL: ${{ github.event.head_commit.url }} | |
run: | | |
ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'` | |
cd artifacts | |
export RELEASE_TEST_PWD=$(find . -name "*release-testkey*") | |
mv ./$RELEASE_TEST_PWD/app-release.apk ./$RELEASE_TEST_PWD.apk && rm -rf ./$RELEASE_TEST_PWD | |
export RELEASE_SIGNED_PWD=$(find . -name "*release-signed*") | |
mv ./$RELEASE_SIGNED_PWD/app-release.apk ./$RELEASE_SIGNED_PWD.apk && rm -rf ./$RELEASE_SIGNED_PWD | |
../binaries/telegram-bot-api --api-id=${{ secrets.TELEGRAM_API_APP_ID }} --api-hash=${{ secrets.TELEGRAM_API_HASH }} --local 2>&1 > /dev/null & | |
export token=${{ secrets.TELEGRAM_BOT_KEY }} | |
curl -v "http://127.0.0.1:8081/bot$token/sendMediaGroup?chat_id=-1002216379163&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseSigned%22%2C%22parse_mode%22%3A%22HTML%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \ | |
-F releaseTest="@$RELEASE_TEST_PWD.apk" \ | |
-F releaseSigned="@$RELEASE_SIGNED_PWD.apk" |