1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
vcmi/.github/workflows/github.yml

387 lines
14 KiB
YAML
Raw Normal View History

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
- develop
2022-09-19 10:31:48 +02:00
pull_request:
workflow_dispatch:
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:
build:
strategy:
matrix:
include:
2023-03-05 22:29:43 +02:00
- platform: linux-qt6
os: ubuntu-22.04
2024-01-13 13:02:12 +02:00
test: 0
2023-03-01 16:26:59 +02:00
preset: linux-clang-test
2021-07-05 19:04:17 +02:00
- platform: linux
os: ubuntu-22.04
2024-01-08 21:13:23 +02:00
test: 1
2023-03-01 16:26:59 +02:00
preset: linux-gcc-test
2023-07-11 14:30:45 +02:00
- platform: linux
os: ubuntu-20.04
test: 0
preset: linux-gcc-debug
- platform: mac-intel
2024-04-13 16:54:27 +02:00
os: macos-13
test: 0
pack: 1
2023-12-03 21:03:09 +02:00
pack_type: Release
extension: dmg
preset: macos-conan-ninja-release
conan_profile: macos-intel
2023-02-26 14:53:51 +02:00
conan_options: --options with_apple_system_libs=True
artifact_platform: intel
- platform: mac-arm
2024-04-13 16:54:27 +02:00
os: macos-13
test: 0
pack: 1
2023-12-03 21:03:09 +02:00
pack_type: Release
extension: dmg
preset: macos-arm-conan-ninja-release
conan_profile: macos-arm
2023-02-26 14:53:51 +02:00
conan_options: --options with_apple_system_libs=True
artifact_platform: arm
2022-08-11 12:14:02 +02:00
- platform: ios
2024-04-13 16:54:27 +02:00
os: macos-13
2022-08-11 12:14:02 +02:00
test: 0
pack: 1
2023-12-03 21:03:09 +02:00
pack_type: Release
2022-08-11 12:14:02 +02:00
extension: ipa
preset: ios-release-conan-ccache
2022-10-13 12:09:15 +02:00
conan_profile: ios-arm64
2023-02-26 14:53:51 +02:00
conan_options: --options with_apple_system_libs=True
2021-07-27 20:26:17 +02:00
- platform: msvc
os: windows-latest
test: 0
pack: 1
2023-12-03 21:03:09 +02:00
pack_type: RelWithDebInfo
2021-07-27 20:26:17 +02:00
extension: exe
preset: windows-msvc-release-ccache
- platform: mingw
os: ubuntu-22.04
test: 0
pack: 1
2023-12-03 21:03:09 +02:00
pack_type: Release
extension: exe
cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
cmake_args: -G Ninja
preset: windows-mingw-conan-linux
conan_profile: mingw64-linux.jinja
- platform: mingw-32
os: ubuntu-22.04
test: 0
pack: 1
pack_type: Release
extension: exe
cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
cmake_args: -G Ninja
preset: windows-mingw-conan-linux
conan_profile: mingw32-linux.jinja
2023-02-26 14:53:51 +02:00
- platform: android-32
os: ubuntu-22.04
extension: apk
preset: android-conan-ninja-release
conan_profile: android-32
conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
artifact_platform: armeabi-v7a
- platform: android-64
os: ubuntu-22.04
extension: apk
preset: android-conan-ninja-release
conan_profile: android-64
conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
2023-04-15 10:47:24 +02:00
artifact_platform: arm64-v8a
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:
- uses: actions/checkout@v4
2021-07-05 19:04:17 +02:00
with:
submodules: recursive
- name: Ensure LF line endings
if: ${{ startsWith(matrix.preset, 'linux-clang-test') }}
run: |
find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
-o -path ./osx -prune -o -type f \
2023-11-16 23:42:20 +02:00
-not -name '*.png' -and -not -name '*.vcxproj*' -and -not -name '*.props' -and -not -name '*.wav' -and -not -name '*.webm' -and -not -name '*.ico' -and -not -name '*.bat' -print0 | \
{ ! xargs -0 grep -l -z -P '\r\n'; }
2023-09-15 22:55:48 +02:00
- name: Validate JSON
2023-09-16 01:52:04 +02:00
# the Python yaml module doesn't seem to work on mac-arm
# also, running it on multiple presets is redundant and slightly increases already long CI built times
if: ${{ startsWith(matrix.preset, 'linux-clang-test') }}
2023-09-15 22:55:48 +02:00
run: |
pip3 install jstyleson
python3 CI/linux-qt6/validate_json.py
2023-09-15 22:55:48 +02:00
2021-07-05 19:04:17 +02:00
- 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:
2021-07-27 20:26:17 +02:00
VCMI_BUILD_PLATFORM: x64
2023-10-29 00:13:36 +02:00
# ensure the ccache for each PR is separate so they don't interfere with each other
# fall back to ccache of the vcmi/vcmi repo if no PR-specific ccache is found
- name: ccache for PRs
2023-09-29 23:55:12 +02:00
uses: hendrikmuhs/ccache-action@v1.2
2023-10-29 00:13:36 +02:00
if: ${{ github.event.number != '' }}
2023-09-29 23:55:12 +02:00
with:
2023-10-29 00:13:36 +02:00
key: ${{ matrix.preset }}-PR-${{ github.event.number }}
restore-keys: |
${{ matrix.preset }}-PR-${{ github.event.number }}
${{ matrix.preset }}-no-PR
# actual cache takes up less space, at most ~1 GB
max-size: "5G"
verbose: 2
- name: ccache for everything but PRs
2023-10-29 00:13:36 +02:00
uses: hendrikmuhs/ccache-action@v1.2
2024-04-26 18:55:14 +02:00
if: ${{ (github.repository == 'vcmi/vcmi' && github.event.number == '' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master')) || github.repository != 'vcmi/vcmi' }}
2023-10-29 00:13:36 +02:00
with:
key: ${{ matrix.preset }}-no-PR
restore-keys: |
${{ matrix.preset }}-no-PR
# actual cache takes up less space, at most ~1 GB
max-size: "5G"
verbose: 2
2023-09-29 23:55:12 +02:00
- name: Prepare Heroes 3 data
2024-01-08 21:13:23 +02:00
env:
HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
2024-01-13 13:50:47 +02:00
if: ${{ env.HEROES_3_DATA_PASSWORD != '' && matrix.test == 1 }}
2024-01-08 21:13:23 +02:00
run: |
wget --progress=dot:giga https://github.com/vcmi-mods/vcmi-test-data/releases/download/v1.0/h3_assets.zip
7za x h3_assets.zip -p$HEROES_3_DATA_PASSWORD
2024-01-08 21:13:23 +02:00
mkdir -p ~/.local/share/vcmi/
mv h3_assets/* ~/.local/share/vcmi/
2024-01-08 21:13:23 +02:00
- uses: actions/setup-python@v5
if: "${{ matrix.conan_profile != '' }}"
with:
python-version: '3.10'
2023-10-29 00:13:36 +02:00
- name: Conan setup
if: "${{ matrix.conan_profile != '' }}"
run: |
2023-02-22 11:57:44 +02:00
pip3 install 'conan<2.0'
conan profile new default --detect
conan install . \
--install-folder=conan-generated \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=CI/conan/${{ matrix.conan_profile }} \
2023-02-26 14:53:51 +02:00
${{ matrix.conan_options }}
env:
GENERATE_ONLY_BUILT_CONFIG: 1
2021-07-05 19:04:17 +02:00
- name: Build Number
run: |
2021-07-27 20:26:17 +02:00
source '${{github.workspace}}/CI/get_package_name.sh'
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
echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
2021-07-05 19:04:17 +02:00
env:
PULL_REQUEST: ${{ github.event.pull_request.number }}
- name: Configure
2023-09-29 23:55:12 +02:00
run: |
if [[ ${{matrix.preset}} == linux-gcc-test ]]; then GCC13=1; fi
cmake -DENABLE_CCACHE:BOOL=ON --preset ${{ matrix.preset }} ${GCC13:+-DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13}
2023-09-29 23:55:12 +02:00
- name: Build
2021-07-27 20:26:17 +02:00
run: |
cmake --build --preset ${{matrix.preset}}
2021-07-05 19:04:17 +02:00
- name: Test
2024-01-13 13:50:47 +02:00
env:
HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
if: ${{ env.HEROES_3_DATA_PASSWORD != '' && matrix.test == 1 }}
2021-07-05 19:04:17 +02:00
run: |
ctest --preset ${{matrix.preset}}
- name: Kill XProtect to work around CPack issue on macOS
if: ${{ startsWith(matrix.platform, 'mac') }}
run: |
# Cf. https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
echo Killing...; sudo pkill -9 XProtect >/dev/null || true;
echo "Waiting..."; counter=0; while pgrep XProtect && ((counter < 20)); do sleep 3; ((counter++)); done
pgrep XProtect || true
- name: Pack
2021-07-05 19:04:17 +02:00
id: cpack
if: ${{ matrix.pack == 1 }}
2021-07-05 19:04:17 +02:00
run: |
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
2024-01-23 15:07:32 +02:00
counter=0; until "$CPACK_PATH" -C ${{matrix.pack_type}} ${{ matrix.cpack_args }} || ((counter > 20)); do sleep 3; ((counter++)); done
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 }}'.*)"
rm -rf _CPack_Packages
- name: Create Android package
2023-02-26 14:53:51 +02:00
if: ${{ startsWith(matrix.platform, 'android') }}
run: |
cd android
./gradlew assembleDaily --info
echo ANDROID_APK_PATH="$(ls ${{ github.workspace }}/android/vcmi-app/build/outputs/apk/daily/*.${{ matrix.extension }})" >> $GITHUB_ENV
2021-07-05 19:04:17 +02:00
- name: Additional logs
if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'msvc' }}
2021-07-05 19:04:17 +02:00
run: |
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'
- name: Artifacts
if: ${{ matrix.pack == 1 }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
path: |
${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
2023-04-15 10:47:24 +02:00
2023-02-26 14:53:51 +02:00
- name: Android artifacts
if: ${{ startsWith(matrix.platform, 'android') }}
uses: actions/upload-artifact@v4
2023-02-26 14:53:51 +02:00
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
path: |
${{ env.ANDROID_APK_PATH }}
2023-12-03 20:20:59 +02:00
- name: Symbols
if: ${{ matrix.platform == 'msvc' }}
uses: actions/upload-artifact@v4
2023-12-03 20:20:59 +02:00
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
path: |
${{github.workspace}}/**/*.pdb
2023-04-15 10:47:24 +02:00
- name: Android JNI ${{matrix.platform}}
if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v4
2023-04-15 10:47:24 +02:00
with:
name: Android JNI ${{matrix.platform}}
path: |
${{ github.workspace }}/android/vcmi-app/src/main/jniLibs
- name: Upload build
2024-01-13 19:37:42 +02:00
if: ${{ (matrix.pack == 1 || startsWith(matrix.platform, 'android')) && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/features/')) && matrix.platform != 'msvc' && matrix.platform != 'mingw-32' }}
continue-on-error: true
run: |
2023-03-06 20:29:46 +02:00
if cd '${{github.workspace}}/android/vcmi-app/build/outputs/apk/daily' ; then
mv '${{ env.ANDROID_APK_PATH }}' "$VCMI_PACKAGE_FILE_NAME.${{ matrix.extension }}"
else
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
fi
2021-07-27 20:26:17 +02:00
source '${{github.workspace}}/CI/upload_package.sh'
env:
DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
PACKAGE_EXTENSION: ${{ matrix.extension }}
2023-04-15 10:47:24 +02:00
# copy-pasted mostly
bundle_release:
needs: build
if: always() && github.ref == 'refs/heads/master'
strategy:
matrix:
include:
- platform: android-32
os: ubuntu-22.04
extension: aab
preset: android-conan-ninja-release
conan_profile: android-32
conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
artifact_platform: aab
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
2023-04-15 10:47:24 +02:00
with:
submodules: recursive
- name: Dependencies
run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
env:
VCMI_BUILD_PLATFORM: x64
- uses: actions/setup-python@v5
2023-04-15 10:47:24 +02:00
if: "${{ matrix.conan_profile != '' }}"
with:
python-version: '3.10'
2023-04-15 10:47:24 +02:00
- name: Conan setup
if: "${{ matrix.conan_profile != '' }}"
run: |
pip3 install 'conan<2.0'
conan profile new default --detect
conan install . \
--install-folder=conan-generated \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=CI/conan/${{ matrix.conan_profile }} \
${{ matrix.conan_options }}
env:
GENERATE_ONLY_BUILT_CONFIG: 1
- name: Build Number
run: |
source '${{github.workspace}}/CI/get_package_name.sh'
if [ '${{ matrix.artifact_platform }}' ]; then
VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
fi
echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
2023-04-15 10:47:24 +02:00
env:
PULL_REQUEST: ${{ github.event.pull_request.number }}
- name: CMake Preset
run: |
cmake --preset ${{ matrix.preset }}
- name: Build Preset
run: |
cmake --build --preset ${{matrix.preset}}
- name: Download libs x64
uses: actions/download-artifact@v4
2023-04-15 10:47:24 +02:00
with:
name: Android JNI android-64
path: ${{ github.workspace }}/android/vcmi-app/src/main/jniLibs/
- name: Create Android package
2023-04-15 10:47:24 +02:00
run: |
cd android
./gradlew bundleRelease --info
echo ANDROID_APK_PATH="$(ls ${{ github.workspace }}/android/vcmi-app/build/outputs/bundle/release/*.aab)" >> $GITHUB_ENV
env:
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Android artifacts
uses: actions/upload-artifact@v4
2023-04-15 10:47:24 +02:00
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
path: |
${{ env.ANDROID_APK_PATH }}