259 lines
11 KiB
YAML
259 lines
11 KiB
YAML
name: Docker multi-arch build
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
|
|
jobs:
|
|
build:
|
|
name: Build (${{ matrix.implementation }}-${{ matrix.os }}-${{ matrix.arch }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/386", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/386", implementation: "tdlib"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/amd64", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/amd64", implementation: "tdlib"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/armhf", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/armhf", implementation: "tdlib"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/arm64", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/arm64", implementation: "tdlib"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/s390x", implementation: "tdlight"}
|
|
# Can't build original tdlib for big endian architectures
|
|
# - {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/s390x", implementation: "tdlib"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/ppc64le", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", useqemu: "false", arch: "linux/ppc64le", implementation: "tdlib"}
|
|
- {os: windows-2019, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlight", vcpkgCommitId: "30124253eecff36bc90f73341edbfb4f845e2a1e", triplet: "x64-windows-static"}
|
|
- {os: windows-2019, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlib", vcpkgCommitId: "30124253eecff36bc90f73341edbfb4f845e2a1e", triplet: "x64-windows-static"}
|
|
- {os: macos-10.15, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlight"}
|
|
- {os: macos-10.15, usedocker: "false", useqemu: "false", arch: "amd64", implementation: "tdlib"}
|
|
steps:
|
|
- name: Checkout current repo
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: "recursive"
|
|
|
|
|
|
- name: Get version
|
|
if: matrix.usedocker == 'true'
|
|
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
|
|
if: matrix.usedocker == 'true' && matrix.useqemu == 'true'
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
if: matrix.usedocker == 'true'
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Cache Docker layers
|
|
if: matrix.usedocker == 'true'
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ env.SAFE_ARCH }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-${{ env.SAFE_ARCH }}-
|
|
|
|
- name: Build image
|
|
if: matrix.usedocker == 'true'
|
|
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
|
|
platforms: linux/amd64
|
|
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
|
|
if: matrix.usedocker == 'true'
|
|
run: |
|
|
mkdir generated
|
|
docker cp $(docker create tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}):/usr/src/tdlight-java-natives/generated/. ./generated/.
|
|
|
|
- name: Setup Java (Snapshot)
|
|
if: github.ref == 'refs/heads/develop'
|
|
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)
|
|
if: github.ref == 'refs/heads/master'
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 11
|
|
server-id: mchv-release-distribution
|
|
server-username: MAVEN_USERNAME
|
|
server-password: MAVEN_PASSWORD
|
|
- name: Setup variables
|
|
shell: bash
|
|
run: |
|
|
# ====== Variables
|
|
export REVISION=${{ github.run_number }}
|
|
export GH_MATRIX_OS=${{ matrix.os }}
|
|
export GH_MATRIX_ARCH=${{ matrix.arch }}
|
|
export IMPLEMENTATION_NAME=${{ matrix.implementation }}
|
|
source ./scripts/continuous-integration/github-workflows/setup-variables.sh
|
|
|
|
echo "Variables:"
|
|
echo "REVISION=$REVISION" >> $GITHUB_ENV
|
|
echo "BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV
|
|
echo "IMPLEMENTATION_NAME=$IMPLEMENTATION_NAME" >> $GITHUB_ENV
|
|
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
|
|
if [[ ! -z "$PATH" && "$OPERATING_SYSTEM_NAME" != "windows" ]]; then
|
|
echo "PATH=$PATH" >> $GITHUB_ENV
|
|
fi
|
|
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
|
|
|
|
- name: Install dependencies
|
|
if: matrix.usedocker == 'false'
|
|
shell: bash
|
|
run: |
|
|
echo "REVISION: $REVISION"
|
|
|
|
source ./scripts/continuous-integration/github-workflows/install-dependencies.sh
|
|
- name: Setup PHP with Readline extension
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.0'
|
|
extensions: readline
|
|
- name: Install MSVC
|
|
if: matrix.os == 'windows-2019'
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
with:
|
|
vs-version: '[16.4,16.5)'
|
|
- name: Setup cmake
|
|
if: matrix.os == 'windows-2019'
|
|
uses: jwlawson/actions-setup-cmake@v1.9
|
|
with:
|
|
cmake-version: '3.16.x'
|
|
- name: Set up Maven
|
|
uses: stCarolas/setup-maven@v4.2
|
|
with:
|
|
maven-version: 3.8.2
|
|
- name: Setup NASM
|
|
if: matrix.os == 'windows-2019'
|
|
uses: ilammy/setup-nasm@v1
|
|
- name: Restore artifacts, or setup vcpkg (do not install any package)
|
|
if: matrix.os == 'windows-2019'
|
|
uses: lukka/run-vcpkg@v7
|
|
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.
|
|
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
|
vcpkgGitCommitId: '${{ matrix.vcpkgCommitId}}'
|
|
# 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.
|
|
additionalCachedPaths: ${{ github.workspace }}/vcpkg
|
|
- name: Install vcpkg deps
|
|
if: matrix.os == 'windows-2019'
|
|
run: |
|
|
$VCPKG_DIR/vcpkg install gperf openssl:x64-windows-static zlib:x64-windows-static
|
|
shell: bash
|
|
- name: Build
|
|
if: matrix.usedocker == 'false'
|
|
shell: bash
|
|
run: |
|
|
echo "REVISION: $REVISION"
|
|
|
|
source ./scripts/continuous-integration/github-workflows/build-natives.sh
|
|
|
|
|
|
- id: getfilename
|
|
shell: bash
|
|
run: echo "::set-output name=file::$(cd generated/target; ls tdli*-natives-*.jar)"
|
|
- id: getfilepath
|
|
shell: bash
|
|
run: echo "::set-output name=file::$(ls generated/target/tdli*-natives-*.jar)"
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ steps.getfilename.outputs.file }}
|
|
path: ${{ steps.getfilepath.outputs.file }}
|
|
- name: Deploy to Maven (Snapshot)
|
|
if: github.ref == 'refs/heads/develop'
|
|
shell: bash
|
|
run: |
|
|
echo "REVISION: $REVISION"
|
|
|
|
source ./scripts/continuous-integration/github-workflows/deploy-snapshot.sh
|
|
env:
|
|
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
|
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|
|
- name: Deploy to Maven (Release)
|
|
if: github.ref == 'refs/heads/master'
|
|
shell: bash
|
|
run: |
|
|
echo "REVISION: $REVISION"
|
|
|
|
source ./scripts/continuous-integration/github-workflows/deploy-release.sh
|
|
env:
|
|
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
|
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|