tdlight-java-natives/.github/workflows/platform_natives.yaml

322 lines
17 KiB
YAML
Raw Normal View History

2023-05-07 18:03:58 +02:00
name: multi-arch build
2020-12-26 12:09:32 +01:00
on:
push:
2023-01-03 00:40:21 +01:00
branches:
- master
- develop
2021-03-15 18:55:42 +01:00
2020-12-26 12:09:32 +01:00
jobs:
build:
2023-05-07 18:03:58 +02:00
name: ${{ matrix.type }} on ${{ matrix.os }}
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:
2023-08-29 13:46:14 +02:00
- { os: ubuntu-22.04, type: "linux_amd64_gnu_ssl1", compiler: "gnu", ssl: "ssl1", debianArch: "amd64", tripleArch: "x86_64", tripleGnu: "gnu", debianVersion: "buster-backports", native: "true" }
- { os: ubuntu-22.04, type: "linux_amd64_gnu_ssl3", compiler: "gnu", ssl: "ssl3", debianArch: "amd64", tripleArch: "x86_64", tripleGnu: "gnu", debianVersion: "bookworm-backports", native: "true" }
- { os: ubuntu-22.04, type: "linux_amd64_clang_ssl3", compiler: "clang", ssl: "ssl3", debianArch: "amd64", tripleArch: "x86_64", tripleGnu: "gnu", debianVersion: "bookworm-backports", native: "true" }
2023-08-29 14:15:00 +02:00
#- { os: ubuntu-22.04, type: "linux_i386_gnu_ssl1", compiler: "gnu", ssl: "ssl1", debianArch: "i386", tripleArch: "i386", tripleGnu: "gnu", debianVersion: "buster-backports", native: "false" }
#- { os: ubuntu-22.04, type: "linux_i386_gnu_ssl3", compiler: "gnu", ssl: "ssl3", debianArch: "i386", tripleArch: "i386", tripleGnu: "gnu", debianVersion: "bookworm-backports", native: "false" }
2023-08-29 13:46:14 +02:00
- { os: ubuntu-22.04, type: "linux_ppc64el_gnu_ssl3", compiler: "gnu", ssl: "ssl3", debianArch: "ppc64el", tripleArch: "powerpc64le", tripleGnu: "gnu", debianVersion: "bookworm-backports", native: "false" }
- { os: ubuntu-22.04, type: "linux_riscv64_gnu_ssl3", compiler: "gnu", ssl: "ssl3", debianArch: "riscv64", tripleArch: "riscv64", tripleGnu: "gnu", debianVersion: "sid", native: "false" }
- { os: ubuntu-22.04, type: "linux_armhf_gnu_ssl1", compiler: "gnu", ssl: "ssl1", debianArch: "armhf", tripleArch: "arm", tripleGnu: "gnueabihf", debianVersion: "buster-backports", native: "false" }
- { os: ubuntu-22.04, type: "linux_armhf_gnu_ssl3", compiler: "gnu", ssl: "ssl3", debianArch: "armhf", tripleArch: "arm", tripleGnu: "gnueabihf", debianVersion: "bookworm-backports", native: "false" }
- { os: ubuntu-22.04, type: "linux_arm64_gnu_ssl1", compiler: "gnu", ssl: "ssl1", debianArch: "arm64", tripleArch: "aarch64", tripleGnu: "gnu", debianVersion: "buster-backports", native: "false" }
- { os: ubuntu-22.04, type: "linux_arm64_gnu_ssl3", compiler: "gnu", ssl: "ssl3", debianArch: "arm64", tripleArch: "aarch64", tripleGnu: "gnu", debianVersion: "bookworm-backports", native: "false" }
- { os: ubuntu-22.04, type: "linux_arm64_clang_ssl3", compiler: "clang", ssl: "ssl3", debianArch: "arm64", tripleArch: "aarch64", tripleGnu: "gnu", debianVersion: "bookworm-backports", native: "false" }
2023-05-14 15:31:52 +02:00
- { os: windows-2019, type: "windows_amd64", vcpkgCommitId: "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", triplet: "x64-windows-static" }
- { os: macos-12, type: "macos_amd64" }
2023-05-14 14:41:59 +02:00
# todo: do not enable until github actions adds support to apple silicon, accepting PRs
# - { os: macos-12, type: "macos_arm64" }
2020-12-26 12:09:32 +01:00
steps:
2021-03-15 18:55:42 +01:00
- name: Checkout current repo
2023-05-09 14:54:15 +02:00
uses: actions/checkout@v3
2020-12-26 12:38:55 +01:00
with:
submodules: "recursive"
2021-03-15 18:55:42 +01:00
- name: Get version
2023-05-13 15:02:44 +02:00
shell: bash
2021-03-15 18:55:42 +01:00
run: |
2023-05-09 12:15:15 +02:00
set -xeo pipefail
2021-03-15 18:55:42 +01:00
# 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,')
2023-04-27 20:18:15 +02:00
2021-03-15 18:55:42 +01:00
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
2023-04-27 20:18:15 +02:00
2021-03-15 18:55:42 +01:00
# 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)}')
2023-04-27 20:18:15 +02:00
TYPE=${{ matrix.type }}
2023-05-10 10:24:01 +02:00
SAFE_TYPE=${TYPE///} # linux_amd64_ -> linux_amd64_
2023-08-29 12:33:59 +02:00
COMPILER=${{ matrix.compiler }}
SSL=${{ matrix.ssl }}
DEBIAN_ARCH=${{ matrix.debianArch }}
TRIPLE_ARCH=${{ matrix.tripleArch }}
TRIPLE_GNU=${{ matrix.tripleGnu }}
2023-08-29 13:46:14 +02:00
NATIVE=${{ matrix.native }}
2023-08-29 12:52:08 +02:00
DEBIAN_VERSION=${{ matrix.debianVersion }}
2023-04-27 20:18:15 +02:00
2023-05-09 11:46:30 +02:00
REVISION=4.0.${{ github.run_number }}
2023-04-27 20:18:15 +02:00
GH_MATRIX_OS=${{ matrix.os }}
GH_MATRIX_TYPE=${{ matrix.type }}
2021-03-15 18:55:42 +01:00
# Store variable for future use
echo "HASH_VERSION=$HASH_VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
2023-04-27 20:18:15 +02:00
echo "TYPE=$TYPE" >> $GITHUB_ENV
echo "SAFE_TYPE=$SAFE_TYPE" >> $GITHUB_ENV
2023-08-29 12:48:04 +02:00
echo "COMPILER=$COMPILER" >> $GITHUB_ENV
2023-08-29 12:33:59 +02:00
echo "SSL=$SSL" >> $GITHUB_ENV
echo "DEBIAN_ARCH=$DEBIAN_ARCH" >> $GITHUB_ENV
echo "TRIPLE_ARCH=$TRIPLE_ARCH" >> $GITHUB_ENV
echo "TRIPLE_GNU=$TRIPLE_GNU" >> $GITHUB_ENV
2023-08-29 13:46:14 +02:00
echo "NATIVE=$NATIVE" >> $GITHUB_ENV
2023-08-29 12:52:08 +02:00
echo "DEBIAN_VERSION=$DEBIAN_VERSION" >> $GITHUB_ENV
2023-04-27 20:18:15 +02:00
echo "REVISION=$REVISION" >> $GITHUB_ENV
echo "GH_MATRIX_OS=$GH_MATRIX_OS" >> $GITHUB_ENV
echo "GH_MATRIX_TYPE=$GH_MATRIX_TYPE" >> $GITHUB_ENV
2021-03-15 18:55:42 +01:00
# Print debug info
echo "hash version: $HASH_VERSION"
echo "version: $VERSION"
echo "safe arch: $SAFE_ARCH"
2023-08-29 12:33:59 +02:00
echo "ssl: $SSL"
echo "debian arch: $DEBIAN_ARCH"
echo "triple arch: $TRIPLE_ARCH"
echo "triple gnu: $TRIPLE_GNU"
2021-03-15 18:55:42 +01:00
2023-04-27 20:18:15 +02:00
echo "Variables:"
2021-03-15 18:55:42 +01:00
# Save env to file
cat $GITHUB_ENV > github.env
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'
2022-11-14 12:52:42 +01:00
uses: actions/setup-java@v3
2021-03-15 18:59:29 +01:00
with:
java-version: 11
2022-11-14 12:52:42 +01:00
distribution: temurin
2021-03-15 18:59:29 +01:00
server-id: mchv-snapshot-distribution
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
2023-05-09 10:45:22 +02:00
cache: 'maven'
2021-03-15 18:59:29 +01:00
- name: Setup Java (Release)
2023-01-03 00:40:21 +01:00
if: github.ref != 'refs/heads/develop'
2022-11-14 12:52:42 +01:00
uses: actions/setup-java@v3
2021-03-15 18:59:29 +01:00
with:
java-version: 11
2022-11-14 12:52:42 +01:00
distribution: temurin
2021-03-15 18:59:29 +01:00
server-id: mchv-release-distribution
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
2023-05-09 10:45:22 +02:00
cache: 'maven'
2021-09-14 01:55:55 +02:00
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
2023-08-29 12:33:59 +02:00
# - name: Install ubuntu 20.04 dependencies
2023-05-14 00:13:05 +02:00
# if: matrix.os == 'ubuntu-20.04'
2023-08-29 12:33:59 +02:00
# shell: bash
# run: |
# export DEBIAN_FRONTEND=noninteractive
# sudo apt-get --assume-yes update
# sudo apt-get --assume-yes install make git zlib1g-dev libssl-dev gperf php-cli cmake default-jdk clang-12 lld-12 libc++-12-dev libc++abi-12-dev libgcc-9-dev libunwind-dev libclang-common-12-dev maven
- name: Install ubuntu 20.04 dependencies (cached)
if: matrix.os == 'ubuntu-20.04'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: make git zlib1g-dev libssl-dev gperf php-cli cmake default-jdk clang-12 lld-12 libc++-12-dev libc++abi-12-dev libgcc-9-dev libunwind-dev libclang-common-12-dev maven
version: 1.0
# - name: Install ubuntu 22.04 dependencies
2023-05-14 00:13:05 +02:00
# if: matrix.os == 'ubuntu-22.04'
2023-08-29 12:33:59 +02:00
# shell: bash
# run: |
# export DEBIAN_FRONTEND=noninteractive
# sudo apt-get --assume-yes update
# sudo apt-get --assume-yes install make git zlib1g-dev libssl-dev gperf php-cli cmake default-jdk clang-14 lld-14 libc++-14-dev libc++abi-14-dev libgcc-11-dev libunwind-14-dev libclang-common-14-dev maven
- name: Install ubuntu 22.04 dependencies (cached)
if: matrix.os == 'ubuntu-22.04'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: make git zlib1g-dev libssl-dev gperf php-cli cmake default-jdk clang-14 lld-14 libc++-14-dev libc++abi-14-dev libgcc-11-dev libunwind-14-dev libclang-common-14-dev maven
version: 1.0
2023-05-13 11:15:46 +02:00
- name: Install custom dependencies
2023-08-29 12:33:59 +02:00
if: matrix.os == 'macos-12' || matrix.os == 'windows-2019'
2023-05-13 11:15:46 +02:00
shell: bash
run: |
set -xeo pipefail
echo "REVISION: $REVISION"
if [[ -f "./.github/workflows/scripts/install_deps_${SAFE_TYPE}.sh" ]]; then
2023-05-14 01:22:11 +02:00
if [[ "$GH_MATRIX_OS" == *"windows"* || "$GH_MATRIX_OS" == *"macos"* ]]; then
2023-05-14 00:05:17 +02:00
./.github/workflows/scripts/install_deps_${SAFE_TYPE}.sh
else
sudo ./.github/workflows/scripts/install_deps_${SAFE_TYPE}.sh
fi
2023-05-13 11:15:46 +02:00
fi
2023-05-10 11:07:12 +02:00
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
2021-09-14 15:03:15 +02:00
- 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
2023-05-09 14:54:15 +02:00
uses: stCarolas/setup-maven@v4.5
2021-09-14 15:03:15 +02:00
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: |
2023-05-09 12:15:15 +02:00
set -xeo pipefail
2023-05-14 01:34:16 +02:00
./vcpkg/vcpkg install gperf openssl:x64-windows-static zlib:x64-windows-static
2021-09-11 12:27:22 +02:00
shell: bash
2020-12-26 15:06:44 +01:00
- name: Build
2023-08-29 12:33:59 +02:00
if: matrix.os == 'macos-12' || matrix.os == 'windows-2019'
2020-12-26 15:06:44 +01:00
shell: bash
run: |
2023-05-09 12:15:15 +02:00
set -xeo pipefail
2020-12-26 15:06:44 +01:00
echo "REVISION: $REVISION"
2023-04-27 20:18:15 +02:00
2023-05-10 10:24:01 +02:00
source ./.github/workflows/scripts/build_${SAFE_TYPE}.sh
2023-05-10 11:07:12 +02:00
env:
2023-08-29 12:33:59 +02:00
SCCACHE_GHA_ENABLED: "on"
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v4
2023-08-29 13:29:40 +02:00
if: matrix.os == 'ubuntu-22.04'
2023-08-29 12:33:59 +02:00
with:
context: .
push: false
2023-08-29 12:43:58 +02:00
file: tdlight.arch.${{env.SSL}}.${{env.COMPILER}}.dockerfile
tags: tdlight.${{env.DEBIAN_ARCH}}.${{env.SSL}}.${{env.COMPILER}}
2023-08-29 12:33:59 +02:00
build-args: |
SCCACHE_GHA_ENABLED=on
2023-08-29 12:43:58 +02:00
ACTIONS_CACHE_URL=${{env.ACTIONS_CACHE_URL}}
ACTIONS_RUNTIME_TOKEN=${{env.ACTIONS_RUNTIME_TOKEN}}
ARCH_DEBIAN=${{env.DEBIAN_ARCH}}
ARCH_TRIPLE=${{env.TRIPLE_ARCH}}
TRIPLE_GNU=${{env.TRIPLE_GNU}}
2023-08-29 13:46:14 +02:00
NATIVE=${{env.NATIVE}}
2023-08-29 12:52:08 +02:00
DEBIAN_VERSION=${{env.DEBIAN_VERSION}}
2023-08-29 12:33:59 +02:00
cache-from: type=gha
2023-08-29 13:03:47 +02:00
cache-to: type=gha,mode=max
- name: Copy built files from docker
2023-08-29 12:33:59 +02:00
if: matrix.os == 'ubuntu-22.04'
shell: bash
run: |
set -xeo pipefail
echo "REVISION: $REVISION"
rm -rf natives
docker cp "tdlight.${DEBIAN_ARCH}.${SSL}.${COMPILER}:/out/natives" "natives"
docker cp "tdlight.${DEBIAN_ARCH}.${SSL}.${COMPILER}:/out/libtdjni.so" "libtdjni.${env.REVISION}-${env.TYPE}.so"
docker cp "tdlight.${DEBIAN_ARCH}.${SSL}.${COMPILER}:/out/tdlight-natives.jar" "natives/target-${TYPE}/tdlight-natives-${REVISION}-${TYPE}.jar"
2022-11-15 01:29:39 +01:00
- uses: actions/upload-artifact@v3
2020-12-26 12:09:32 +01:00
with:
2023-05-09 12:28:08 +02:00
name: tdlight-natives-${{env.REVISION}}-${{env.TYPE}}.jar
2023-05-09 11:46:30 +02:00
path: natives/target-${{env.TYPE}}/tdlight-natives-${{env.REVISION}}-${{env.TYPE}}.jar
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'
shell: bash
run: |
2023-05-09 12:15:15 +02:00
set -xeo pipefail
echo "REVISION: $REVISION"
2023-05-09 11:19:45 +02:00
echo "TYPE: $TYPE"
2023-05-09 11:59:15 +02:00
mvn -B -f natives/pom.xml -Drevision="$REVISION" -Dnative.type.classifier="$TYPE" clean package
2023-05-09 12:15:15 +02:00
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file -Durl=https://mvn.mchv.eu/repository/mchv-snapshot \
2023-05-09 11:59:15 +02:00
-DrepositoryId=mchv-snapshot-distribution \
-Dfile=natives/target-$TYPE/tdlight-natives-$REVISION-$TYPE.jar \
2023-05-09 12:15:15 +02:00
-Dpackaging=pom \
-DgroupId=it.tdlight \
-DartifactId=tdlight-natives \
-Dversion=$REVISION \
-Drevision=$REVISION \
2023-05-09 11:59:15 +02:00
-Dclassifier=$TYPE \
-Dnative.type.classifier="$TYPE"
2023-05-10 10:24:01 +02:00
if [[ "$TYPE" == "linux_amd64_ssl1" ]]; then
2023-05-09 12:15:15 +02:00
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file -Durl=https://mvn.mchv.eu/repository/mchv-snapshot \
2023-05-09 11:47:22 +02:00
-DrepositoryId=mchv-snapshot-distribution \
2023-05-09 11:59:15 +02:00
-Dfile=natives/.ci-friendly-pom.xml \
-Dpackaging=pom \
-DgroupId=it.tdlight \
-DartifactId=tdlight-natives \
-Dversion=$REVISION \
2023-05-09 12:15:15 +02:00
-Drevision=$REVISION \
2023-05-09 11:59:15 +02:00
-Dnative.type.classifier="$TYPE"
2023-05-09 11:46:30 +02:00
fi
2023-05-09 11:19:45 +02:00
echo "Done."
exit 0
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: |
2023-05-09 12:15:15 +02:00
set -xeo pipefail
2020-12-27 21:08:01 +01:00
echo "REVISION: $REVISION"
2023-05-09 11:19:45 +02:00
echo "TYPE: $TYPE"
2023-05-09 11:59:15 +02:00
mvn -B -f natives/pom.xml -Drevision="$REVISION" -Dnative.type.classifier="$TYPE" clean package
2023-05-09 12:15:15 +02:00
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file -Durl=https://mvn.mchv.eu/repository/mchv \
2023-05-09 11:59:15 +02:00
-DrepositoryId=mchv-release-distribution \
-Dfile=natives/target-$TYPE/tdlight-natives-$REVISION-$TYPE.jar \
2023-05-09 12:15:15 +02:00
-Dpackaging=pom \
-DgroupId=it.tdlight \
-DartifactId=tdlight-natives \
-Dversion=$REVISION \
-Drevision=$REVISION \
2023-05-09 11:59:15 +02:00
-Dclassifier=$TYPE \
-Dnative.type.classifier="$TYPE"
2023-05-10 10:24:01 +02:00
if [[ "$TYPE" == "linux_amd64_ssl1" ]]; then
2023-05-09 12:15:15 +02:00
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file -Durl=https://mvn.mchv.eu/repository/mchv \
2023-05-09 11:46:30 +02:00
-DrepositoryId=mchv-release-distribution \
2023-05-09 11:59:15 +02:00
-Dfile=natives/.ci-friendly-pom.xml \
-Dpackaging=pom \
-DgroupId=it.tdlight \
-DartifactId=tdlight-natives \
-Dversion=$REVISION \
2023-05-09 12:15:15 +02:00
-Drevision=$REVISION \
2023-05-09 11:59:15 +02:00
-Dnative.type.classifier="$TYPE"
2023-05-09 11:46:30 +02:00
fi
2023-05-09 11:19:45 +02:00
echo "Done."
exit 0
2020-12-27 21:08:01 +01:00
env:
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}