Skip to content

Build TDLib Addon binaries #16

Build TDLib Addon binaries

Build TDLib Addon binaries #16

name: Build TDLib Addon binaries
# This workflow can be executed using a command like this:
# gh workflow run prebuilt-tdlib.yml --ref develop -f tdlib=v1.8.0 \
# -f npm-version=0.1008000.0 -f npm-tag=latest -f npm-add-tag=td-1.8.0
on:
workflow_dispatch:
inputs:
ADDON_VERSION:
description: 'version of "tdlib-addon-prebuilt" from package.json'
type: string
required: true
env:
DOCKER_IMAGE_GLIBC: node:16-slim
DOCKER_IMAGE_MUSL: node:16-alpine
ARCH_X64: x64
ARCH_ARM64: arm64
ARCH_X64_DOCKER_PLATFORM: amd64
ARCH_ARM64_DOCKER_PLATFORM: arm64
# NOTE: The ZLIB_USE_STATIC_LIBS option requires CMake >= 3.24
jobs:
build-linux-matrix:
name: Build TDLib in docker
runs-on: ubuntu-20.04
strategy:
fail-fast: false
max-parallel: 2
matrix:
platform:
- x64
- arm64
libc:
- glibc
- musl
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- run: docker run --privileged --rm tonistiigi/binfmt --install arm64
# - run: docker build -t build -f Dockerfile .
# - run: mkdir -p prebuilds/lib
# - run: docker create --name dummy build
# - run: docker cp -L dummy:/td/build/libtdjson.so prebuilds/lib/libtdjson.so
# - run: docker cp -L dummy:/td/build/info.txt prebuilds/lib/info.txt
# - run: ldd prebuilds/lib/libtdjson.so
# - run: |
# cd prebuilds
# tar -czvf linux-arm64-musl.tar.gz lib/*
# cp linux-arm64-musl.tar.gz ..
# - uses: actions/upload-artifact@v3
# with:
# name: tdlib-linux-x64-musl
# path: libtdjson.so
- name: Set variables
run: |
echo "TGZ_NAME=linux-${{ matrix.platform == 'arm64' && env.ARCH_ARM64 || env.ARCH_X64 }}-${{ matrix.libc }}.tar.gz" >> $GITHUB_ENV
echo 'ADDON_VERSION=${{ inputs.ADDON_VERSION }}' >> $GITHUB_ENV
echo 'TDLIB_GIT_COMMIT_HASH='`cd deps/td && git rev-parse HEAD` >> $GITHUB_ENV
# echo 'ADDON_VERSION='`cat deps/td/CMakeLists.txt | sed -nr "s/project\(TDLib VERSION ([0-9.]+) LANGUAGES CXX C\)/\1/p"` >> $GITHUB_ENV
# - name: Show variables
# run: |
# echo ${{ env.TGZ_NAME }}
# echo ${{ env.ADDON_VERSION }}
# echo ${{ env.TDLIB_GIT_COMMIT_HASH }}
- name: Build in docker
run: |
make build-lib-docker-linux-${{ matrix.platform }}-${{ matrix.libc }}
# mkdir -p prebuilds/lib
# cat prebuilt-tdlib-docker.sh
# docker run \
# -v $(pwd):/rep \
# --platform linux/${{ matrix.platform == 'arm64' && env.ARCH_ARM64_DOCKER_PLATFORM || env.ARCH_X64_DOCKER_PLATFORM }} \
# ${{ matrix.libc == 'glibc' && env.DOCKER_IMAGE_GLIBC || env.DOCKER_IMAGE_MUSL }} \
# sh /rep/prebuilt-tdlib-docker.sh
- name: Archive
run: |
LIBC=${{ matrix.libc }} ARCH=${{ matrix.platform }} make build-lib-archive
# cd prebuilds
# cat lib/info.txt
# tar -czvf ${{ env.TGZ_NAME }} lib/*
# cp ${{ env.TGZ_NAME }} ..
- name: Create version folder
# You may pin to the exact commit or the version.
# uses: nekiro/ssh-job@e0d177751aced5bcaf110ce4d782a681e5e12856
uses: nekiro/ssh-job@v1.0.5
with:
# Target machine hostname or ip
host: tdlib-binaries.telepilot.co
# Port to use while connecting
port: 22
# Ssh private key used to connect to target machine
key: ${{ secrets.SSH_PRIVATE_KEY }}
# Ssh user
user: ${{ vars.SSH_USERNAME }}
command: |
mkdir -p ${{ vars.TARGET_UPLOAD_FOLDER }}/v${{ env.ADDON_VERSION }}
- name: Upload to version folder
uses: appleboy/scp-action@v0.1.4
with:
host: tdlib-binaries.telepilot.co
username: ${{ vars.SSH_USERNAME }}
port: 22
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "${{ env.TGZ_NAME }}"
target: ${{ vars.TARGET_UPLOAD_FOLDER }}/v${{ env.ADDON_VERSION }}/
# - name: Upload to version/git commit hash folder
# uses: appleboy/scp-action@v0.1.4
# with:
# host: tdlib-binaries.telepilot.co
# username: ${{ vars.SSH_USERNAME }}
# port: 22
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# source: "${{ env.TGZ_NAME }}"
# target: /tmp/v${{ env.ADDON_VERSION }}/${{ env.TDLIB_GIT_COMMIT_HASH }}/