2021-03-15 18:55:42 +01:00
|
|
|
name: Docker multi-arch build
|
2020-12-26 12:09:32 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-03-15 18:55:42 +01:00
|
|
|
pull_request:
|
|
|
|
|
2020-12-26 12:09:32 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2021-03-15 19:05:50 +01:00
|
|
|
name: Build (${{ matrix.implementation }}-${{ matrix.os }}-${{ matrix.arch }})
|
2021-03-15 19:04:42 +01:00
|
|
|
runs-on: ${{ matrix.os }}
|
2020-12-26 12:09:32 +01:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-12-26 12:20:40 +01:00
|
|
|
include:
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/386", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/386", implementation: "tdlib"}
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/amd64", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/amd64", implementation: "tdlib"}
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/armhf", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/armhf", implementation: "tdlib"}
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/arm64", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/arm64", implementation: "tdlib"}
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/s390x", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/s390x", implementation: "tdlib"}
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/ppc64le", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/ppc64le", implementation: "tdlib"}
|
2022-10-16 15:42:08 +02:00
|
|
|
- {os: windows-2019, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlight", vcpkgCommitId: "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", triplet: "x64-windows-static"}
|
|
|
|
#- {os: windows-2019, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlib", vcpkgCommitId: "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", triplet: "x64-windows-static"}
|
2021-09-26 00:56:40 +02:00
|
|
|
- {os: macos-10.15, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlight"}
|
2021-10-22 11:06:14 +02:00
|
|
|
#- {os: macos-10.15, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlib"}
|
2020-12-26 12:09:32 +01:00
|
|
|
steps:
|
2021-03-15 18:55:42 +01:00
|
|
|
- name: Checkout current repo
|
|
|
|
uses: actions/checkout@v2
|
2020-12-26 12:38:55 +01:00
|
|
|
with:
|
|
|
|
submodules: "recursive"
|
2021-03-15 18:59:29 +01:00
|
|
|
|
|
|
|
|
2021-03-15 18:55:42 +01:00
|
|
|
- name: Get version
|
2021-03-15 18:59:29 +01:00
|
|
|
if: matrix.usedocker == 'true'
|
2021-03-15 18:55:42 +01:00
|
|
|
run: |
|
|
|
|
# Get latest commit short hash
|
|
|
|
HASH_VERSION=$(git rev-parse --short HEAD)
|
|
|
|
|
|
|
|
# Strip git ref prefix from version
|
|
|
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
|
|
|
|
|
|
|
# Strip "v" prefix from tag name
|
|
|
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
|
|
|
|
|
|
|
# Use Docker `latest` tag convention
|
|
|
|
[ "$VERSION" == "master" ] && VERSION=latest
|
|
|
|
|
|
|
|
HASH_VERSION=$(echo "$HASH_VERSION" | awk '{print tolower($0)}')
|
|
|
|
VERSION=$(echo "$VERSION" | awk '{print tolower($0)}')
|
|
|
|
ARCH=${{ matrix.arch }}
|
|
|
|
SAFE_ARCH=${ARCH///} # linux/amd64 -> linuxamd64
|
|
|
|
|
|
|
|
# Store variable for future use
|
|
|
|
echo "HASH_VERSION=$HASH_VERSION" >> $GITHUB_ENV
|
|
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
|
|
echo "SAFE_ARCH=$SAFE_ARCH" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
# Print debug info
|
|
|
|
echo "hash version: $HASH_VERSION"
|
|
|
|
echo "version: $VERSION"
|
|
|
|
echo "safe arch: $SAFE_ARCH"
|
|
|
|
|
|
|
|
# Save env to file
|
|
|
|
cat $GITHUB_ENV > github.env
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
2021-09-26 00:56:40 +02:00
|
|
|
if: matrix.usedocker == 'true' && matrix.useqemu == 'true'
|
2021-03-15 18:55:42 +01:00
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2021-03-15 18:59:29 +01:00
|
|
|
if: matrix.usedocker == 'true'
|
2021-03-15 18:55:42 +01:00
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Cache Docker layers
|
2021-03-15 18:59:29 +01:00
|
|
|
if: matrix.usedocker == 'true'
|
2021-03-15 18:55:42 +01:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
2021-09-26 19:43:12 +02:00
|
|
|
path: /tmp/.buildx-cache
|
2022-05-04 18:48:07 +02:00
|
|
|
key: ${{ runner.os }}-v2-buildx-cache-${{ env.SAFE_ARCH }}-${{ github.sha }}
|
2021-03-15 18:55:42 +01:00
|
|
|
restore-keys: |
|
2022-05-04 18:48:07 +02:00
|
|
|
${{ runner.os }}-v2-buildx-cache-${{ env.SAFE_ARCH }}-
|
2021-03-15 18:55:42 +01:00
|
|
|
|
2021-09-26 19:43:12 +02:00
|
|
|
- name: Cache Maven
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.m2/repository
|
2022-05-04 18:48:07 +02:00
|
|
|
key: ${{ runner.os }}-v2-maven-${{ env.SAFE_ARCH }}-${{ hashFiles('**/pom.xml') }}
|
2021-09-26 19:43:12 +02:00
|
|
|
restore-keys: |
|
2022-05-04 18:48:07 +02:00
|
|
|
${{ runner.os }}-v2-maven-${{ env.SAFE_ARCH }}-
|
2021-09-26 19:43:12 +02:00
|
|
|
|
|
|
|
- name: Cache packages cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/tdlight-java-natives/tdlight-java-natives/.cache
|
2022-05-04 18:48:07 +02:00
|
|
|
key: ${{ runner.os }}-v2-packages-${{ env.SAFE_ARCH }}-${{ github.sha }}
|
2021-09-26 19:43:12 +02:00
|
|
|
restore-keys: |
|
2022-05-04 18:48:07 +02:00
|
|
|
${{ runner.os }}-v2-packages-${{ env.SAFE_ARCH }}-
|
2021-09-26 19:43:12 +02:00
|
|
|
|
|
|
|
- name: Cache ccache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.ccache
|
2022-05-04 18:48:07 +02:00
|
|
|
key: ${{ runner.os }}-v2-ccache-${{ env.SAFE_ARCH }}-${{ github.sha }}
|
2021-09-26 19:43:12 +02:00
|
|
|
restore-keys: |
|
2022-05-04 18:48:07 +02:00
|
|
|
${{ runner.os }}-v2-ccache-${{ env.SAFE_ARCH }}-
|
2021-09-26 19:43:12 +02:00
|
|
|
|
2021-03-15 18:55:42 +01:00
|
|
|
- name: Build image
|
2021-03-15 18:59:29 +01:00
|
|
|
if: matrix.usedocker == 'true'
|
2021-03-15 18:55:42 +01:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
|
2021-09-26 01:01:12 +02:00
|
|
|
platforms: linux/amd64
|
2021-03-15 18:55:42 +01:00
|
|
|
push: false
|
|
|
|
load: true
|
|
|
|
tags: |
|
|
|
|
tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}
|
|
|
|
build-args: |
|
|
|
|
REVISION=${{ github.run_number }}
|
|
|
|
GH_MATRIX_OS=${{ matrix.os }}
|
|
|
|
GH_MATRIX_ARCH=${{ matrix.arch }}
|
|
|
|
IMPLEMENTATION_NAME=${{ matrix.implementation }}
|
|
|
|
|
|
|
|
- name: Extract jni from docker image
|
2021-03-15 18:59:29 +01:00
|
|
|
if: matrix.usedocker == 'true'
|
2021-03-15 18:55:42 +01:00
|
|
|
run: |
|
|
|
|
mkdir generated
|
|
|
|
docker cp $(docker create tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}):/usr/src/tdlight-java-natives/generated/. ./generated/.
|
|
|
|
|
2021-03-15 18:59:29 +01:00
|
|
|
- name: Setup Java (Snapshot)
|
2021-03-16 01:56:44 +01:00
|
|
|
if: github.ref == 'refs/heads/develop'
|
2021-03-15 18:59:29 +01:00
|
|
|
uses: actions/setup-java@v1
|
|
|
|
with:
|
|
|
|
java-version: 11
|
|
|
|
server-id: mchv-snapshot-distribution
|
|
|
|
server-username: MAVEN_USERNAME
|
|
|
|
server-password: MAVEN_PASSWORD
|
|
|
|
- name: Setup Java (Release)
|
2021-03-16 01:56:44 +01:00
|
|
|
if: github.ref == 'refs/heads/master'
|
2021-03-15 18:59:29 +01:00
|
|
|
uses: actions/setup-java@v1
|
|
|
|
with:
|
|
|
|
java-version: 11
|
|
|
|
server-id: mchv-release-distribution
|
|
|
|
server-username: MAVEN_USERNAME
|
|
|
|
server-password: MAVEN_PASSWORD
|
2020-12-26 12:09:32 +01:00
|
|
|
- name: Setup variables
|
2020-12-26 12:42:01 +01:00
|
|
|
shell: bash
|
2020-12-26 12:09:32 +01:00
|
|
|
run: |
|
|
|
|
# ====== Variables
|
2020-12-26 12:45:53 +01:00
|
|
|
export REVISION=${{ github.run_number }}
|
2020-12-26 13:07:23 +01:00
|
|
|
export GH_MATRIX_OS=${{ matrix.os }}
|
2020-12-26 12:45:53 +01:00
|
|
|
export GH_MATRIX_ARCH=${{ matrix.arch }}
|
2020-12-26 15:39:42 +01:00
|
|
|
export IMPLEMENTATION_NAME=${{ matrix.implementation }}
|
2020-12-28 19:52:17 +01:00
|
|
|
source ./scripts/continuous-integration/github-workflows/setup-variables.sh
|
2020-12-26 12:36:31 +01:00
|
|
|
|
2021-03-15 22:11:42 +01:00
|
|
|
echo "Variables:"
|
2020-12-26 12:09:32 +01:00
|
|
|
echo "REVISION=$REVISION" >> $GITHUB_ENV
|
2021-01-05 12:54:13 +01:00
|
|
|
echo "BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV
|
2020-12-26 15:39:42 +01:00
|
|
|
echo "IMPLEMENTATION_NAME=$IMPLEMENTATION_NAME" >> $GITHUB_ENV
|
2020-12-26 12:09:32 +01:00
|
|
|
echo "TD_SRC_DIR=$TD_SRC_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TD_BIN_DIR=$TD_BIN_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TDNATIVES_BIN_DIR=$TDNATIVES_BIN_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TDNATIVES_CPP_SRC_DIR=$TDNATIVES_CPP_SRC_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TDNATIVES_DOCS_BIN_DIR=$TDNATIVES_DOCS_BIN_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TD_BUILD_DIR=$TD_BUILD_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TDNATIVES_CPP_BUILD_DIR=$TDNATIVES_CPP_BUILD_DIR" >> $GITHUB_ENV
|
|
|
|
echo "JAVA_SRC_DIR=$JAVA_SRC_DIR" >> $GITHUB_ENV
|
|
|
|
echo "TDLIB_SERIALIZER_DIR=$TDLIB_SERIALIZER_DIR" >> $GITHUB_ENV
|
2021-09-14 15:03:15 +02:00
|
|
|
if [[ ! -z "$PATH" && "$OPERATING_SYSTEM_NAME" != "windows" ]]; then
|
|
|
|
echo "PATH=$PATH" >> $GITHUB_ENV
|
|
|
|
fi
|
2020-12-26 12:09:32 +01:00
|
|
|
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
|
|
|
|
echo "JAVA_INCLUDE_PATH=$JAVA_INCLUDE_PATH" >> $GITHUB_ENV
|
|
|
|
echo "CMAKE_EXTRA_ARGUMENTS=$CMAKE_EXTRA_ARGUMENTS" >> $GITHUB_ENV
|
|
|
|
echo "VCPKG_DIR=$VCPKG_DIR" >> $GITHUB_ENV
|
|
|
|
echo "MAVEN_OPTS=$MAVEN_OPTS" >> $GITHUB_ENV
|
|
|
|
echo "GH_CPU_ARCH=$GH_CPU_ARCH" >> $GITHUB_ENV
|
|
|
|
echo "CPU_ARCH_JAVA=$CPU_ARCH_JAVA" >> $GITHUB_ENV
|
|
|
|
echo "CPU_ARCHITECTURE_NAME=$CPU_ARCHITECTURE_NAME" >> $GITHUB_ENV
|
|
|
|
echo "CPU_CORES_NUM=$CPU_CORES_NUM" >> $GITHUB_ENV
|
|
|
|
echo "CPU_CORES=$CPU_CORES" >> $GITHUB_ENV
|
|
|
|
echo "OPERATING_SYSTEM_NAME=$OPERATING_SYSTEM_NAME" >> $GITHUB_ENV
|
|
|
|
echo "OPERATING_SYSTEM_NAME_SHORT=$OPERATING_SYSTEM_NAME_SHORT" >> $GITHUB_ENV
|
|
|
|
echo "SRC_TDJNI_LIBNAME=$SRC_TDJNI_LIBNAME" >> $GITHUB_ENV
|
|
|
|
echo "DEST_TDJNI_LIBNAME=$DEST_TDJNI_LIBNAME" >> $GITHUB_ENV
|
2021-09-14 01:55:55 +02:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
if: matrix.usedocker == 'false'
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "REVISION: $REVISION"
|
|
|
|
|
|
|
|
source ./scripts/continuous-integration/github-workflows/install-dependencies.sh
|
2021-09-14 15:03:15 +02:00
|
|
|
- name: Setup PHP with Readline extension
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: '8.0'
|
|
|
|
extensions: readline
|
|
|
|
- name: Install MSVC
|
2022-03-16 00:21:04 +01:00
|
|
|
if: matrix.os == 'windows-2019'
|
2021-09-14 15:03:15 +02:00
|
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
with:
|
2022-03-16 00:21:04 +01:00
|
|
|
toolset: 14.0
|
2021-09-14 15:03:15 +02:00
|
|
|
vs-version: '[16.4,16.5)'
|
|
|
|
- name: Setup cmake
|
2022-03-16 00:21:04 +01:00
|
|
|
if: matrix.os == 'windows-2019'
|
2022-03-15 19:39:53 +01:00
|
|
|
uses: lukka/get-cmake@latest
|
2021-09-14 15:03:15 +02:00
|
|
|
- name: Set up Maven
|
|
|
|
uses: stCarolas/setup-maven@v4.2
|
|
|
|
with:
|
|
|
|
maven-version: 3.8.2
|
|
|
|
- name: Setup NASM
|
2022-03-16 00:21:04 +01:00
|
|
|
if: matrix.os == 'windows-2019'
|
2021-09-14 15:03:15 +02:00
|
|
|
uses: ilammy/setup-nasm@v1
|
2021-09-11 12:27:22 +02:00
|
|
|
- name: Restore artifacts, or setup vcpkg (do not install any package)
|
2022-03-16 00:21:04 +01:00
|
|
|
if: matrix.os == 'windows-2019'
|
2022-03-15 19:30:08 +01:00
|
|
|
uses: lukka/run-vcpkg@v10.2
|
2021-09-11 12:27:22 +02:00
|
|
|
with:
|
|
|
|
# Just install vcpkg for now, do not install any ports in this step yet.
|
|
|
|
setupOnly: true
|
|
|
|
# Location of the vcpkg submodule in the Git repository.
|
2021-09-14 15:03:15 +02:00
|
|
|
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
|
|
|
vcpkgGitCommitId: '${{ matrix.vcpkgCommitId}}'
|
2021-09-11 12:27:22 +02:00
|
|
|
# Since the cache must be invalidated when content of the vcpkg.json file changes, let's
|
|
|
|
# compute its hash and append this to the computed cache's key.
|
|
|
|
appendedCacheKey: ${{ hashFiles( '**/vcpkg_manifest/vcpkg.json' ) }}
|
|
|
|
vcpkgTriplet: ${{ matrix.triplet }}
|
|
|
|
# Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory.
|
2021-09-14 15:03:15 +02:00
|
|
|
additionalCachedPaths: ${{ github.workspace }}/vcpkg
|
2021-09-11 12:27:22 +02:00
|
|
|
- name: Install vcpkg deps
|
2022-03-16 00:21:04 +01:00
|
|
|
if: matrix.os == 'windows-2019'
|
2021-09-11 12:27:22 +02:00
|
|
|
run: |
|
|
|
|
$VCPKG_DIR/vcpkg install gperf openssl:x64-windows-static zlib:x64-windows-static
|
|
|
|
shell: bash
|
2020-12-26 15:06:44 +01:00
|
|
|
- name: Build
|
2021-03-15 18:59:29 +01:00
|
|
|
if: matrix.usedocker == 'false'
|
2020-12-26 15:06:44 +01:00
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "REVISION: $REVISION"
|
|
|
|
|
2020-12-29 19:33:21 +01:00
|
|
|
source ./scripts/continuous-integration/github-workflows/build-natives.sh
|
2020-12-27 18:45:23 +01:00
|
|
|
- id: getfilename
|
2020-12-27 19:04:46 +01:00
|
|
|
shell: bash
|
2020-12-27 19:41:19 +01:00
|
|
|
run: echo "::set-output name=file::$(cd generated/target; ls tdli*-natives-*.jar)"
|
2020-12-27 19:04:46 +01:00
|
|
|
- id: getfilepath
|
2020-12-27 18:45:23 +01:00
|
|
|
shell: bash
|
2020-12-27 19:41:19 +01:00
|
|
|
run: echo "::set-output name=file::$(ls generated/target/tdli*-natives-*.jar)"
|
2020-12-26 12:09:32 +01:00
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
2020-12-27 19:04:46 +01:00
|
|
|
name: ${{ steps.getfilename.outputs.file }}
|
|
|
|
path: ${{ steps.getfilepath.outputs.file }}
|
2020-12-28 00:16:13 +01:00
|
|
|
- name: Deploy to Maven (Snapshot)
|
2021-03-15 18:55:42 +01:00
|
|
|
if: github.ref == 'refs/heads/develop'
|
2020-12-27 18:45:23 +01:00
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "REVISION: $REVISION"
|
|
|
|
|
2020-12-28 19:52:17 +01:00
|
|
|
source ./scripts/continuous-integration/github-workflows/deploy-snapshot.sh
|
2020-12-27 18:45:23 +01:00
|
|
|
env:
|
|
|
|
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
|
|
|
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|
2020-12-28 00:16:13 +01:00
|
|
|
- name: Deploy to Maven (Release)
|
2020-12-27 21:08:01 +01:00
|
|
|
if: github.ref == 'refs/heads/master'
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "REVISION: $REVISION"
|
|
|
|
|
2020-12-28 19:52:17 +01:00
|
|
|
source ./scripts/continuous-integration/github-workflows/deploy-release.sh
|
2020-12-27 21:08:01 +01:00
|
|
|
env:
|
|
|
|
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
|
|
|
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|