Update cmake-multi-platform.yml #142
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: CI/CD | |
on: | |
push: | |
branches: [ "main" ] | |
tags: | |
- '*' | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
build_type: [Release] | |
c_compiler: [gcc, cl] | |
include: | |
- os: windows-latest | |
c_compiler: cl | |
cpp_compiler: cl | |
- os: ubuntu-latest | |
c_compiler: gcc | |
cpp_compiler: g++ | |
exclude: | |
- os: windows-latest | |
c_compiler: gcc | |
- os: ubuntu-latest | |
c_compiler: cl | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # complete history | |
fetch-tags: true | |
- name: Install Qt6 dependencies for Windows | |
if: runner.os == 'Windows' | |
uses: jurplel/install-qt-action@v4.0.0 | |
with: | |
aqtversion: '==3.1.*' | |
version: '6.6.1' | |
host: 'windows' | |
target: 'desktop' | |
arch: 'win64_msvc2019_64' | |
modules: 'qtcharts qtmultimedia' | |
- name: Install Qt6 dependencies for Linux | |
if: runner.os == 'Linux' | |
uses: jurplel/install-qt-action@v4.0.0 | |
with: | |
aqtversion: '==3.1.*' | |
version: '6.6.3' | |
host: 'linux' | |
target: 'desktop' | |
arch: 'gcc_64' | |
modules: 'qtcharts qtmultimedia' | |
- name: Set reusable strings | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
- name: Configure CMake for Windows | |
if: runner.os == 'Windows' | |
run: | | |
cmake -B ${{ steps.strings.outputs.build-output-dir }} ` | |
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ` | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ` | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ` | |
-DCMAKE_PREFIX_PATH=${{ env.Qt6_DIR }} ` | |
-DCMAKE_IS_GITHUB_WORKFLOW=ON ` | |
-S ${{ github.workspace }} | |
- name: Configure CMake for Linux | |
if: runner.os == 'Linux' | |
run: | | |
cmake -B ${{ steps.strings.outputs.build-output-dir }} \ | |
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-DCMAKE_PREFIX_PATH=/usr/lib/qt6 \ | |
-S ${{ github.workspace }} | |
- name: Check Deployment Script | |
if: runner.os == 'Windows' | |
run: ls -R D:/a/dartomato/dartomato/build/.qt | |
- name: Build | |
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | |
- name: Test | |
working-directory: ${{ steps.strings.outputs.build-output-dir }}/tests | |
run: ctest --build-config ${{ matrix.build_type }} | |
- name: Install Build Output | |
run: cmake --install ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --strip | |
- name: Compress Build Output | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
if [ "${{ runner.os }}" == "Linux" ]; then | |
cd ${{ steps.strings.outputs.build-output-dir }}/install && tar -cvzf ../../build-${{ matrix.os }}-${{ matrix.build_type }}.tar.gz . | |
else | |
pwsh -Command "Compress-Archive -Path '${{ steps.strings.outputs.build-output-dir }}/bin/*' -DestinationPath 'build-${{ matrix.os }}-${{ matrix.build_type }}.zip'" | |
fi | |
shell: bash | |
- name: Upload Artifacts | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-${{ matrix.os }}-${{ matrix.build_type }} | |
path: build-${{ matrix.os }}-${{ matrix.build_type }}.${{ runner.os == 'Linux' && 'tar.gz' || 'zip' }} | |
deploy: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: build | |
runs-on: ubuntu-latest # Choose a single runner for the deploy step | |
steps: | |
- name: Download Linux Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-ubuntu-latest-Release # Adjust OS and build type names | |
path: ./linux/ | |
- name: Download Windows Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-windows-latest-Release # Adjust OS and build type names | |
path: ./windows/ | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: "Release ${{ github.ref }}" | |
draft: false | |
prerelease: false | |
- name: Upload Linux Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./linux/build-ubuntu-latest-Release.tar.gz | |
asset_name: build-ubuntu-latest-Release.tar.gz | |
asset_content_type: application/gzip | |
- name: Upload Windows Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./windows/build-windows-latest-Release.zip | |
asset_name: build-windows-latest-Release.zip | |
asset_content_type: application/zip | |