2021-07-27 20:26:17 +02:00
|
|
|
name: VCMI
|
2021-07-05 19:04:17 +02:00
|
|
|
|
2021-07-27 20:26:17 +02:00
|
|
|
on:
|
2022-09-19 10:31:48 +02:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- features/*
|
2022-12-02 13:16:22 +02:00
|
|
|
- beta
|
2022-12-23 10:10:05 +02:00
|
|
|
- master
|
2022-09-19 10:31:48 +02:00
|
|
|
pull_request:
|
2022-09-20 11:04:00 +02:00
|
|
|
schedule:
|
|
|
|
- cron: '0 2 * * *'
|
2022-09-20 11:04:15 +02:00
|
|
|
workflow_dispatch:
|
2022-09-20 11:04:00 +02:00
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
env:
|
|
|
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
2022-05-27 09:11:44 +02:00
|
|
|
BUILD_TYPE: Release
|
2021-07-05 19:04:17 +02:00
|
|
|
|
|
|
|
jobs:
|
2022-09-20 11:04:00 +02:00
|
|
|
check_last_build:
|
|
|
|
if: github.event.schedule != ''
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
skip_build: ${{ steps.check_if_built.outputs.skip_build }}
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
steps:
|
|
|
|
- name: Get repo name
|
|
|
|
id: get_repo_name
|
|
|
|
run: echo "::set-output name=value::${GITHUB_REPOSITORY#*/}"
|
|
|
|
- name: Get last successful build for ${{ github.sha }}
|
|
|
|
uses: octokit/request-action@v2.1.0
|
|
|
|
id: get_last_scheduled_run
|
|
|
|
with:
|
|
|
|
route: GET /repos/{owner}/{repo}/actions/runs
|
|
|
|
owner: ${{ github.repository_owner }}
|
|
|
|
repo: ${{ steps.get_repo_name.outputs.value }}
|
|
|
|
status: success
|
|
|
|
per_page: 1
|
|
|
|
head_sha: ${{ github.sha }}
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Check if successful build of the current commit exists
|
|
|
|
id: check_if_built
|
|
|
|
run: |
|
|
|
|
if [ ${{ fromJson(steps.get_last_scheduled_run.outputs.data).total_count }} -gt 0 ]; then
|
|
|
|
echo '::set-output name=skip_build::1'
|
|
|
|
else
|
|
|
|
echo '::set-output name=skip_build::0'
|
|
|
|
fi
|
|
|
|
- name: Cancel current run
|
|
|
|
if: steps.check_if_built.outputs.skip_build == 1
|
|
|
|
uses: octokit/request-action@v2.1.0
|
|
|
|
with:
|
|
|
|
route: POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel
|
|
|
|
owner: ${{ github.repository_owner }}
|
|
|
|
repo: ${{ steps.get_repo_name.outputs.value }}
|
|
|
|
run_id: ${{ github.run_id }}
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Wait for the run to be cancelled
|
|
|
|
if: steps.check_if_built.outputs.skip_build == 1
|
|
|
|
run: sleep 60
|
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
build:
|
2022-09-20 11:04:00 +02:00
|
|
|
needs: check_last_build
|
|
|
|
if: always() && needs.check_last_build.skip_build != 1
|
2021-07-05 19:04:17 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- platform: linux
|
|
|
|
os: ubuntu-20.04
|
|
|
|
test: 0
|
2022-05-26 07:55:20 +02:00
|
|
|
preset: linux-clang-release
|
2021-07-05 19:04:17 +02:00
|
|
|
- platform: linux
|
|
|
|
os: ubuntu-20.04
|
|
|
|
test: 0
|
2022-05-26 07:55:20 +02:00
|
|
|
preset: linux-gcc-release
|
2022-08-30 16:29:00 +02:00
|
|
|
- platform: mac-intel
|
|
|
|
os: macos-12
|
2022-03-05 16:04:13 +02:00
|
|
|
test: 0
|
|
|
|
pack: 1
|
|
|
|
extension: dmg
|
2022-08-30 16:29:00 +02:00
|
|
|
preset: macos-conan-ninja-release
|
|
|
|
conan_profile: macos-intel
|
|
|
|
artifact_platform: intel
|
|
|
|
- platform: mac-arm
|
|
|
|
os: macos-12
|
|
|
|
test: 0
|
|
|
|
pack: 1
|
|
|
|
extension: dmg
|
|
|
|
preset: macos-arm-conan-ninja-release
|
|
|
|
conan_profile: macos-arm
|
|
|
|
artifact_platform: arm
|
2022-08-11 12:14:02 +02:00
|
|
|
- platform: ios
|
|
|
|
os: macos-12
|
|
|
|
test: 0
|
|
|
|
pack: 1
|
|
|
|
extension: ipa
|
2022-10-13 12:09:15 +02:00
|
|
|
preset: ios-release-conan
|
|
|
|
conan_profile: ios-arm64
|
2021-07-05 19:04:17 +02:00
|
|
|
- platform: mxe
|
|
|
|
os: ubuntu-20.04
|
|
|
|
mxe: i686-w64-mingw32.shared
|
|
|
|
test: 0
|
2021-07-12 21:00:29 +02:00
|
|
|
pack: 1
|
2021-07-20 09:41:04 +02:00
|
|
|
cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
|
2021-07-12 21:00:29 +02:00
|
|
|
extension: exe
|
2021-07-27 20:26:17 +02:00
|
|
|
cmake_args: -G Ninja
|
|
|
|
- platform: msvc
|
|
|
|
os: windows-latest
|
|
|
|
test: 0
|
|
|
|
pack: 1
|
|
|
|
extension: exe
|
2022-05-26 07:55:20 +02:00
|
|
|
preset: windows-msvc-release
|
2021-07-05 19:04:17 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
2021-07-27 20:26:17 +02:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
2021-07-05 19:04:17 +02:00
|
|
|
|
|
|
|
steps:
|
2022-05-26 07:55:20 +02:00
|
|
|
- uses: actions/checkout@v3
|
2021-07-05 19:04:17 +02:00
|
|
|
with:
|
|
|
|
submodules: recursive
|
|
|
|
|
|
|
|
- name: Dependencies
|
2021-07-27 20:26:17 +02:00
|
|
|
run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
|
2021-07-05 19:04:17 +02:00
|
|
|
env:
|
|
|
|
MXE_TARGET: ${{ matrix.mxe }}
|
2021-07-27 20:26:17 +02:00
|
|
|
VCMI_BUILD_PLATFORM: x64
|
2022-05-26 07:55:20 +02:00
|
|
|
|
2022-11-02 10:07:20 +02:00
|
|
|
- uses: actions/setup-python@v4
|
|
|
|
if: "${{ matrix.conan_profile != '' }}"
|
|
|
|
with:
|
|
|
|
python-version: '3.10'
|
2022-08-30 16:29:00 +02:00
|
|
|
- name: Conan setup
|
|
|
|
if: "${{ matrix.conan_profile != '' }}"
|
|
|
|
run: |
|
|
|
|
pip3 install conan
|
|
|
|
conan profile new default --detect
|
|
|
|
conan install . \
|
|
|
|
--install-folder=conan-generated \
|
|
|
|
--no-imports \
|
|
|
|
--build=never \
|
|
|
|
--profile:build=default \
|
2022-10-18 09:07:47 +02:00
|
|
|
--profile:host=CI/conan/${{ matrix.conan_profile }} \
|
|
|
|
--options with_apple_system_libs=True
|
2022-10-15 14:03:27 +02:00
|
|
|
env:
|
|
|
|
GENERATE_ONLY_BUILT_CONFIG: 1
|
2022-08-30 16:29:00 +02:00
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
- name: Git branch name
|
|
|
|
id: git-branch-name
|
|
|
|
uses: EthanSK/git-branch-name-action@v1
|
|
|
|
|
|
|
|
- name: Build Number
|
|
|
|
run: |
|
2021-07-27 20:26:17 +02:00
|
|
|
source '${{github.workspace}}/CI/get_package_name.sh'
|
2022-08-30 16:29:00 +02:00
|
|
|
if [ '${{ matrix.artifact_platform }}' ]; then
|
|
|
|
VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
|
|
|
|
fi
|
2021-07-05 19:04:17 +02:00
|
|
|
echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
|
|
|
|
echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
|
2022-12-23 10:10:05 +02:00
|
|
|
echo VCMI_PACKAGE_GITVERSION="$VCMI_PACKAGE_GITVERSION" >> $GITHUB_ENV
|
2021-07-05 19:04:17 +02:00
|
|
|
env:
|
|
|
|
PULL_REQUEST: ${{ github.event.pull_request.number }}
|
|
|
|
|
|
|
|
- name: Configure CMake
|
2022-05-26 07:55:20 +02:00
|
|
|
if: "${{ matrix.preset == '' }}"
|
2021-07-05 19:04:17 +02:00
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
mkdir -p '${{github.workspace}}/out/build/${{matrix.preset}}'
|
|
|
|
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
|
|
|
|
cmake \
|
|
|
|
../.. -GNinja \
|
|
|
|
${{matrix.cmake_args}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
|
2021-07-05 19:04:17 +02:00
|
|
|
-DENABLE_TEST=${{matrix.test}} \
|
2022-12-30 14:33:55 +02:00
|
|
|
-DENABLE_STRICT_COMPILATION=ON \
|
2021-07-05 19:04:17 +02:00
|
|
|
-DPACKAGE_NAME_SUFFIX:STRING="$VCMI_PACKAGE_NAME_SUFFIX" \
|
2022-12-23 10:10:05 +02:00
|
|
|
-DPACKAGE_FILE_NAME:STRING="$VCMI_PACKAGE_FILE_NAME" \
|
|
|
|
-DENABLE_GITVERSION="$VCMI_PACKAGE_GITVERSION"
|
2021-07-05 19:04:17 +02:00
|
|
|
env:
|
|
|
|
CC: ${{ matrix.cc }}
|
|
|
|
CXX: ${{ matrix.cxx }}
|
|
|
|
|
2022-05-26 07:55:20 +02:00
|
|
|
- name: CMake Preset
|
|
|
|
if: "${{ matrix.preset != '' }}"
|
|
|
|
run: |
|
|
|
|
cmake --preset ${{ matrix.preset }}
|
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
- name: Build
|
2022-05-26 07:55:20 +02:00
|
|
|
if: "${{ matrix.preset == '' }}"
|
2021-07-05 19:04:17 +02:00
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
cmake --build '${{github.workspace}}/out/build/${{matrix.preset}}'
|
|
|
|
|
|
|
|
- name: Build Preset
|
|
|
|
if: "${{ matrix.preset != '' }}"
|
2021-07-27 20:26:17 +02:00
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
cmake --build --preset ${{matrix.preset}}
|
2021-07-05 19:04:17 +02:00
|
|
|
|
|
|
|
- name: Test
|
2022-05-26 07:55:20 +02:00
|
|
|
if: ${{ matrix.test == 1 && matrix.preset != ''}}
|
2021-07-05 19:04:17 +02:00
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
ctest --preset ${{matrix.preset}}
|
|
|
|
|
2021-07-12 21:00:29 +02:00
|
|
|
- name: Pack
|
2021-07-05 19:04:17 +02:00
|
|
|
id: cpack
|
2021-07-12 21:00:29 +02:00
|
|
|
if: ${{ matrix.pack == 1 }}
|
2021-07-05 19:04:17 +02:00
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
|
2021-09-05 12:37:59 +02:00
|
|
|
CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
|
2022-05-26 07:55:20 +02:00
|
|
|
"$CPACK_PATH" -C ${{env.BUILD_TYPE}} ${{ matrix.cpack_args }}
|
2022-08-11 12:14:02 +02:00
|
|
|
test -f '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' \
|
|
|
|
&& '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' '${{github.workspace}}' "$(ls '${{ env.VCMI_PACKAGE_FILE_NAME }}'.*)"
|
2022-05-26 07:55:20 +02:00
|
|
|
rm -rf _CPack_Packages
|
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
- name: Additional logs
|
|
|
|
if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'mxe' }}
|
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/project.nsi'
|
|
|
|
cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/NSISOutput.log'
|
|
|
|
|
2021-07-12 21:00:29 +02:00
|
|
|
- name: Artifacts
|
|
|
|
if: ${{ matrix.pack == 1 }}
|
2022-05-26 07:55:20 +02:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-07-12 21:00:29 +02:00
|
|
|
with:
|
|
|
|
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
|
2022-05-26 07:55:20 +02:00
|
|
|
path: |
|
|
|
|
${{github.workspace}}/**/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
|
|
|
|
|
2021-07-12 21:00:29 +02:00
|
|
|
- name: Upload build
|
2022-12-23 10:10:05 +02:00
|
|
|
if: ${{ matrix.pack == 1 && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/features/')) && matrix.platform != 'msvc' }}
|
2021-07-12 21:00:29 +02:00
|
|
|
run: |
|
2022-05-26 07:55:20 +02:00
|
|
|
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
|
2021-07-27 20:26:17 +02:00
|
|
|
source '${{github.workspace}}/CI/upload_package.sh'
|
2021-07-12 21:00:29 +02:00
|
|
|
env:
|
|
|
|
DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
|
|
|
|
PACKAGE_EXTENSION: ${{ matrix.extension }}
|
2022-05-26 07:55:20 +02:00
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
- uses: act10ns/slack@v1
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|
|
|
|
channel: '#notifications'
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
|
|
if: always()
|
2022-05-26 07:55:20 +02:00
|
|
|
|
2021-11-15 08:38:34 +02:00
|
|
|
- name: Trigger Android
|
|
|
|
uses: peter-evans/repository-dispatch@v1
|
2022-12-23 14:40:52 +02:00
|
|
|
if: ${{ (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master') && matrix.platform == 'mxe' }}
|
2021-11-15 08:38:34 +02:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.VCMI_ANDROID_ACCESS_TOKEN }}
|
|
|
|
repository: vcmi/vcmi-android
|
|
|
|
event-type: vcmi
|