Build TDLib Addon binaries #24
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 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: 1 | |
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 }}/ | |
# - name: Create/Update release and upload assets | |
# # You may pin to the exact commit or the version. | |
# # uses: ColinPitrat/update-release@ae88712eedac1679d610a95fde906b2d4c94614a | |
# uses: ColinPitrat/update-release@v1.0.1 | |
# with: | |
# # Your Github token; try \$\{\{ secrets.GITHUB_TOKEN \}\} if your build lasts less than an hour, or create your own secret token with repository access if your build requires longer than an hour. | |
# token: ${{ secrets.GH_TOKEN }} | |
# # Paths to built files to be released. May be absolute or relative to \$\{\{ github.workspace \}\}. | |
# files: ${{ env.TGZ_NAME }} | |
# # The name of the release to be created. A reasonable looking release name will be created from the current \$\{\{ github.ref \}\} if this input is not supplied. | |
# release: ${{ env.ADDON_VERSION }} | |
# # # The name of the tag to be used. If not provided, the name of the release will be used. | |
# # tag: # optional | |
# # # A one-line description for both the tag and the release. | |
# # message: # optional | |
# # # A fuller description of the release. | |
# # body: # optional | |
# # # Should the release, if created, be marked as a prerelease? Such releases are generally publicly visible. | |
# # prerelease: # optional | |
# # Should the release, if created, be marked as a draft? Such releases are generally not publicly visible. | |
# draft: true | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
tag_name: v${{ env.ADDON_VERSION }} # Specify the tag name for the release | |
release_name: Release v${{ env.ADDON_VERSION }} # Specify the release name | |
body: | | |
Release notes and description for v${{ env.ADDON_VERSION }} | |
- name: Upload to GitHub Releases | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: "./${{ env.TGZ_NAME }}" | |
asset_name: ${{ env.TGZ_NAME }} | |
asset_content_type: application/gzip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |