| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- name: VCMI
- on:
- push:
- branches:
- - features/*
- - beta
- - master
- pull_request:
- schedule:
- - cron: '0 2 * * *'
- workflow_dispatch:
- env:
- # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
- BUILD_TYPE: Release
- jobs:
- 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/[email protected]
- 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/[email protected]
- 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
- build:
- needs: check_last_build
- if: always() && needs.check_last_build.skip_build != 1
- strategy:
- matrix:
- include:
- - platform: linux-qt6
- os: ubuntu-22.04
- test: 0
- preset: linux-clang-test
- - platform: linux
- os: ubuntu-20.04
- test: 0
- preset: linux-gcc-test
- - platform: linux
- os: ubuntu-20.04
- test: 0
- preset: linux-gcc-debug
- - platform: mac-intel
- os: macos-12
- test: 0
- pack: 1
- pack_type: Release
- extension: dmg
- preset: macos-conan-ninja-release
- conan_profile: macos-intel
- conan_options: --options with_apple_system_libs=True
- artifact_platform: intel
- - platform: mac-arm
- os: macos-12
- test: 0
- pack: 1
- pack_type: Release
- extension: dmg
- preset: macos-arm-conan-ninja-release
- conan_profile: macos-arm
- conan_options: --options with_apple_system_libs=True
- artifact_platform: arm
- - platform: ios
- os: macos-12
- test: 0
- pack: 1
- pack_type: Release
- extension: ipa
- preset: ios-release-conan-ccache
- conan_profile: ios-arm64
- conan_options: --options with_apple_system_libs=True
- - platform: msvc
- os: windows-latest
- test: 0
- pack: 1
- pack_type: RelWithDebInfo
- extension: exe
- preset: windows-msvc-release-ccache
- - platform: mingw
- 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: 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
- - 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
- artifact_platform: arm64-v8a
- runs-on: ${{ matrix.os }}
- defaults:
- run:
- shell: bash
- steps:
- - uses: actions/checkout@v3
- 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 \
- -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'; }
- - name: Validate JSON
- # 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') }}
- run: |
- pip3 install json5 jstyleson
- python3 CI/linux-qt6/validate_json.py
- - name: Dependencies
- run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
- env:
- VCMI_BUILD_PLATFORM: x64
- # 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
- uses: hendrikmuhs/[email protected]
- if: ${{ github.event.number != '' }}
- with:
- 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
- uses: hendrikmuhs/[email protected]
- if: ${{ github.event.number == '' }}
- 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
- - uses: actions/setup-python@v4
- if: "${{ matrix.conan_profile != '' }}"
- with:
- python-version: '3.10'
- - 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: Git branch name
- id: git-branch-name
- uses: EthanSK/git-branch-name-action@v1
- - 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_GITVERSION="$VCMI_PACKAGE_GITVERSION" >> $GITHUB_ENV
- env:
- PULL_REQUEST: ${{ github.event.pull_request.number }}
- - name: CMake Preset with ccache
- run: |
- cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache --preset ${{ matrix.preset }}
- - name: Build Preset
- run: |
- cmake --build --preset ${{matrix.preset}}
- - name: Test
- if: ${{ matrix.test == 1 }}
- run: |
- ctest --preset ${{matrix.preset}}
- - name: Pack
- id: cpack
- if: ${{ matrix.pack == 1 }}
- run: |
- cd '${{github.workspace}}/out/build/${{matrix.preset}}'
- CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
- "$CPACK_PATH" -C ${{matrix.pack_type}} ${{ matrix.cpack_args }}
- 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
- 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
- - name: Additional logs
- if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'msvc' }}
- 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@v3
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
- path: |
- ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
-
- - name: Android artifacts
- if: ${{ startsWith(matrix.platform, 'android') }}
- uses: actions/upload-artifact@v3
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
- path: |
- ${{ env.ANDROID_APK_PATH }}
-
- - name: Symbols
- if: ${{ matrix.platform == 'msvc' }}
- uses: actions/upload-artifact@v3
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
- path: |
- ${{github.workspace}}/**/*.pdb
- - name: Android JNI ${{matrix.platform}}
- if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
- uses: actions/upload-artifact@v3
- with:
- name: Android JNI ${{matrix.platform}}
- path: |
- ${{ github.workspace }}/android/vcmi-app/src/main/jniLibs
- - name: Upload build
- 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: |
- 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
- source '${{github.workspace}}/CI/upload_package.sh'
- env:
- DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
- PACKAGE_EXTENSION: ${{ matrix.extension }}
- - uses: act10ns/slack@v1
- with:
- status: ${{ job.status }}
- channel: '#notifications'
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- if: always()
-
- # 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@v3
- with:
- submodules: recursive
- - name: Dependencies
- run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
- env:
- VCMI_BUILD_PLATFORM: x64
- - uses: actions/setup-python@v4
- if: "${{ matrix.conan_profile != '' }}"
- with:
- python-version: '3.10'
- - 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: Git branch name
- id: git-branch-name
- uses: EthanSK/git-branch-name-action@v1
- - 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_GITVERSION="$VCMI_PACKAGE_GITVERSION" >> $GITHUB_ENV
- 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@v3
- with:
- name: Android JNI android-64
- path: ${{ github.workspace }}/android/vcmi-app/src/main/jniLibs/
-
- - name: Create android package
- 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@v3
- with:
- name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
- path: |
- ${{ env.ANDROID_APK_PATH }}
- - uses: act10ns/slack@v1
- with:
- status: ${{ job.status }}
- channel: '#notifications'
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- if: always()
|