284 lines
12 KiB
YAML
284 lines
12 KiB
YAML
name: Docker multi-arch build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- develop
|
|
|
|
jobs:
|
|
build:
|
|
name: Build (${{ matrix.implementation }}-${{ matrix.os }}-${{ matrix.arch }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- {os: ubuntu-20.04, usedocker: "true", ssl: "ssl1", useqemu: "false", arch: "linux/386", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", ssl: "ssl1", useqemu: "false", arch: "linux/amd64", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", ssl: "ssl1", useqemu: "false", arch: "linux/armhf", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", ssl: "ssl1", useqemu: "false", arch: "linux/arm64", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", ssl: "ssl1", useqemu: "false", arch: "linux/s390x", implementation: "tdlight"}
|
|
- {os: ubuntu-20.04, usedocker: "true", ssl: "ssl1", useqemu: "false", arch: "linux/ppc64le", implementation: "tdlight"}
|
|
- {os: ubuntu-22.04, usedocker: "true", ssl: "ssl3", useqemu: "false", arch: "linux/amd64", implementation: "tdlight"}
|
|
- {os: ubuntu-22.04, usedocker: "true", ssl: "ssl3", useqemu: "false", arch: "linux/arm64", implementation: "tdlight"}
|
|
- {os: windows-2019, usedocker: "false", ssl: "ssl1", useqemu: "false", arch: "amd64", implementation: "tdlight", vcpkgCommitId: "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", triplet: "x64-windows-static"}
|
|
- {os: macos-10.15, usedocker: "false", ssl: "ssl1", useqemu: "false", arch: "amd64", implementation: "tdlight"}
|
|
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
|
|
SSL_TYPE=${{ matrix.ssl }}
|
|
|
|
# Store variable for future use
|
|
echo "HASH_VERSION=$HASH_VERSION" >> $GITHUB_ENV
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
echo "SAFE_ARCH=$SAFE_ARCH" >> $GITHUB_ENV
|
|
echo "SSL_TYPE=$SSL_TYPE" >> $GITHUB_ENV
|
|
|
|
# Print debug info
|
|
echo "hash version: $HASH_VERSION"
|
|
echo "version: $VERSION"
|
|
echo "safe arch: $SAFE_ARCH"
|
|
echo "ssl type: $SSL_TYPE"
|
|
|
|
# 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@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
if: matrix.usedocker == 'true'
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Cache Docker layers
|
|
if: matrix.usedocker == 'true'
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-v3-buildx-cache-${{ env.SAFE_ARCH }}-${{ env.SSL }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-v3-buildx-cache-${{ env.SAFE_ARCH }}-${{ env.SSL }}-
|
|
|
|
- name: Cache Maven
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: ${{ runner.os }}-v3-maven-${{ env.SAFE_ARCH }}-${{ env.SSL }}-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-v3-maven-${{ env.SAFE_ARCH }}-${{ env.SSL }}-
|
|
|
|
- name: Cache packages cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/tdlight-java-natives/tdlight-java-natives/.cache
|
|
key: ${{ runner.os }}-v3-packages-${{ env.SAFE_ARCH }}-${{ env.SSL }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-v3-packages-${{ env.SAFE_ARCH }}-${{ env.SSL }}-
|
|
|
|
- name: Cache ccache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.ccache
|
|
key: ${{ runner.os }}-v2-ccache-${{ env.SAFE_ARCH }}-${{ env.SSL }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-v2-ccache-${{ env.SAFE_ARCH }}-${{ env.SSL }}-
|
|
|
|
- name: Build image
|
|
if: matrix.usedocker == 'true'
|
|
uses: docker/build-push-action@v3
|
|
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 }}-${{ env.SSL }}
|
|
build-args: |
|
|
REVISION=${{ github.run_number }}
|
|
GH_MATRIX_OS=${{ matrix.os }}
|
|
GH_MATRIX_ARCH=${{ matrix.arch }}
|
|
GH_MATRIX_SSL=${{ matrix.ssl }}
|
|
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 }}-${{ env.SSL }}):/usr/src/tdlight-java-natives/generated/. ./generated/.
|
|
|
|
- name: Setup Java (Snapshot)
|
|
if: github.ref == 'refs/heads/develop'
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: 11
|
|
distribution: temurin
|
|
server-id: mchv-snapshot-distribution
|
|
server-username: MAVEN_USERNAME
|
|
server-password: MAVEN_PASSWORD
|
|
- name: Setup Java (Release)
|
|
if: github.ref != 'refs/heads/develop'
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: 11
|
|
distribution: temurin
|
|
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 GH_MATRIX_SSL=${{ matrix.ssl }}
|
|
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 "SSL_TYPE=$GH_MATRIX_SSL" >> $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:
|
|
toolset: 14.0
|
|
vs-version: '[16.4,16.5)'
|
|
- name: Setup cmake
|
|
if: matrix.os == 'windows-2019'
|
|
uses: lukka/get-cmake@latest
|
|
- 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@v10.2
|
|
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@v3
|
|
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"
|
|
echo "SSL TYPE: $SSL_TYPE"
|
|
|
|
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"
|
|
echo "SSL TYPE: $SSL_TYPE"
|
|
|
|
source ./scripts/continuous-integration/github-workflows/deploy-release.sh
|
|
env:
|
|
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
|
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|