Skip to content

Build YaComponent Repo #3

Build YaComponent Repo

Build YaComponent Repo #3

Workflow file for this run

name: Build YaComponent Repo
# Trigger the workflow on push or pull request,
# but only for the main branch
on:
workflow_dispatch:
# push:
# branches:
# - master
env:
PLUGIN_NAME: yacomponent
QT_VERSION: 5.15.2
CMAKE_VERSION: 3.22.1
NINJA_VERSION: 1.10.2
jobs:
build:
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
outputs:
qtc_url: ${{ steps.qt_creator.outputs.qtc_base_url }}
strategy:
matrix:
config:
- {
name: "Windows Latest MSVC", artifact: "Windows-x64",
os: windows-latest,
cc: "cl", cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
}
- {
name: "Ubuntu Latest GCC", artifact: "Linux-x64",
os: ubuntu-latest,
cc: "gcc", cxx: "g++"
}
steps:
- uses: actions/checkout@v4
- name: Download Ninja and CMake
shell: cmake -P {0}
run: |
set(cmake_version "$ENV{CMAKE_VERSION}")
set(ninja_version "$ENV{NINJA_VERSION}")
if ("${{ runner.os }}" STREQUAL "Windows")
set(ninja_suffix "win.zip")
set(cmake_suffix "win64-x64.zip")
set(cmake_dir "cmake-${cmake_version}-win64-x64/bin")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(ninja_suffix "linux.zip")
set(cmake_suffix "Linux-x86_64.tar.gz")
set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin")
elseif ("${{ runner.os }}" STREQUAL "macOS")
set(ninja_suffix "mac.zip")
set(cmake_suffix "Darwin-x86_64.tar.gz")
set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin")
endif()
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip)
set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}")
file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip)
# Add to PATH environment variable
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir)
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}")
if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(
COMMAND chmod +x ninja
COMMAND chmod +x ${cmake_dir}/cmake
)
endif()
- name: Install system libs
shell: cmake -P {0}
run: |
if ("${{ runner.os }}" STREQUAL "Linux")
execute_process(
COMMAND sudo apt update
)
execute_process(
COMMAND sudo apt install libgl1-mesa-dev
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to install dependencies")
endif()
endif()
- name: Download Qt
id: qt
shell: cmake -P {0}
run: |
set(qt_version "$ENV{QT_VERSION}")
string(REPLACE "." "" qt_version_dotless "${qt_version}")
if ("${{ runner.os }}" STREQUAL "Windows")
set(url_os "windows_x86")
set(qt_package_arch_suffix "win64_msvc2019_64")
set(qt_dir_prefix "${qt_version}/msvc2019_64")
set(qt_package_suffix "-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(url_os "linux_x64")
set(qt_package_arch_suffix "gcc_64")
set(qt_dir_prefix "${qt_version}/gcc_64")
set(qt_package_suffix "-Linux-RHEL_7_6-GCC-Linux-RHEL_7_6-X86_64")
elseif ("${{ runner.os }}" STREQUAL "macOS")
set(url_os "mac_x64")
set(qt_package_arch_suffix "clang_64")
set(qt_dir_prefix "${qt_version}/clang_64")
set(qt_package_suffix "-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64")
endif()
file(MAKE_DIRECTORY build-qt5)
set(qt_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/qt5_${qt_version_dotless}")
file(DOWNLOAD "${qt_base_url}/Updates.xml" ./build-qt5/Updates.xml SHOW_PROGRESS)
file(READ ./build-qt5/Updates.xml updates_xml)
string(REGEX MATCH "<Name>qt.qt5.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}")
set(qt_package_version ${CMAKE_MATCH_1})
# Save the path for other steps
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/build-qt5/${qt_dir_prefix}" qt_dir)
#message("\"qt_dir=${qt_dir}\" >> $GITHUB_OUTPUT")
file(APPEND "$ENV{GITHUB_OUTPUT}" "qt_dir=${qt_dir}\n")
message("Downloading Qt to ${qt_dir}")
function(downloadAndExtract url archive)
message("Downloading ${url}")
file(DOWNLOAD "${url}" ./build-qt5/${archive} SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ${archive} WORKING_DIRECTORY build-qt5)
endfunction()
# qtdeclarative qttools qtsvg qtxmlpatterns
foreach(package qtbase qttools )
downloadAndExtract(
"${qt_base_url}/qt.qt5.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z"
${package}.7z
)
endforeach()
# uic depends on libicu56.so
if ("${{ runner.os }}" STREQUAL "Linux")
downloadAndExtract(
"${qt_base_url}/qt.qt5.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}icu-linux-Rhel7.2-x64.7z"
icu.7z
)
endif()
# message("::set-output name=qt_base_url::${qt_base_url}")
# message("\"qt_base_url::${qt_base_url}\" >> $GITHUB_OUTPUT")
file(APPEND "$ENV{GITHUB_OUTPUT}" "qt_base_url=${qt_base_url}\n")
- name: Configure
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
)
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(ENV{Qt5_DIR} "${{ steps.qt.outputs.qt_dir }}" )
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "${{ steps.cmake_and_ninja.outputs.cmake_dir }}${path_separator}$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
set( qt_version ${{ steps.qt.outputs.qt_version }} )
set( qt_url ${{ steps.qt.outputs.qt_base_url }} )
execute_process( COMMAND cmake -E make_directory "build" )
execute_process(
COMMAND cmake
-G "Ninja"
-DCMAKE_BUILD_TYPE=Release
..
RESULT_VARIABLE result
WORKING_DIRECTORY build
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
set(ENV{MACOSX_DEPLOYMENT_TARGET} "10.13")
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
)
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
set(ENV{Qt5_DIR} "${{ steps.qt.outputs.qt_dir }}" )
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "${{ steps.cmake_and_ninja.outputs.cmake_dir }}${path_separator}$ENV{GITHUB_WORKSPACE}${path_separator}${{ steps.qt.outputs.qt_dir }}/bin/${path_separator}$ENV{PATH}")
if ("${{ runner.os }}" STREQUAL "Windows")
else()
set(ENV{LD_LIBRARY_PATH} "qtcreator/lib/Qt/lib:$ENV{LD_LIBRARY_PATH}")
set(ENV{QT_QPA_PLATFORM} "minimal" )
endif()
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
execute_process(
COMMAND ninja
RESULT_VARIABLE result
WORKING_DIRECTORY build
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status of ninja")
string(REGEX MATCH "FAILED:.*$" error_message "${output}")
string(REPLACE "\n" "%0A" error_message "${error_message}")
message("::error::${error_message}")
message(FATAL_ERROR "Build failed")
endif()
# install plugin dependencies for deployment
execute_process(
COMMAND ${CMAKE_COMMAND} -E env "DESTDIR=$ENV{GITHUB_WORKSPACE}/build/install" ninja install
RESULT_VARIABLE result
WORKING_DIRECTORY build
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status of ninja install")
endif()
- uses: actions/upload-artifact@v4
id: upload_artifact
with:
name: ${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-${{ matrix.config.artifact }}.7z
path: |
./${{ env.PLUGIN_NAME }}-${{ env.QT_CREATOR_VERSION }}-${{ matrix.config.artifact }}.7z
release_info:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: ReleaseInfo
id: release_info
shell: cmake -P {0}
run: |
set( qt_version "$ENV{QT_VERSION}")
string( REPLACE "refs/tags/" "" tag_name "$ENV{GITHUB_REF}" )
set( readme_url "$ENV{GITHUB_SERVER_URL}/$ENV{GITHUB_REPOSITORY}/blob/${tag_name}/RELEASENOTES.md" )
configure_file( $ENV{GITHUB_WORKSPACE}/RELEASEINFO.md.in $ENV{GITHUB_WORKSPACE}/RELEASEINFO.md @ONLY )
- uses: actions/upload-artifact@v4
with:
name: RELEASEINFO.md
path: |
./RELEASEINFO.md
release:
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: release_info
steps:
- name: Download artifact
uses: actions/download-artifact@v4
id: download
with:
path: download
# - name: Display structure of downloaded files
# run: ls -R
# working-directory: download
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: download/RELEASEINFO.md/RELEASEINFO.md
draft: true
prerelease: false
files: |
'download/**/*.7z'