chore: build infra change #217
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: Debug build | |
on: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '*' | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
- '!.github/workflows/debug.yml' | |
pull_request: | |
branches: | |
- dev | |
workflow_dispatch: | |
inputs: | |
artifacts: | |
description: 'y, if drop artifacts' | |
required: false | |
publish: | |
description: 'y, if not release' | |
required: false | |
jobs: | |
jni: | |
name: Native Build (jni) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Fetch Status | |
run: | | |
git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status | |
git submodule status TMessagesProj/jni/libvpx > libvpx_status | |
git submodule status TMessagesProj/jni/boringssl > boringssl_status | |
- name: FFmpeg Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/jni/ffmpeg/build | |
TMessagesProj/jni/libvpx/build | |
key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} | |
- name: BoringSSL Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/jni/boringssl/build | |
key: ${{ hashFiles('boringssl_status') }} | |
- name: Setup Android SDK Tools | |
uses: android-actions/setup-android@v2 | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Install NDK | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null | |
echo "sdk.dir=${ANDROID_HOME}" > local.properties | |
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties | |
- name: Native Build | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
sudo apt-get install yasm -y | |
sudo apt-get install bison gcc make curl ninja-build -y | |
. buildenv.sh | |
cd TMessagesProj/jni | |
./build_libvpx_clang.sh | |
./build_ffmpeg_clang.sh | |
./patch_ffmpeg.sh | |
./patch_boringssl.sh | |
./build_boringssl.sh | |
native: | |
name: Native Build (Telegram) | |
runs-on: ubuntu-latest | |
needs: | |
- jni | |
strategy: | |
matrix: | |
flavor: | |
- armeabi-v7a | |
- arm64-v8a | |
- x86 | |
- x86_64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Fetch Status | |
run: | | |
git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status | |
git submodule status TMessagesProj/jni/libvpx > libvpx_status | |
git submodule status TMessagesProj/jni/boringssl > boringssl_status | |
- name: Native Cache | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/src/main/libs | |
key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-${{ matrix.flavor }} | |
- name: Checkout Library | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
git submodule update --init 'TMessagesProj/jni/*' | |
- name: FFmpeg Cache | |
uses: actions/cache@v3 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
path: | | |
TMessagesProj/jni/ffmpeg/build | |
TMessagesProj/jni/libvpx/build | |
key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} | |
fail-on-cache-miss: 'true' | |
- name: BoringSSL Cache | |
uses: actions/cache@v3 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
path: | | |
TMessagesProj/jni/boringssl/build | |
key: ${{ hashFiles('boringssl_status') }} | |
fail-on-cache-miss: 'true' | |
- name: Setup Android SDK Tools | |
uses: android-actions/setup-android@v2 | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Install NDK | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null | |
echo "sdk.dir=${ANDROID_HOME}" > local.properties | |
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties | |
- uses: actions/setup-java@v3 | |
name: Setup Java | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Native Build | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
echo "${{ secrets.B64_SIGNING_KEY }}" | base64 --decode - > TMessagesProj/luvletter2333.jks | |
echo "${{ secrets.KEYSTORE_PASS }}" > TMessagesProj/priv-signing.properties | |
sha256sum TMessagesProj/luvletter2333.jks | |
export NATIVE_TARGET="${{ matrix.flavor }}" | |
./run libs native | |
v2ray: | |
name: Native Build (V2ray) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Fetch Status | |
run: git submodule status v2ray > v2ray_status | |
- name: V2ray Cache | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/libs/libv2ray.aar | |
key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} | |
- name: Setup Android SDK Tools | |
uses: android-actions/setup-android@v2 | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Install NDK | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null | |
echo "sdk.dir=${ANDROID_HOME}" > local.properties | |
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties | |
- name: Install Golang | |
uses: actions/setup-go@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
go-version: 'stable' | |
- name: Native Build | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
. buildenv.sh | |
cd v2ray | |
make all | |
make downloadGoMobile | |
make BuildMobile | |
build: | |
name: Gradle Build | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'pull_request' && success() }} | |
needs: | |
- native | |
- v2ray | |
- telegram-bot-api | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Android SDK Tools | |
uses: android-actions/setup-android@v2 | |
- name: Install NDK | |
run: | | |
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null | |
echo "sdk.dir=${ANDROID_HOME}" > local.properties | |
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties | |
- name: Fetch Status | |
run: | | |
git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status | |
git submodule status TMessagesProj/jni/boringssl > boringssl_status | |
git submodule status v2ray > v2ray_status | |
- name: Native Cache (armeabi-v7a) | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/src/main/libs | |
key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-armeabi-v7a | |
- name: Native Cache (arm64-v8a) | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/src/main/libs | |
key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-arm64-v8a | |
- name: Native Cache (x86) | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/src/main/libs | |
key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86 | |
- name: Native Cache (x86_64) | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/src/main/libs | |
key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86_64 | |
- name: V2ray Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/libs/libv2ray.aar | |
key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} | |
- name: Build Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
TMessagesProj/build | |
TMessagesProj/.cxx | |
openpgp-api/build | |
key: build-cache | |
- name: Configure Gradle | |
run: | | |
sed -i -e "s/16384/6144/g" gradle.properties | |
echo "sdk.dir=${ANDROID_HOME}" >> local.properties | |
# echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" >> local.properties | |
- uses: actions/setup-java@v3 | |
name: Setup Java | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'gradle' | |
- name: Debug Build | |
run: | | |
echo "${{ secrets.B64_SIGNING_KEY }}" | base64 --decode - > TMessagesProj/luvletter2333.jks | |
echo "${{ secrets.KEYSTORE_PASS }}" > TMessagesProj/priv-signing.properties | |
sha256sum TMessagesProj/luvletter2333.jks | |
./gradlew TMessagesProj:assemble | |
- name: Upload artifacts | |
uses: actions/upload-artifact@master | |
if: github.event.inputs.upload != 'y' | |
with: | |
name: ${{ matrix.flavor }} | |
path: TMessagesProj/build/outputs/apk/ | |
publish: | |
name: Publish pre-Release | |
if: github.event.inputs.publish != 'y' | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
path: artifacts | |
- name: Release | |
run: | | |
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz | |
tar -xvf ghr.tar.gz | |
mv ghr*linux_amd64/ghr . | |
mkdir apks | |
find -name "*.apk" -exec cp {} apks \; | |
./ghr -delete -t "${{ github.token }}" \ | |
-b "${{ github.event_name }}" \ | |
-prerelease \ | |
"$(printf %.8s $GITHUB_SHA)" apks | |
upload: | |
name: Upload Release | |
if: github.event.inputs.artifacts != 'y' | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- telegram-bot-api | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
path: artifacts | |
- name: Download Telegram Bot API Binary | |
uses: actions/download-artifact@master | |
with: | |
name: telegram-bot-api-binary | |
path: . | |
- name: Release | |
run: | | |
chmod +x telegram-bot-api-binary | |
./telegram-bot-api-binary --api-id=21724 --api-hash=3e0cb5efcd52300aec5994fdfc5bdc16 --local 2>&1 > /dev/null & | |
curl http://127.0.0.1:8081/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage \ | |
-X POST \ | |
--form-string chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ | |
-F text="==== $GITHUB_SHA ====" \ | |
--silent --show-error --fail >/dev/null | |
for apk in $(find artifacts -name '*.apk' ) | |
do | |
curl http://127.0.0.1:8081/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \ | |
-X POST \ | |
-F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ | |
-F document="@$apk" \ | |
-F caption="${{ github.event.head_commit.message }} | |
$GITHUB_SHA" \ | |
--silent --show-error --fail >/dev/null | |
done | |
pkill telegram-bot | |
telegram-bot-api: | |
name: Telegram Bot API | |
runs-on: ubuntu-latest | |
if: github.event.inputs.artifacts != 'y' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Clone Telegram Bot API | |
run: | | |
git clone --recursive https://github.com/tdlib/telegram-bot-api.git | |
git status telegram-bot-api >> telegram-bot-api-status | |
- name: Cache Bot API Binary | |
id: cache-bot-api | |
uses: actions/cache@v3 | |
with: | |
path: telegram-bot-api-binary | |
key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }} | |
- name: Compile Telegram Bot API | |
if: steps.cache-bot-api.outputs.cache-hit != 'true' | |
run: | | |
sudo apt-get update | |
sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++ | |
cd telegram-bot-api | |
rm -rf build | |
mkdir build | |
cd build | |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. | |
cmake --build . --target install -j$(nproc) | |
cd ../.. | |
ls -l telegram-bot-api/bin/telegram-bot-api* | |
cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary | |
- name: Upload Binary | |
uses: actions/upload-artifact@master | |
with: | |
name: telegram-bot-api-binary | |
path: telegram-bot-api-binary |