Update cmake-multi-platform.yml #154
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: | | ||
Check failure on line 108 in .github/workflows/cmake-multi-platform.yml
|
||
TAG_NAME=${GITHUB_REF#refs/tags/} | ||
if [ "${{ runner.os }}" == "Linux" ]; then | ||
cd ${{ steps.strings.outputs.build-output-dir }}/install && tar -cvzf ../../dartomato-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ TAG_NAME }}.tar.gz * | ||
else | ||
pwsh -Command "Compress-Archive -Path '${{ steps.strings.outputs.build-output-dir }}/bin/*' -DestinationPath 'dartomato-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ TAG_NAME }}.zip'" | ||
fi | ||
shell: bash | ||
- name: Upload Artifacts | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dartomat-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ TAG_NAME }} | ||
path: dartomat-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ TAG_NAME }}.${{ runner.os == 'Linux' && 'tar.gz' || 'zip' }} | ||
deploy: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
- name: Get Tag Name | ||
id: get_tag | ||
run: | | ||
TAG_NAME=$(git describe --tags --abbrev=0) | ||
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | ||
- name: Debug Tag | ||
run: echo "Using tag $TAG_NAME" | ||
- name: Download Linux Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dartomato-build-ubuntu-latest-Release-${{ steps.get_tag.outputs.TAG_NAME }} | ||
path: ./linux/ | ||
- name: Download Windows Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dartomato-build-windows-latest-Release-${{ steps.get_tag.outputs.TAG_NAME }} | ||
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/dartomato-build-ubuntu-latest-Release-${{ steps.get_tag.outputs.TAG_NAME }}.tar.gz | ||
asset_name: dartomato-build-ubuntu-latest-Release-${{ steps.get_tag.outputs.TAG_NAME }}.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/dartomato-build-windows-latest-Release-${{ steps.get_tag.outputs.TAG_NAME }}.zip | ||
asset_name: dartomato-build-windows-latest-Release-${{ steps.get_tag.outputs.TAG_NAME }}.zip | ||
asset_content_type: application/zip | ||