Files
build-with-mob-action/action.yml
T

161 lines
6.3 KiB
YAML

name: Build with mob
description: Build ModOrganizer 2 plugins and executables using mob
inputs:
mo2-owner:
description: Owner to use to build.
required: false
default: ${{ github.event.pull_request.head.repo.owner.login || github.repository_owner }}
mo2-branch:
description: Branch to build.
required: false
default: ${{ github.head_ref || github.ref_name }}
mo2-dependencies:
description: List of MO2 dependencies to build.
required: false
default: ""
mo2-skip-checkout:
description: Whether to skip checkout of the repository.
required: false
default: "false"
mo2-skip-configure:
description: Whether to skip configure of the repository.
required: false
default: "false"
mo2-skip-build:
description: Whether to skip build of the repository (after configure).
required: false
default: "false"
qt-install:
description: Whether to install Qt or not.
required: false
default: "true"
qt-modules:
description: List of Qt modules to install.
required: false
default: ""
outputs:
cmake-prefix-path:
description: Value of the CMAKE_PREFIX_PATH variable used when configuring.
value: ${{ steps.set-cmake-paths.outputs.cmake-prefix-path }}
cmake-install-path:
description: Value of the CMAKE_INSTALL_PREFIX variable used when configuring.
value: ${{ steps.set-cmake-paths.outputs.cmake-install-path }}
working-directory:
description: Working directory containing the vsbuild folder.
value: ./build/${{ github.event.repository.name }}
runs:
using: "composite"
steps:
# Qt version
- name: Determine mob branch
id: determine-mob-branch
shell: bash
run: |
branch=master
if git ls-remote --exit-code https://github.com/ModOrganizer2/mob.git ${{ inputs.mo2-branch }} > /dev/null 2>&1; then
branch=${{ inputs.mo2-branch }}
fi
echo "branch=${branch}" >> "$GITHUB_OUTPUT"
- name: Checkout mob.ini
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/ModOrganizer2/mob/refs/heads/${{ steps.determine-mob-branch.outputs.branch }}/mob.ini" -OutFile ${{ github.workspace }}/mob.ini
# Qt
- name: Get Qt version
id: find-qt-version
shell: pwsh
run: |
$version = "${{ inputs.qt-version }}"
if (!$version) {
$version = (Get-Content "${{ github.workspace }}/mob.ini" | Select-String -Raw "^qt\s+=").Split("= ")[1]
}
Write-Output "Found Qt Version: $version"
Write-Output "QT_VERSION=$version" >> "$env:GITHUB_OUTPUT"
- if: inputs.qt-install == 'true'
name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ steps.find-qt-version.outputs.QT_VERSION }}
modules: ${{ inputs.qt-modules }}
arch: win64_msvc2022_64
aqtsource: git+https://github.com/miurahr/aqtinstall.git
cache: true
- name: Add Qt bins to PATH
shell: pwsh
run: echo "${QT_ROOT_DIR}/msvc2022_64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# set VCPKG Root
- name: "Set environmental variables"
shell: bash
run: |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
# set CMake install and prefix
- name: "Set CMAKE_PREFIX_PATH and CMAKE_INSTALL_PATH"
id: set-cmake-paths
shell: bash
run: |
echo "cmake-prefix-path=${QT_ROOT_DIR}\msvc2022_64;${{ github.workspace }}\build\cmake_common;${{ github.workspace }}\install\lib\cmake" >> $GITHUB_OUTPUT
echo "cmake-install-path=${{ github.workspace }}\install" >> $GITHUB_OUTPUT
# MO2 dependencies
- name: Checkout MO2 modules
shell: pwsh
run: '& ${env:GITHUB_ACTION_PATH}/checkout-mo2-dependencies.ps1 -Owner ${{ inputs.mo2-owner }} -Branch ${{ inputs.mo2-branch }} "cmake_common ${{ inputs.mo2-dependencies }}"'
- name: Configure & Build MO2 dependencies
shell: pwsh
run: |
Get-ChildItem build -Directory -Exclude ".git", "cmake_common", "${{ github.event.repository.name }}" | ForEach-Object {
Write-Output "Building $_... "
Push-Location $_
if ($_.Name -eq "usvfs") {
cmake --preset vs2022-windows-x64 `
"-DCMAKE_PREFIX_PATH=${{ steps.set-cmake-paths.outputs.cmake-prefix-path }}" `
"-DCMAKE_INSTALL_PREFIX=${{ steps.set-cmake-paths.outputs.cmake-install-path }}" `
"-DBUILD_TESTING=OFF"
cmake --build --preset vs2022-windows-x64 --config RelWithDebInfo --target INSTALL --parallel 16
cmake --preset vs2022-windows-x86 `
"-DCMAKE_PREFIX_PATH=${{ steps.set-cmake-paths.outputs.cmake-prefix-path }}" `
"-DCMAKE_INSTALL_PREFIX=${{ steps.set-cmake-paths.outputs.cmake-install-path }}" `
"-DBUILD_TESTING=OFF"
cmake --build --preset vs2022-windows-x86 --config RelWithDebInfo --target INSTALL --parallel 16
}
else {
cmake --preset vs2022-windows `
"-DCMAKE_PREFIX_PATH=${{ steps.set-cmake-paths.outputs.cmake-prefix-path }}" `
"-DCMAKE_INSTALL_PREFIX=${{ steps.set-cmake-paths.outputs.cmake-install-path }}" `
"-DBUILD_TESTING=OFF"
cmake --build --preset vs2022-windows --config RelWithDebInfo --target INSTALL --parallel 16
}
Pop-Location
}
- uses: actions/checkout@v3
if: inputs.mo2-skip-checkout != 'true'
with:
path: ./build/${{ github.event.repository.name }}
- name: Configure Repository
if: inputs.mo2-skip-checkout != 'true' && inputs.mo2-skip-configure != 'true'
shell: pwsh
run: |
Push-Location build/${{ github.event.repository.name }}
cmake --preset vs2022-windows `
"-DCMAKE_PREFIX_PATH=${{ steps.set-cmake-paths.outputs.cmake-prefix-path }}" `
"-DCMAKE_INSTALL_PREFIX=${{ steps.set-cmake-paths.outputs.cmake-install-path }}" `
"-DBUILD_TESTING=ON"
Pop-Location
# build repository
- name: Build Repository
if: inputs.mo2-skip-checkout != 'true' && inputs.mo2-skip-configure != 'true' && inputs.mo2-skip-build != 'true'
shell: pwsh
run: |
cmake --build --preset vs2022-windows --config RelWithDebInfo --parallel 16
working-directory: ./build/${{ github.event.repository.name }}