| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- name: VCMI
- on:
- push:
- branches:
- - beta
- - master
- - develop
- pull_request:
- workflow_dispatch:
- jobs:
- build:
- name: Build (${{ matrix.platform }})
- strategy:
- matrix:
- include:
- - platform: mac-intel
- os: macos-13
- pack: 1
- upload: 1
- pack_type: Release
- extension: dmg
- before_install: macos.sh
- preset: macos-conan-ninja-release
- conan_profile: macos-intel
- conan_prebuilts: dependencies-mac-intel
- conan_options: --options with_apple_system_libs=True
- artifact_platform: intel
- - platform: mac-arm
- os: macos-13
- pack: 1
- upload: 1
- pack_type: Release
- extension: dmg
- before_install: macos.sh
- preset: macos-arm-conan-ninja-release
- conan_profile: macos-arm
- conan_prebuilts: dependencies-mac-arm
- conan_options: --options with_apple_system_libs=True
- artifact_platform: arm
- - platform: ios
- os: macos-13
- pack: 1
- upload: 1
- pack_type: Release
- extension: ipa
- before_install: macos.sh
- preset: ios-release-conan-ccache
- conan_profile: ios-arm64
- conan_prebuilts: dependencies-ios
- conan_options: --options with_apple_system_libs=True
- - platform: msvc-x64
- arch: x64
- os: windows-2025
- pack: 1
- upload: 0
- pack_type: RelWithDebInfo
- extension: zip
- before_install: msvc.sh
- preset: windows-msvc-release
- artifact_platform: x64
- - platform: msvc-x86
- arch: x86
- os: windows-2025
- pack: 1
- upload: 0
- pack_type: RelWithDebInfo
- extension: zip
- before_install: msvc.sh
- preset: windows-msvc-release-x86
- artifact_platform: x86
- - platform: msvc-arm64
- arch: arm64
- os: windows-11-arm
- pack: 1
- upload: 0
- pack_type: RelWithDebInfo
- extension: zip
- before_install: msvc.sh
- preset: windows-msvc-release-arm64
- artifact_platform: arm64
- - platform: mingw_x86_64
- os: ubuntu-24.04
- pack: 1
- pack_type: Release
- extension: zip
- cmake_args: -G Ninja
- before_install: mingw.sh
- preset: windows-mingw-conan-linux
- conan_profile: mingw64-linux.jinja
- conan_prebuilts: dependencies-mingw-x86-64
- - platform: mingw_x86
- os: ubuntu-24.04
- pack: 1
- pack_type: Release
- extension: zip
- cmake_args: -G Ninja
- before_install: mingw.sh
- preset: windows-mingw-conan-linux
- conan_profile: mingw32-linux.jinja
- conan_prebuilts: dependencies-mingw-x86
- - platform: android-32
- os: ubuntu-24.04
- upload: 1
- extension: apk
- preset: android-conan-ninja-release
- before_install: android.sh
- conan_profile: android-32-ndk
- conan_prebuilts: dependencies-android-armeabi-v7a
- artifact_platform: armeabi-v7a
- - platform: android-64
- os: ubuntu-24.04
- upload: 1
- extension: apk
- preset: android-conan-ninja-release
- before_install: android.sh
- conan_profile: android-64-ndk
- conan_prebuilts: dependencies-android-arm64-v8a
- artifact_platform: arm64-v8a
- runs-on: ${{ matrix.os }}
- defaults:
- run:
- shell: bash
- steps:
- - name: Checkout repository
- uses: actions/checkout@v5
- with:
- submodules: recursive
- - name: Prepare CI
- if: "${{ matrix.before_install != '' }}"
- run: source '${{github.workspace}}/CI/before_install/${{matrix.before_install}}'
- - name: Install Conan Dependencies
- if: "${{ matrix.conan_prebuilts != '' }}"
- run: source '${{github.workspace}}/CI/install_conan_dependencies.sh' '${{matrix.conan_prebuilts}}'
- - name: Install vcpkg Dependencies
- if: ${{ startsWith(matrix.platform, 'msvc') }}
- run: source '${{github.workspace}}/CI/install_vcpkg_dependencies.sh' '${{matrix.platform}}'
- # 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: Install ccache for PRs
- uses: hendrikmuhs/[email protected]
- if: ${{ github.event.number != '' && !startsWith(matrix.platform, 'msvc') }}
- with:
- key: ${{ matrix.platform }}-PR-${{ github.event.number }}
- restore-keys: |
- ${{ matrix.platform }}-PR-${{ github.event.number }}
- ${{ matrix.platform }}-branch-${{ github.base_ref }}
- max-size: "5G"
- verbose: 2
- - name: Install ccache for branch builds
- uses: hendrikmuhs/[email protected]
- if: ${{ github.event.number == '' && !startsWith(matrix.platform, 'msvc')}}
- with:
- key: ${{ matrix.platform }}-${{ github.ref_name }}
- restore-keys: |
- ${{ matrix.platform }}-branch-${{ github.ref_name }}
- max-size: "5G"
- verbose: 2
- - name: Install Conan
- if: "${{ matrix.conan_profile != '' }}"
- run: pipx install 'conan<2.0'
- - name: Install Conan profile
- if: "${{ matrix.conan_profile != '' }}"
- run: |
- 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
- # Can't be set in Gradle project
- - name: Configure enableUncompressedNativeLibs
- if: ${{ startsWith(matrix.platform, 'android') }}
- run: mkdir -p ~/.gradle && echo "android.bundle.enableUncompressedNativeLibs=true" > ~/.gradle/gradle.properties
- # Workaround for gradle not discovering SDK that was installed via conan
- - name: Find Android NDK
- if: ${{ startsWith(matrix.platform, 'android') }}
- run: sudo ln -s -T /home/runner/.conan/data/android-ndk/r25c/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin /usr/local/lib/android/sdk/ndk/25.2.9519653
- - name: Install Java
- uses: actions/setup-java@v4
- if: ${{ startsWith(matrix.platform, 'android') }}
- with:
- distribution: 'temurin'
- java-version: '17'
- # a hack to build ID for x64 build in order for Google Play to allow upload of both 32 and 64 bit builds
- - name: Bump Android x64 build ID
- if: ${{ matrix.platform == 'android-64' }}
- run: perl -i -pe 's/versionCode (\d+)/$x=$1+1; "versionCode $x"/e' android/vcmi-app/build.gradle
- - 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_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
- echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
- echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
- env:
- PULL_REQUEST: ${{ github.event.pull_request.number }}
- - name: Configure
- run: |
- if [[ (${{matrix.preset}} == android-conan-ninja-release) && (${{github.ref}} != 'refs/heads/master') ]]
- then
- cmake -DENABLE_CCACHE:BOOL=ON -DANDROID_GRADLE_PROPERTIES="applicationIdSuffix=.daily;signingConfig=dailySigning;applicationLabel=VCMI daily;applicationVariant=daily" --preset ${{ matrix.preset }}
- elif ${{startsWith(matrix.platform, 'msvc') }}
- then
- cmake --preset ${{ matrix.preset }}
- else
- cmake -DENABLE_CCACHE:BOOL=ON --preset ${{ matrix.preset }}
- fi
- - name: Build
- run: |
- cmake --build --preset ${{matrix.preset}}
- env:
- ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
- ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- - 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
- id: cpack
- if: ${{ matrix.pack == 1 }}
- run: |
- cd '${{github.workspace}}/out/build/${{matrix.preset}}'
-
- # Workaround for CPack bug on macOS 13
- counter=0
- until cpack -C ${{matrix.pack_type}} || ((counter > 20)); do
- sleep 3
- ((counter++))
- done
- rm -rf _CPack_Packages
- - name: Find Android package
- if: ${{ startsWith(matrix.platform, 'android') }}
- run: |
- OUTPUT_DIRECTORY="${{ github.workspace }}/out/build/${{ matrix.preset }}/android-build/vcmi-app/build/outputs"
- mv "$OUTPUT_DIRECTORY/apk/release/vcmi-release.apk" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.apk"
- mv "$OUTPUT_DIRECTORY/bundle/release/vcmi-release.aab" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab"
- - name: Upload Artifact
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
- compression-level: 0
- path: |
- ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
- - name: Upload AAB Artifact
- if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - aab
- compression-level: 0
- path: |
- ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab
- - name: Upload debug symbols
- if: ${{ startsWith(matrix.platform, 'msvc') }}
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
- compression-level: 9
- path: |
- ${{github.workspace}}/**/*.pdb
- - name: Upload build to download.vcmi.eu
- if: ${{ matrix.upload == 1 && github.event.number == '' && env.DEPLOY_RSA != '' }}
- run: |
- if [ -z '${{ env.ANDROID_APK_PATH }}' ] ; then
- cd '${{github.workspace}}/out/build/${{matrix.preset}}'
- fi
- source '${{github.workspace}}/CI/upload_package.sh'
- env:
- DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
- PACKAGE_EXTENSION: ${{ matrix.extension }}
- upload-source-package:
- name: Upload Source Code Package
- if: always() && github.event.number == ''
- runs-on: ubuntu-24.04
- defaults:
- run:
- shell: bash
- steps:
- - uses: actions/checkout@v5
- with:
- submodules: recursive
- - name: Build Number
- run: |
- source '${{github.workspace}}/CI/get_package_name.sh'
- echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
-
- - name: Create source code archive (including submodules)
- run: |
- git archive HEAD -o "release.tar" --worktree-attributes -v
- git submodule update --init --recursive
- git submodule --quiet foreach 'cd "$toplevel"; tar -rvf "release.tar" "$sm_path"'
- gzip release.tar
-
- - name: Upload source code archive
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
- compression-level: 0
- path: |
- ./release.tar.gz
- test:
- continue-on-error: true
- name: Test (${{ matrix.platform }})
- strategy:
- matrix:
- include:
- - platform: gcc-latest-release
- os: ubuntu-24.04
- before_install: linux_qt6.sh
- compiler_cxx: g++-14
- compiler_cc: gcc-14
- preset: linux-gcc-test
- - platform: clang-latest-debug
- os: ubuntu-24.04
- before_install: linux_qt6.sh
- compiler_cxx: clang++-18
- compiler_cc: clang-18
- preset: linux-clang-debug
- - platform: gcc-oldest-debug
- os: ubuntu-22.04
- before_install: linux_qt5.sh
- compiler_cxx: g++-10
- compiler_cc: gcc-10
- preset: linux-gcc-debug
- - platform: clang-oldest-release
- os: ubuntu-22.04
- before_install: linux_qt5.sh
- compiler_cxx: clang++-13
- compiler_cc: clang-13
- preset: linux-clang-test
-
- runs-on: ${{ matrix.os }}
- defaults:
- run:
- shell: bash
- steps:
- - name: Checkout repository
- uses: actions/checkout@v5
- with:
- submodules: recursive
- - name: Prepare CI
- run: source '${{github.workspace}}/CI/before_install/${{matrix.before_install}}'
- - name: Install ccache for PRs
- uses: hendrikmuhs/[email protected]
- if: ${{ github.event.number != '' }}
- with:
- key: ${{ matrix.platform }}-PR-${{ github.event.number }}
- restore-keys: |
- ${{ matrix.platform }}-PR-${{ github.event.number }}
- ${{ matrix.platform }}-branch-${{ github.base_ref }}
- max-size: "5G"
- verbose: 2
- - name: Install ccache for branch builds
- uses: hendrikmuhs/[email protected]
- if: ${{ github.event.number == '' }}
- with:
- key: ${{ matrix.platform }}-${{ github.ref_name }}
- restore-keys: |
- ${{ matrix.platform }}-branch-${{ github.ref_name }}
- max-size: "5G"
- verbose: 2
- - name: Prepare Heroes 3 data
- env:
- HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
- if: ${{ env.HEROES_3_DATA_PASSWORD != '' }}
- run: |
- if [[ ${{github.repository_owner}} == vcmi ]]
- then
- data_url="https://github.com/vcmi-mods/vcmi-test-data/releases/download/v1.0/h3_assets.zip"
- else
- data_url="https://github.com/${{github.repository_owner}}/vcmi-test-data/releases/download/v1.0/h3_assets.zip"
- fi
- wget --progress=dot:giga "$data_url" -O h3_assets.zip
- 7za x h3_assets.zip -p$HEROES_3_DATA_PASSWORD
- mkdir -p ~/.local/share/vcmi/
- mv h3_assets/* ~/.local/share/vcmi/
-
- - name: Configure
- run: |
- cmake -DENABLE_CCACHE:BOOL=ON -DCMAKE_C_COMPILER=${{ matrix.compiler_cc }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler_cxx }} --preset ${{ matrix.preset }}
- - name: Build
- run: |
- cmake --build --preset ${{matrix.preset}}
- - name: Test
- env:
- HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
- if: ${{ env.HEROES_3_DATA_PASSWORD != '' }}
- run: |
- ctest --preset ${{matrix.preset}}
- windows-installer:
- needs: build
- name: Create Windows Installer (${{ matrix.arch }})
- strategy:
- matrix:
- include:
- - platform: msvc-x64
- arch: x64
- os: windows-2025
- - platform: msvc-x86
- arch: x86
- os: windows-2025
- - platform: msvc-arm64
- arch: arm64
- os: windows-11-arm
- runs-on: ${{ matrix.os }}
- defaults:
- run:
- shell: bash
- steps:
- - name: Checkout repository
- uses: actions/checkout@v5
- with:
- submodules: recursive
- - name: Extract version info
- id: extract-version
- shell: bash
- run: |
- filePath="${GITHUB_WORKSPACE}/cmake_modules/VersionDefinition.cmake"
- major=$(grep -m 1 "VCMI_VERSION_MAJOR" "$filePath" | tr -d -c 0-9)
- minor=$(grep -m 1 "VCMI_VERSION_MINOR" "$filePath" | tr -d -c 0-9)
- patch=$(grep -m 1 "VCMI_VERSION_PATCH" "$filePath" | tr -d -c 0-9)
- short_version="${major}.${minor}.${patch}"
- version_timestamp=$(date +"%Y%m%d%H%M%S")
- echo "short_version=${short_version}" >> "$GITHUB_OUTPUT"
- echo "version_timestamp=${version_timestamp}" >> "$GITHUB_OUTPUT"
- - name: Install vcpkg Dependencies
- run: source '${{github.workspace}}/CI/install_vcpkg_dependencies.sh' '${{matrix.platform}}'
- - name: Build Number
- run: |
- source '${{github.workspace}}/CI/get_package_name.sh'
- VCMI_PACKAGE_FILE_NAME+="-${{ matrix.arch }}"
- echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
- echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
- echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
- echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
- env:
- PULL_REQUEST: ${{ github.event.pull_request.number }}
- - name: Download Artifact
- uses: actions/download-artifact@v5
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
- path: ${{github.workspace}}/artifact
- - name: Extract Artifact
- shell: bash
- run: |
- mkdir artifact/extracted
- unzip "artifact/${{ env.VCMI_PACKAGE_FILE_NAME }}.zip" -d artifact/extracted
- - name: Ensure Inno Setup is installed
- shell: bash
- run: |
- if [ ! -f "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" ] && [ ! -f "/c/ProgramData/Chocolatey/bin/ISCC.exe" ]; then
- choco install innosetup --no-progress -y
- fi
- - name: Build VCMI Installer
- run: >
- CI\wininstaller\build_installer.cmd
- "${{ steps.extract-version.outputs.short_version }}"
- "${{ env.VCMI_PACKAGE_BUILD }}"
- "${{ matrix.arch }}"
- "VCMI ${{ env.VCMI_PACKAGE_NAME_SUFFIX }}"
- "${{ env.VCMI_PACKAGE_FILE_NAME }}"
- "${{ github.workspace }}\artifact\extracted"
- "${{ github.workspace }}\ucrt"
- shell: cmd
- - name: Upload VCMI Installer Artifacts
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - installer
- compression-level: 0
- path: |
- ${{ github.workspace }}/CI/wininstaller/Output/*.exe
- - name: Upload Installer
- if: ${{ github.event.number == '' && env.DEPLOY_RSA != '' }}
- run: |
- cd '${{github.workspace}}/CI/wininstaller/Output'
- source '${{github.workspace}}/CI/upload_package.sh'
- env:
- DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
- PACKAGE_EXTENSION: exe
- validate-code:
- name: Validate Code
- if: always()
- runs-on: ubuntu-latest
- defaults:
- run:
- shell: bash
- steps:
- - uses: actions/checkout@v5
- - name: Ensure LF line endings
- run: |
- find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
- -o -path ./osx -prune -o -type f \
- -not -name '*.png' -and -not -name '*.ttf' -and -not -name '*.wav' -and -not -name '*.webm' -and -not -name '*.ico' -and -not -name '*.bat' -and -not -name '*.cmd' -and -not -name '*.iss' -and -not -name '*.isl' -print0 | \
- { ! xargs -0 grep -l -z -P '\r\n'; }
- - name: Validate JSON
- run: |
- sudo apt install python3-jstyleson
- python3 CI/validate_json.py
- - name: Validate Markdown
- uses: DavidAnson/markdownlint-cli2-action@v20
- with:
- config: 'CI/example.markdownlint-cli2.jsonc'
- globs: '**/*.md'
|