|
| 1 | +name: Build plugin |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +env: |
| 6 | + PLUGIN_NAME: DoxygenPlugin |
| 7 | + QT_VERSION: 6.8.1 |
| 8 | + QT_CREATOR_VERSION: 15.0.1 |
| 9 | + QT_CREATOR_VERSION_INTERNAL: 15.0.1 |
| 10 | + MACOS_DEPLOYMENT_TARGET: "11.0" |
| 11 | + CMAKE_VERSION: "3.29.6" |
| 12 | + NINJA_VERSION: "1.12.1" |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: ${{ matrix.config.name }} |
| 17 | + runs-on: ${{ matrix.config.os }} |
| 18 | + outputs: |
| 19 | + tag: ${{ steps.git.outputs.tag }} |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + config: |
| 23 | + - { |
| 24 | + name: "Windows Latest MSVC", artifact: "Windows-x64", |
| 25 | + os: windows-latest, |
| 26 | + platform: windows_x64, |
| 27 | + cc: "cl", cxx: "cl", |
| 28 | + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", |
| 29 | + } |
| 30 | + - { |
| 31 | + name: "Windows Latest MSVC Arm64", artifact: "Windows-arm64", |
| 32 | + os: windows-latest, |
| 33 | + platform: windows_arm64, |
| 34 | + cc: "cl", cxx: "cl", |
| 35 | + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsamd64_arm64.bat", |
| 36 | + } |
| 37 | + - { |
| 38 | + name: "Ubuntu Latest GCC", artifact: "Linux-x64", |
| 39 | + os: ubuntu-latest, |
| 40 | + platform: linux_x64, |
| 41 | + cc: "gcc", cxx: "g++" |
| 42 | + } |
| 43 | + - { |
| 44 | + name: "Ubuntu Latest GCC Arm64", artifact: "Linux-arm64", |
| 45 | + os: ubuntu-latest, |
| 46 | + platform: linux_arm64, |
| 47 | + cc: "aarch64-linux-gnu-gcc", cxx: "aarch64-linux-gnu-g++" |
| 48 | + } |
| 49 | + - { |
| 50 | + name: "macOS Latest Clang", artifact: "macOS-universal", |
| 51 | + os: macos-latest, |
| 52 | + platform: mac_x64, |
| 53 | + cc: "clang", cxx: "clang++" |
| 54 | + } |
| 55 | + |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - name: Checkout submodules |
| 59 | + id: git |
| 60 | + shell: cmake -P {0} |
| 61 | + run: | |
| 62 | + if (${{github.ref}} MATCHES "tags/v(.*)") |
| 63 | + file(APPEND "$ENV{GITHUB_OUTPUT}" "tag=${CMAKE_MATCH_1}") |
| 64 | + else() |
| 65 | + file(APPEND "$ENV{GITHUB_OUTPUT}" "tag=${{github.run_id}}") |
| 66 | + endif() |
| 67 | +
|
| 68 | + - name: Download Ninja and CMake |
| 69 | + uses: lukka/get-cmake@latest |
| 70 | + with: |
| 71 | + cmakeVersion: ${{ env.CMAKE_VERSION }} |
| 72 | + ninjaVersion: ${{ env.NINJA_VERSION }} |
| 73 | + |
| 74 | + - name: Install system libs |
| 75 | + shell: cmake -P {0} |
| 76 | + run: | |
| 77 | + if ("${{ matrix.config.platform }}" STREQUAL "linux_x64") |
| 78 | + execute_process( |
| 79 | + COMMAND sudo apt-get update |
| 80 | + ) |
| 81 | + execute_process( |
| 82 | + COMMAND sudo apt-get install -y libgl1-mesa-dev |
| 83 | + RESULT_VARIABLE result |
| 84 | + ) |
| 85 | + if (NOT result EQUAL 0) |
| 86 | + message(FATAL_ERROR "Failed to install dependencies") |
| 87 | + endif() |
| 88 | + elseif ("${{ matrix.config.platform }}" STREQUAL "linux_arm64") |
| 89 | + execute_process(COMMAND sudo dpkg --add-architecture arm64) |
| 90 | +
|
| 91 | + # TODO: Check to see if the azure.ubuntu added arm64 support |
| 92 | + execute_process(COMMAND sudo apt-get install -y bash curl apt-transport-https ca-certificates) |
| 93 | + execute_process(COMMAND sudo curl https://raw.githubusercontent.com/vegardit/fast-apt-mirror.sh/v1/fast-apt-mirror.sh -o /usr/local/bin/fast-apt-mirror.sh) |
| 94 | + execute_process(COMMAND sudo chmod 755 /usr/local/bin/fast-apt-mirror.sh) |
| 95 | +
|
| 96 | + #execute_process(COMMAND sudo /usr/local/bin/fast-apt-mirror.sh set https://mirrors.ocf.berkeley.edu/ubuntu-ports/) |
| 97 | + execute_process(COMMAND sudo /usr/local/bin/fast-apt-mirror.sh set https://mirror.kumi.systems/ubuntu-ports/) |
| 98 | +
|
| 99 | + execute_process( |
| 100 | + COMMAND sudo apt-get update |
| 101 | + ) |
| 102 | + execute_process( |
| 103 | + COMMAND |
| 104 | + sudo apt-get install -y crossbuild-essential-arm64 libgl1-mesa-dev:arm64 |
| 105 | + RESULT_VARIABLE result |
| 106 | + ) |
| 107 | + if (NOT result EQUAL 0) |
| 108 | + message(FATAL_ERROR "Failed to install dependencies") |
| 109 | + endif() |
| 110 | + endif() |
| 111 | +
|
| 112 | + - name: Download Qt |
| 113 | + id: qt |
| 114 | + shell: cmake -P {0} |
| 115 | + run: | |
| 116 | + set(qt_version "$ENV{QT_VERSION}") |
| 117 | +
|
| 118 | + function(download_qt platform export_qt_dir) |
| 119 | + string(REPLACE "." "" qt_version_dotless "${qt_version}") |
| 120 | + if (platform STREQUAL "windows_x64") |
| 121 | + set(url_os "windows_x86") |
| 122 | + set(qt_package_arch_suffix "win64_msvc2022_64") |
| 123 | + set(qt_dir_prefix "${qt_version}/msvc_64") |
| 124 | + set(qt_package_suffix "-Windows-Windows_11_23H2-MSVC2022-Windows-Windows_11_23H2-X86_64") |
| 125 | + elseif (platform STREQUAL "windows_arm64") |
| 126 | + set(url_os "windows_x86") |
| 127 | + set(qt_package_arch_suffix "win64_msvc2022_arm64_cross_compiled") |
| 128 | + set(qt_dir_prefix "${qt_version}/msvc_arm64") |
| 129 | + set(qt_package_suffix "-Windows-Windows_11_23H2-MSVC2022-Windows-Windows_11_23H2-ARM64") |
| 130 | + elseif (platform STREQUAL "linux_x64") |
| 131 | + set(url_os "linux_x64") |
| 132 | + set(qt_package_arch_suffix "linux_gcc_64") |
| 133 | + set(qt_dir_prefix "${qt_version}/gcc_64") |
| 134 | + set(qt_package_suffix "-Linux-RHEL_8_10-GCC-Linux-RHEL_8_10-X86_64") |
| 135 | + elseif (platform STREQUAL "linux_arm64") |
| 136 | + set(url_os "linux_arm64") |
| 137 | + set(qt_package_arch_suffix "linux_gcc_arm64") |
| 138 | + set(qt_dir_prefix "${qt_version}/gcc_arm64") |
| 139 | + set(qt_package_suffix "-Linux-Ubuntu_24_04-GCC-Linux-Ubuntu_24_04-AARCH64") |
| 140 | + elseif (platform STREQUAL "mac_x64") |
| 141 | + set(url_os "mac_x64") |
| 142 | + set(qt_package_arch_suffix "clang_64") |
| 143 | + set(qt_dir_prefix "${qt_version}/macos") |
| 144 | + set(qt_package_suffix "-MacOS-MacOS_14-Clang-MacOS-MacOS_14-X86_64-ARM64") |
| 145 | + endif() |
| 146 | +
|
| 147 | + set(qt_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/qt6_${qt_version_dotless}/qt6_${qt_version_dotless}") |
| 148 | + file(DOWNLOAD "${qt_base_url}/Updates.xml" ./Updates.xml SHOW_PROGRESS) |
| 149 | +
|
| 150 | + file(READ ./Updates.xml updates_xml) |
| 151 | + string(REGEX MATCH "<Name>qt.qt6.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}") |
| 152 | + set(qt_package_version ${CMAKE_MATCH_1}) |
| 153 | +
|
| 154 | + # Save the path for other steps |
| 155 | + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qt6/${qt_dir_prefix}" qt_dir) |
| 156 | +
|
| 157 | + if (export_qt_dir) |
| 158 | + file(APPEND "$ENV{GITHUB_OUTPUT}" "qt_dir=${qt_dir}") |
| 159 | + endif() |
| 160 | +
|
| 161 | + message("Downloading Qt to ${qt_dir}") |
| 162 | + function(downloadAndExtract url archive subdir) |
| 163 | + file(MAKE_DIRECTORY "${qt_dir}/${subdir}") |
| 164 | + message("Downloading ${url}") |
| 165 | + message("... extracting to ${qt_dir}/${subdir}") |
| 166 | + file(DOWNLOAD "${url}" "$ENV{GITHUB_WORKSPACE}/${archive}" SHOW_PROGRESS) |
| 167 | + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "$ENV{GITHUB_WORKSPACE}/${archive}" WORKING_DIRECTORY "${qt_dir}/${subdir}") |
| 168 | + endfunction() |
| 169 | +
|
| 170 | + foreach(package qtbase qtdeclarative) |
| 171 | + downloadAndExtract( |
| 172 | + "${qt_base_url}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z" |
| 173 | + ${package}.7z |
| 174 | + "" |
| 175 | + ) |
| 176 | + endforeach() |
| 177 | +
|
| 178 | + foreach(package qt5compat qtshadertools) |
| 179 | + downloadAndExtract( |
| 180 | + "${qt_base_url}/qt.qt6.${qt_version_dotless}.addons.${package}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z" |
| 181 | + ${package}.7z |
| 182 | + "" |
| 183 | + ) |
| 184 | + endforeach() |
| 185 | +
|
| 186 | + # uic depends on libicu*.so |
| 187 | + if (platform STREQUAL "linux_x64") |
| 188 | + if (qt_version VERSION_LESS "6.7.0") |
| 189 | + set(uic_suffix "Rhel7.2-x64") |
| 190 | + else() |
| 191 | + set(uic_suffix "Rhel8.6-x86_64") |
| 192 | + endif() |
| 193 | + downloadAndExtract( |
| 194 | + "${qt_base_url}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}icu-linux-${uic_suffix}.7z" |
| 195 | + icu.7z |
| 196 | + "lib" |
| 197 | + ) |
| 198 | + endif() |
| 199 | +
|
| 200 | + execute_process(COMMAND ${qt_dir}/bin/qmake -query) |
| 201 | + endfunction() |
| 202 | +
|
| 203 | + if ("${{ matrix.config.platform }}" STREQUAL "windows_x64") |
| 204 | + download_qt(windows_x64 TRUE) |
| 205 | + elseif ("${{ matrix.config.platform }}" STREQUAL "windows_arm64") |
| 206 | + download_qt(windows_x64 FALSE) |
| 207 | + download_qt(windows_arm64 TRUE) |
| 208 | + elseif ("${{ matrix.config.platform }}" STREQUAL "linux_x64") |
| 209 | + download_qt(linux_x64 TRUE) |
| 210 | + elseif ("${{ matrix.config.platform }}" STREQUAL "linux_arm64") |
| 211 | + download_qt(linux_x64 FALSE) |
| 212 | + download_qt(linux_arm64 TRUE) |
| 213 | + elseif ("${{ runner.os }}" STREQUAL "macOS") |
| 214 | + download_qt(mac_x64 TRUE) |
| 215 | + endif() |
| 216 | +
|
| 217 | + - name: Download Qt Creator |
| 218 | + uses: qt-creator/[email protected] |
| 219 | + with: |
| 220 | + version: ${{ env.QT_CREATOR_VERSION }} |
| 221 | + unzip-to: 'qtcreator' |
| 222 | + platform: ${{ matrix.config.platform }} |
| 223 | + |
| 224 | + - name: Extract Qt Creator |
| 225 | + id: qt_creator |
| 226 | + shell: cmake -P {0} |
| 227 | + run: | |
| 228 | + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qtcreator" qtc_dir) |
| 229 | + file(APPEND "$ENV{GITHUB_OUTPUT}" "qtc_dir=${qtc_dir}") |
| 230 | +
|
| 231 | + - name: Build |
| 232 | + shell: cmake -P {0} |
| 233 | + run: | |
| 234 | + set(ENV{CC} ${{ matrix.config.cc }}) |
| 235 | + set(ENV{CXX} ${{ matrix.config.cxx }}) |
| 236 | + set(ENV{MACOSX_DEPLOYMENT_TARGET} "${{ env.MACOS_DEPLOYMENT_TARGET }}") |
| 237 | +
|
| 238 | + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") |
| 239 | + execute_process( |
| 240 | + COMMAND "${{ matrix.config.environment_script }}" && set |
| 241 | + OUTPUT_FILE environment_script_output.txt |
| 242 | + ) |
| 243 | + file(STRINGS environment_script_output.txt output_lines) |
| 244 | + foreach(line IN LISTS output_lines) |
| 245 | + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") |
| 246 | + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") |
| 247 | + endif() |
| 248 | + endforeach() |
| 249 | + endif() |
| 250 | +
|
| 251 | + set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") |
| 252 | + if ("${{ runner.os }}" STREQUAL "macOS") |
| 253 | + set(ENV{CMAKE_OSX_ARCHITECTURES} "x86_64;arm64") |
| 254 | + endif() |
| 255 | +
|
| 256 | + set(build_plugin_py "scripts/build_plugin.py") |
| 257 | + foreach(dir "share/qtcreator/scripts" "Qt Creator.app/Contents/Resources/scripts" "Contents/Resources/scripts") |
| 258 | + if(EXISTS "${{ steps.qt_creator.outputs.qtc_dir }}/${dir}/build_plugin.py") |
| 259 | + set(build_plugin_py "${dir}/build_plugin.py") |
| 260 | + break() |
| 261 | + endif() |
| 262 | + endforeach() |
| 263 | +
|
| 264 | + if ("${{ matrix.config.platform }}" STREQUAL "windows_arm64") |
| 265 | + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qt6/$ENV{QT_VERSION}/msvc_64" qt_host_dir) |
| 266 | + set(additional_config "--add-config=-DQT_HOST_PATH=${qt_host_dir}") |
| 267 | + elseif ("${{ matrix.config.platform }}" STREQUAL "linux_arm64") |
| 268 | + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qt6/$ENV{QT_VERSION}/gcc_64" qt_host_dir) |
| 269 | + set(additional_config "--add-config=-DQT_HOST_PATH=${qt_host_dir}") |
| 270 | + endif() |
| 271 | +
|
| 272 | + execute_process( |
| 273 | + COMMAND python |
| 274 | + -u |
| 275 | + "${{ steps.qt_creator.outputs.qtc_dir }}/${build_plugin_py}" |
| 276 | + --name "$ENV{PLUGIN_NAME}-$ENV{QT_CREATOR_VERSION}-${{ matrix.config.artifact }}" |
| 277 | + --src . |
| 278 | + --build build |
| 279 | + --qt-path "${{ steps.qt.outputs.qt_dir }}" |
| 280 | + --qtc-path "${{ steps.qt_creator.outputs.qtc_dir }}" |
| 281 | + --output-path "$ENV{GITHUB_WORKSPACE}" |
| 282 | + ${additional_config} |
| 283 | + RESULT_VARIABLE result |
| 284 | + ) |
| 285 | + if (NOT result EQUAL 0) |
| 286 | + string(REGEX MATCH "FAILED:.*$" error_message "${output}") |
| 287 | + string(REPLACE "\n" "%0A" error_message "${error_message}") |
| 288 | + message("::error::${error_message}") |
| 289 | + message(FATAL_ERROR "Build failed") |
| 290 | + endif() |
| 291 | +
|
| 292 | + - name: Upload |
| 293 | + uses: actions/upload-artifact@v4 |
| 294 | + with: |
| 295 | + path: ./${{ env.PLUGIN_NAME }}-${{ env.QT_CREATOR_VERSION }}-${{ matrix.config.artifact }}.7z |
| 296 | + name: ${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-${{ matrix.config.artifact }}.7z |
| 297 | + |
| 298 | + # The json is the same for all platforms, but we need to save one |
| 299 | + - name: Upload plugin json |
| 300 | + if: matrix.config.platform == 'linux_arm64' |
| 301 | + uses: actions/upload-artifact@v4 |
| 302 | + with: |
| 303 | + name: ${{ env.PLUGIN_NAME }}.json |
| 304 | + path: ./build/build/${{ env.PLUGIN_NAME }}.json |
| 305 | + |
| 306 | + release: |
| 307 | + if: contains(github.ref, 'tags/v') |
| 308 | + runs-on: ubuntu-latest |
| 309 | + needs: [build] |
| 310 | + |
| 311 | + steps: |
| 312 | + - name: Download artifacts |
| 313 | + uses: actions/download-artifact@v4 |
| 314 | + with: |
| 315 | + path: release-with-dirs |
| 316 | + |
| 317 | + - name: Fixup artifacts |
| 318 | + run: | |
| 319 | + mkdir release |
| 320 | + mv release-with-dirs/*/* release/ |
| 321 | +
|
| 322 | + - name: Create Release |
| 323 | + id: create_release |
| 324 | + uses: softprops/action-gh-release@v2 |
| 325 | + env: |
| 326 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 327 | + with: |
| 328 | + tag_name: v${{ needs.build.outputs.tag }} |
| 329 | + files: | |
| 330 | + release/${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-Linux-arm64.7z |
| 331 | + release/${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-Linux-x64.7z |
| 332 | + release/${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-macOS-universal.7z |
| 333 | + release/${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-Windows-arm64.7z |
| 334 | + release/${{ env.PLUGIN_NAME}}-${{ env.QT_CREATOR_VERSION }}-Windows-x64.7z |
| 335 | + draft: false |
| 336 | + prerelease: false |
| 337 | + |
| 338 | + - name: Release on Extension Store |
| 339 | + uses: qt-creator/[email protected] |
| 340 | + with: |
| 341 | + api: ${{ secrets.EXTENSION_STORE_API_URL }} |
| 342 | + token: ${{ secrets.EXTENSION_STORE_API_TOKEN }} |
| 343 | + publish: true |
| 344 | + spec: release/${{ env.PLUGIN_NAME }}.json |
| 345 | + download-url-linux-arm64: ${{ fromJSON(steps.create_release.outputs.assets)[0].browser_download_url }} |
| 346 | + download-url-linux-x64: ${{ fromJSON(steps.create_release.outputs.assets)[1].browser_download_url }} |
| 347 | + download-url-macos-arm64: ${{ fromJSON(steps.create_release.outputs.assets)[2].browser_download_url }} |
| 348 | + download-url-macos-x64: ${{ fromJSON(steps.create_release.outputs.assets)[2].browser_download_url }} |
| 349 | + download-url-win-arm64: ${{ fromJSON(steps.create_release.outputs.assets)[3].browser_download_url }} |
| 350 | + download-url-win-x64: ${{ fromJSON(steps.create_release.outputs.assets)[4].browser_download_url }} |
0 commit comments