Merge branch 'feature/qtc12_and_conan' #175
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SpellChecker-Plugin Workflow | |
# Used the following repos as inspiration | |
# - https://github.com/OneMoreGres/qtc-dbviewer/blob/4.13.0/.github/workflows/build.yml | |
# - https://www.qt.io/blog/building-qt-creator-plugins-with-github-actions | |
# Using PowerShell Core since I am trying to learn using it, seemed like a good fit for cross platform scripting. | |
name: Build SpellChecker-Plugin | |
# Controls when the action will run. Triggers the workflow on any push event. | |
on: [push] | |
env: | |
QT_VERSION: "6.4.2" | |
QT_CREATOR_VERSION: "12.0.0" | |
QT_MIRRORS: download.qt.io;mirrors.ocf.berkeley.edu/qt;ftp.fau.de/qtproject;mirror.bit.edu.cn/qtproject | |
# The Jobs | |
jobs: | |
# The release job. | |
# If the github.ref contains /tags/v a release will be set up. | |
# This is done before the builds to simplify the logic to upload the build artifacts to the release. | |
# The release stage a file that contains the URL of where the build artifacts must go. | |
# It is also executed only once, on one agent. | |
release: | |
name: Create release | |
if: contains(github.ref, '/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create release | |
if: contains(github.ref, '/tags/v') | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
body: | | |
Release for Qt Creator ${{env.QT_CREATOR_VERSION}}. | |
Download the correct file based on operating system and architecture of Qt Creator. | |
To deploy into Qt Creator, extract the archive into the root folder of where Qt Creator is installed. | |
Please refer to the main page of the project for usage information. | |
From version 3.0.0 a more semantic versioning approach will be followed to follow the version of Qt Creator more closely. | |
On Windows, make sure to download the correct version for the Qt Creator used, not the architecture of the Operating System. | |
To check this: From Qt Creator, go to "Help" -> "About Qt Creator..." | |
NOTE: From Qt Creator version 4.14 only 64 bit binaries are provided for Windows since Qt does not ship a 32 bit version of Qt Creator anymore. If this | |
is a problem please file a bug and I can see if I can provide binaries in the mean time. | |
*PS: I have a "Buy me a coffee" account if you want to supporting me, see the main page if interested in contributing something to say thank you for the plugin*. | |
draft: false | |
prerelease: false | |
- name: Store release url | |
shell: pwsh | |
run: Write-Output "${{ steps.create_release.outputs.upload_url }}" > ./release_upload_url.txt | |
- name: Upload release url | |
uses: actions/upload-artifact@v2 | |
with: | |
path: ./release_upload_url.txt | |
name: release_upload_url.txt | |
# Build the plugin and upload the archives | |
build: | |
name: Build ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
env: | |
OS: ${{ matrix.config.name }} | |
strategy: | |
matrix: | |
config: | |
- { | |
name: "win64", | |
os: windows-latest, | |
sys: "windows", | |
arch: "x64", | |
qt_arch: "win64_msvc2019_64", | |
qtc_platform: "windows_x64", | |
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
is_msvc: true | |
} | |
- { | |
name: "linux", | |
os: ubuntu-latest, | |
sys: "linux", | |
arch: "x64", | |
qt_arch: "", | |
qtc_platform: "linux_x64" | |
} | |
- { | |
name: "macos", | |
os: macos-latest, | |
sys: "osx", | |
arch: "x64", | |
qt_arch: "", | |
qtc_platform: "mac_x64" | |
} | |
fail-fast: false | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE/SpellChecker-Plugin, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
path: SpellChecker-Plugin | |
- name: System Packages | |
shell: pwsh | |
run: | | |
switch ("${{runner.os}}") | |
{ | |
"Windows" { choco install ninja } | |
"Linux" { sudo apt update; sudo apt install libclang-dev libclang-12-dev libclang-11-dev ninja-build gettext libgl1-mesa-dev libvulkan-dev libxcb-xinput-dev libxcb-xinerama0-dev libxkbcommon-dev libxkbcommon-x11-dev } | |
"macOS" { brew update; brew install automake autoconf ninja } | |
} | |
# Install Conan | |
- name: Install Conan | |
id: conan | |
uses: turtlebrowser/get-conan@main | |
- 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_21H2-MSVC2019-Windows-Windows_10_21H2-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_8_4-GCC-Linux-RHEL_8_4-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}/macos") | |
set(qt_package_suffix "-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64") | |
endif() | |
set(qt_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/qt6_${qt_version_dotless}") | |
file(DOWNLOAD "${qt_base_url}/Updates.xml" ./Updates.xml SHOW_PROGRESS) | |
file(READ ./Updates.xml updates_xml) | |
string(REGEX MATCH "<Name>qt.qt6.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}") | |
set(qt_package_version ${CMAKE_MATCH_1}) | |
file(MAKE_DIRECTORY qt) | |
# Save the path for other steps | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qt/${qt_dir_prefix}" qt_dir) | |
message("::set-output name=qt_dir::${qt_dir}") | |
message("Downloading Qt to ${qt_dir}") | |
function(downloadAndExtract url archive) | |
message("Downloading ${url}") | |
file(DOWNLOAD "${url}" ./${archive} SHOW_PROGRESS) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ../${archive} WORKING_DIRECTORY qt) | |
endfunction() | |
foreach(package qtbase qtdeclarative) | |
downloadAndExtract( | |
"${qt_base_url}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z" | |
${package}.7z | |
) | |
endforeach() | |
foreach(package qt5compat qtshadertools) | |
downloadAndExtract( | |
"${qt_base_url}/qt.qt6.${qt_version_dotless}.${package}.${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.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}icu-linux-Rhel7.2-x64.7z" | |
icu.7z | |
) | |
endif() | |
- name: Download Qt Creator | |
id: qt_creator | |
shell: cmake -P {0} | |
run: | | |
string(REGEX MATCH "([0-9]+.[0-9]+).[0-9]+" outvar "$ENV{QT_CREATOR_VERSION}") | |
set(qtc_base_url "https://download.qt.io/official_releases/qtcreator/${CMAKE_MATCH_1}/$ENV{QT_CREATOR_VERSION}/installer_source") | |
set(qtc_snapshot "$ENV{QT_CREATOR_SNAPSHOT}") | |
if (qtc_snapshot) | |
set(qtc_base_url "https://download.qt.io/snapshots/qtcreator/${CMAKE_MATCH_1}/$ENV{QT_CREATOR_VERSION}/installer_source/${qtc_snapshot}") | |
endif() | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(qtc_platform "windows_x64") | |
elseif ("${{ runner.os }}" STREQUAL "Linux") | |
set(qtc_platform "linux_x64") | |
elseif ("${{ runner.os }}" STREQUAL "macOS") | |
set(qtc_platform "mac_x64") | |
endif() | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qtcreator" qtc_dir) | |
# Save the path for other steps | |
message("::set-output name=qtc_dir::${qtc_dir}") | |
file(MAKE_DIRECTORY qtcreator) | |
message("Downloading Qt Creator from ${qtc_base_url}/${qtc_platform}") | |
foreach(package qtcreator qtcreator_dev) | |
file(DOWNLOAD | |
"${qtc_base_url}/${qtc_platform}/${package}.7z" ./${package}.7z SHOW_PROGRESS) | |
execute_process(COMMAND | |
${CMAKE_COMMAND} -E tar xvf ../${package}.7z WORKING_DIRECTORY qtcreator) | |
endforeach() | |
- name: Build Plugin | |
shell: pwsh | |
run: | | |
${env:CMAKE_PRESET} = "conan-release" | |
switch ("${{runner.os}}") | |
{ | |
"Windows" { | |
Write-Output "<+> Setting up MSBuild" | |
# https://github.com/microsoft/terminal/issues/3821#issuecomment-651506501 | |
# The setup-msbuild action is not used since it does not set up the path to 'cl' | |
# see: https://github.com/microsoft/setup-msbuild/issues/24 | |
${VS_INST_PATH} = & "${env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -property installationPath | |
Write-Output " <-> VS Install Path: ${VS_INST_PATH}" | |
Import-Module ${VS_INST_PATH}/Common7/Tools/Microsoft.VisualStudio.DevShell.dll | |
Enter-VsDevShell -VsInstallPath ${VS_INST_PATH} -SkipAutomaticLocation -DevCmdArguments '-arch=${{matrix.config.arch}} -no_logo' | |
${env:CMAKE_PRESET} = "conan-default" | |
} | |
"macOS" { | |
# From the build.py script: on macOS the prefix path must be inside the app bundle... | |
${prefix_extra}=";${{ steps.qt_creator.outputs.qtc_dir }}/Qt Creator.app/Contents/Resources" | |
} | |
} | |
Set-Location -Path "SpellChecker-Plugin" | |
conan profile detect | |
conan config install .conan | |
conan install . -pr cpp20 --build=missing | |
cmake --preset "${env:CMAKE_PRESET}" ` | |
-DCMAKE_PREFIX_PATH="${{ steps.qt.outputs.qt_dir }};${{ steps.qt_creator.outputs.qtc_dir }}${prefix_extra}" ` | |
cmake --build --preset conan-release | |
- name: Collect Binaries | |
shell: pwsh | |
run: | | |
${PLUGIN_DIR_BASE} = "Plugin/" | |
${PLUGIN_ARCHIVE} = "SpellChecker-Plugin_QtC${env:QT_CREATOR_VERSION}_${env:OS}_${{matrix.config.arch}}" | |
switch ("${{runner.os}}") | |
{ | |
"Windows" { | |
${PLUGIN_DIR_OUT} = "${PLUGIN_DIR_BASE}/lib/qtcreator/plugins" | |
New-Item -ItemType Directory "${PLUGIN_DIR_OUT}" -Force | |
${PLUGIN_OBJ} = Get-ChildItem -Path . -Filter SpellChecker.dll -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName} | |
Write-Output "PLUGIN_OBJ: ${PLUGIN_OBJ}" | |
Copy-Item -Path "${PLUGIN_OBJ}" -Destination "${PLUGIN_DIR_OUT}/" | |
Push-Location ${PLUGIN_DIR_BASE} | |
${env:PLUGIN_ARCHIVE_NAME} = "${PLUGIN_ARCHIVE}.zip" | |
7z a "${env:PLUGIN_ARCHIVE_NAME}" lib | |
Pop-Location | |
} | |
"Linux" { | |
${PLUGIN_DIR_OUT} = "${PLUGIN_DIR_BASE}/lib/qtcreator/plugins" | |
New-Item -ItemType Directory "${PLUGIN_DIR_OUT}" -Force | |
${PLUGIN_OBJ} = Get-ChildItem -Path . -Filter libSpellChecker.so -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName} | |
Write-Output "PLUGIN_OBJ: ${PLUGIN_OBJ}" | |
Copy-Item -Path "${PLUGIN_OBJ}" -Destination "${PLUGIN_DIR_OUT}/" | |
Push-Location ${PLUGIN_DIR_BASE} | |
${env:PLUGIN_ARCHIVE_NAME} = "${PLUGIN_ARCHIVE}.tar.gz" | |
7z a -ttar "${PLUGIN_ARCHIVE}.tar" lib | |
7z a -tgzip "${env:PLUGIN_ARCHIVE_NAME}" "${PLUGIN_ARCHIVE}.tar" | |
Pop-Location | |
} | |
"macOS" { | |
${PLUGIN_DIR_OUT} = "${PLUGIN_DIR_BASE}/bin/Qt Creator.app/Contents/PlugIns" | |
New-Item -Path "${PLUGIN_DIR_OUT}" -ItemType Directory -Force | |
${PLUGIN_OBJ} = Get-ChildItem -Path . -Filter libSpellChecker.dylib -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName} | |
Write-Output "PLUGIN_OBJ: ${PLUGIN_OBJ}" | |
Copy-Item -Path "${PLUGIN_OBJ}" -Destination "${PLUGIN_DIR_OUT}/" | |
Get-ChildItem "${PLUGIN_DIR_OUT}" | |
Push-Location ${PLUGIN_DIR_BASE} | |
${env:PLUGIN_ARCHIVE_NAME} = "${PLUGIN_ARCHIVE}.tar.gz" | |
7z a -ttar "${PLUGIN_ARCHIVE}.tar" bin | |
7z a -tgzip "${env:PLUGIN_ARCHIVE_NAME}" "${PLUGIN_ARCHIVE}.tar" | |
Pop-Location | |
} | |
} | |
${env:PLUGIN_ARCHIVE_FULL} = "${PLUGIN_DIR_BASE}/${env:PLUGIN_ARCHIVE_NAME}" | |
Write-Output "PLUGIN_ARCHIVE_FULL=${{github.workspace}}/${env:PLUGIN_ARCHIVE_FULL}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
Write-Output "PLUGIN_ARCHIVE_NAME=${env:PLUGIN_ARCHIVE_NAME}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- uses: actions/upload-artifact@v2 | |
id: upload_artifact | |
with: | |
path: ${{env.PLUGIN_ARCHIVE_FULL}} | |
name: ${{env.PLUGIN_ARCHIVE_NAME}} | |
- name: Download release url | |
if: contains(github.ref, '/tags/v') | |
uses: actions/download-artifact@v2 | |
with: | |
name: release_upload_url.txt | |
path: ./ | |
- name: Set Release Var | |
if: contains(github.ref, '/tags/v') | |
shell: pwsh | |
run: | | |
${RELEASE_URL} = Get-Content ./release_upload_url.txt | |
Write-Output "Release URL: ${RELEASE_URL}" | |
Write-Output "RELEASE_URL=${RELEASE_URL}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Upload release artifacts | |
if: contains(github.ref, '/tags/v') | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{env.RELEASE_URL}} | |
asset_path: ${{env.PLUGIN_ARCHIVE_FULL}} | |
asset_name: ${{env.PLUGIN_ARCHIVE_NAME}} | |
asset_content_type: application/zip |