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

210 lines
7.8 KiB
YAML
Raw Normal View History

2021-03-15 18:55:42 +01:00
name: Docker 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-04-27 20:18:15 +02:00
name: Build (${{ 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:
# todo: re-enable
#- { os: ubuntu-20.04, type: "linux-386-ssl1" }
- { os: ubuntu-20.04, type: "linux-amd64-ssl1" }
- { os: ubuntu-20.04, type: "linux-arm64-ssl1" }
#- { os: ubuntu-20.04, type: "linux-s390x-ssl1" }
#- { os: ubuntu-20.04, type: "linux-ppc64le-ssl1" }
- { os: ubuntu-22.04, type: "linux-amd64-ssl3" }
#- { os: ubuntu-22.04, type: "linux-arm64-ssl3" }
#- { os: windows-2019, type: "windows-amd64", vcpkgCommitId: "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", triplet: "x64-windows-static" }
#- { os: macos-12, type: "macos-amd64" }
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
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,')
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 }}
SAFE_TYPE=${TYPE///} # linux-amd64 -> linux-amd64
2023-04-27 20:18:15 +02:00
REVISION=${{ github.run_number }}
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
echo "SSL_TYPE=$SSL_TYPE" >> $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"
echo "ssl type: $SSL_TYPE"
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-09-26 19:43:12 +02:00
- name: Cache Maven
2022-11-15 01:29:39 +01:00
uses: actions/cache@v3
2021-09-26 19:43:12 +02:00
with:
path: ~/.m2/repository
2023-04-27 20:18:15 +02:00
key: ${{ runner.os }}-v3-maven-${{ env.SAFE_TYPE }}-${{ hashFiles('**/pom.xml') }}
2021-09-26 19:43:12 +02:00
restore-keys: |
2023-04-27 20:18:15 +02:00
${{ runner.os }}-v3-maven-${{ env.SAFE_TYPE }}-
2021-09-26 19:43:12 +02:00
- name: Cache packages cache
2022-11-15 01:29:39 +01:00
uses: actions/cache@v3
2021-09-26 19:43:12 +02:00
with:
path: ~/tdlight-java-natives/tdlight-java-natives/.cache
2023-04-27 20:18:15 +02:00
key: ${{ runner.os }}-v3-packages-${{ env.SAFE_TYPE }}-${{ github.sha }}
2021-09-26 19:43:12 +02:00
restore-keys: |
2023-04-27 20:18:15 +02:00
${{ runner.os }}-v3-packages-${{ env.SAFE_TYPE }}-
2021-09-26 19:43:12 +02:00
- name: Cache ccache
2022-11-15 01:29:39 +01:00
uses: actions/cache@v3
2021-09-26 19:43:12 +02:00
with:
path: ~/.ccache
2023-04-27 20:18:15 +02:00
key: ${{ runner.os }}-v2-ccache-${{ env.SAFE_TYPE }}-${{ github.sha }}
2021-09-26 19:43:12 +02:00
restore-keys: |
2023-04-27 20:18:15 +02:00
${{ runner.os }}-v2-ccache-${{ env.SAFE_TYPE }}-
2021-03-15 18:55:42 +01:00
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
- 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
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
- name: Install ubuntu 20.04 dependencies
if: matrix.os == 'ubuntu-20.04'
2023-05-07 14:50:02 +02:00
uses: awalsh128/cache-apt-pkgs-action@latest
with:
2023-05-07 15:35:26 +02:00
packages: make git zlib1g-dev libssl-dev gperf php-cli cmake default-jdk clang-10 libc++-dev libc++abi-dev ccache
version: 1.0
- name: Install ubuntu 22.04 dependencies
if: matrix.os == 'ubuntu-22.04'
2023-05-07 14:50:02 +02:00
uses: awalsh128/cache-apt-pkgs-action@latest
with:
2023-05-07 15:35:26 +02:00
packages: make git zlib1g-dev libssl-dev gperf php-cli cmake default-jdk clang-14 libc++-dev libc++abi-dev ccache
version: 1.0
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
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
shell: bash
run: |
echo "REVISION: $REVISION"
2023-04-27 20:18:15 +02:00
source ./.github/workflows/scripts/build-${SAFE_TYPE}.sh
- 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
shell: bash
2020-12-27 19:41:19 +01:00
run: echo "::set-output name=file::$(ls generated/target/tdli*-natives-*.jar)"
2022-11-15 01:29:39 +01:00
- uses: actions/upload-artifact@v3
2020-12-26 12:09:32 +01:00
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'
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 }}
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"
echo "SSL TYPE: $SSL_TYPE"
2020-12-27 21:08:01 +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 }}