Switch to Gitlab Actions #9
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
name: QMake Build Matrix | |
on: [push] | |
env: | |
QT_VERSION: 6.8.0 | |
jobs: | |
build: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: | |
- { | |
name: "Windows Latest x64", | |
artifact: "Windows-x64.zip", | |
arch: win64_msvc2022_64, | |
os: windows-latest, | |
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" | |
} | |
- { | |
name: "Linux Latest x64", | |
artifact: "Linux-x64.zip", | |
arch: "", | |
os: ubuntu-latest | |
} | |
# - { | |
# name: "macOS Latest x64", | |
# artifact: "macOS-x64.zip", | |
# arch: "", | |
# os: macos-latest | |
# } | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Installing system libs | |
shell: cmake -P {0} | |
run: | | |
if ("${{ runner.os }}" STREQUAL "Linux") | |
execute_process( | |
COMMAND sudo apt install libusb-1.0-0-dev | |
) | |
endif() | |
- name: Download Qt | |
id: qt | |
uses: jurplel/install-qt-action@v4 | |
with: | |
version: "${{ env.QT_VERSION }}" | |
arch: "${{ matrix.config.arch }}" | |
- name: Configure | |
shell: cmake -P {0} | |
run: | | |
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}") | |
# Set for other steps | |
message("::set-env name=${CMAKE_MATCH_1}::${CMAKE_MATCH_2}") | |
endif() | |
endforeach() | |
endif() | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qtcreator" qtcreator_dir) | |
execute_process( | |
COMMAND qmake | |
$ENV{PLUGIN_PRO} | |
CONFIG+=release | |
QTC_SOURCE="${qtcreator_dir}" | |
QTC_BUILD="${qtcreator_dir}" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
- name: Build | |
shell: cmake -P {0} | |
run: | | |
if (NOT "${{ runner.os }}" STREQUAL "Windows") | |
set(ENV{LD_LIBRARY_PATH} "qtcreator/lib/Qt/lib:$ENV{LD_LIBRARY_PATH}") | |
endif() | |
include(ProcessorCount) | |
ProcessorCount(N) | |
set(make_program make -j ${N}) | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(make_program "qtcreator/bin/jom") | |
endif() | |
execute_process( | |
COMMAND ${make_program} | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/$ENV{PLUGIN_NAME}-$ENV{QT_CREATOR_VERSION}-${{ matrix.config.artifact }}" artifact) | |
execute_process(COMMAND | |
${CMAKE_COMMAND} -E tar cvf ${artifact} --format=zip "${{ steps.qt_creator.outputs.qtc_binary_name }}" | |
WORKING_DIRECTORY "${{ steps.qt_creator.outputs.qtc_output_directory }}" | |
) | |
- uses: actions/upload-artifact@v4 | |
id: upload_artifact | |
with: | |
path: ./qtusb-${{ matrix.config.artifact }} | |
name: qtusb-${{ matrix.config.artifact }} | |
release: | |
if: contains(github.ref, 'tags/v') | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Store Release url | |
run: | | |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url | |
- uses: actions/upload-artifact@v1 | |
with: | |
path: ./upload_url | |
name: upload_url | |
publish: | |
if: contains(github.ref, 'tags/v') | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: | |
- { | |
name: "Windows Latest x64", | |
artifact: "Windows-x64.zip", | |
os: ubuntu-latest | |
} | |
- { | |
name: "Linux Latest x64", | |
artifact: "Linux-x64.zip", | |
os: ubuntu-latest | |
} | |
# - { | |
# name: "macOS Latest x64", | |
# artifact: "macOS-x64.zip", | |
# os: macos-latest | |
# } | |
needs: release | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${{ env.PLUGIN_NAME }}-${{ env.QT_CREATOR_VERSION }}-${{ matrix.config.artifact }} | |
path: ./ | |
- name: Download URL | |
uses: actions/download-artifact@v1 | |
with: | |
name: upload_url | |
path: ./ | |
- id: set_upload_url | |
run: | | |
upload_url=`cat ./upload_url` | |
echo ::set-output name=upload_url::$upload_url | |
- name: Upload to Release | |
id: upload_to_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.set_upload_url.outputs.upload_url }} | |
asset_path: ./qtusb-${{ matrix.config.artifact }} | |
asset_name: qtusb}-${{ matrix.config.artifact }} | |
asset_content_type: application/zip |