Skip to content

CMake support for Qt5 and Qt6 #1033

CMake support for Qt5 and Qt6

CMake support for Qt5 and Qt6 #1033

Workflow file for this run

name: Build Notepad Next
on:
push:
branches:
- master
tags:
- '*'
pull_request:
env:
QT_RELEASE_VER: 6.8
jobs:
cmake-build:
strategy:
fail-fast: false
matrix:
config:
-
qt_version: 6.6
modules: "qt5compat"
os: ubuntu-20.04
-
qt_version: 6.6
modules: "qt5compat"
os: windows-latest
-
qt_version: 6.6
modules: "qt5compat"
os: macos-latest
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.config.qt_version }}
modules: ${{ matrix.config.modules }}
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Setup (Linux)
if: startsWith (matrix.config.os, 'ubuntu')
run: |
echo "DISTRIBUTION=AppImage" >> "$GITHUB_ENV"
sudo apt-get install libxkbcommon-dev libxkbcommon-x11-0 fuse libxcb-cursor-dev libcups2-dev
- name: Setup VS tools (Windows)
if: startsWith (matrix.config.os, 'windows')
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Compile
run: |
cmake -S . -B cbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=ON
cmake --build cbuild
- name: Create App Image
if: startsWith (matrix.config.os, 'ubuntu')
run: |
cmake --install cbuild --prefix=${{ github.workspace }}/cbuild/AppDir/usr/
cd cbuild
wget --no-verbose "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget --no-verbose "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
chmod +x linuxdeploy*.AppImage
export OUTPUT=NotepadNext-x86_64.AppImage
export LD_LIBRARY_PATH=AppDir/usr/lib/:$LD_LIBRARY_PATH
export DEBUG=1
./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin qt --output appimage
- name: Upload AppImage
if: startsWith (matrix.config.os, 'ubuntu')
uses: actions/upload-artifact@v3
with:
name: NotepadNext-Linux-Qt${{ matrix.config.qt_version }}-cmake-AppImage
path: ${{ github.workspace }}/cbuild/NotepadNext-x86_64.AppImage
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest, osx-latest]
qt_version: ["5.15", "6.5", "6.6"]
exclude:
- os: macos-latest
qt_version: "6.8"
- os: osx-latest
qt_version: "5.15"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.qt_version }}
modules: ${{ matrix.qt_version != '5.15' && 'qt5compat' || '' }}
cache: true
- name: Get number of CPU cores
if: runner.os != 'Windows'
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Setup Visual Studio Tools
if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Install jom
if: runner.os == 'Windows'
run: choco install jom
- name: Setup Linux
if: runner.os == 'Linux'
run: |
echo "DISTRIBUTION=AppImage" >> "$GITHUB_ENV"
sudo apt-get install libxkbcommon-dev libxkbcommon-x11-0 fuse libxcb-cursor-dev
- name: Run QMake
run: |
mkdir build
cd build
qmake ../src/NotepadNext.pro "DISTRIBUTION=$DISTRIBUTION"
- name: Compile for Windows
if: runner.os == 'Windows'
run: |
cd build
jom
- name: Compile for Linux/macOS
if: runner.os != 'Windows'
run: |
cd build
make -j${{ steps.cpu-cores.outputs.count }}
- name: Create Windows zip Package
if: runner.os == 'Windows'
run: |
cd build
jom package
- name: Create Windows Installer
if: runner.os == 'Windows'
run: |
cd build
jom installer
- name: Create DMG
if: runner.os == 'macOS'
run: |
cd build
make dmg
- name: Create AppImage
if: runner.os == 'Linux'
run: |
cd build
make appimage
- name: Upload Windows zip Package
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: NotepadNext-Windows-Qt${{ matrix.qt_version }}-Zip
path: ${{ github.workspace }}/build/package/
- name: Upload Windows Installer
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: NotepadNext-Windows-Qt${{ matrix.qt_version }}-Installer
path: ${{ github.workspace }}/installer/NotepadNext*.exe
- name: Upload macOS dmg
uses: actions/upload-artifact@v4
if: runner.os == 'macOS'
with:
name: NotepadNext-macOS-Qt${{ matrix.qt_version }}
path: ${{ github.workspace }}/build/NotepadNext/NotepadNext*.dmg
- name: Upload Linux AppImage
uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
with:
name: NotepadNext-Linux-Qt${{ matrix.qt_version }}-AppImage
path: ${{ github.workspace }}/build/NotepadNext/NotepadNext*.AppImage
github:
name: Draft GitHub Release
runs-on: ubuntu-latest
needs: [build]
if: github.repository == 'dail8859/NotepadNext' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Draft Release
run: |
gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --generate-notes --draft
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Upload Windows Installer
run: |
gh release upload ${{ github.ref_name }} NotepadNext-Windows-Qt$QT_RELEASE_VER-Installer/NotepadNext-${{ github.ref_name }}-Installer.exe
# The artifact is unzipped, so need to zip it back up so it can be uploaded
- name: Upload Windows Zip
run: |
cd NotepadNext-Windows-Qt$QT_RELEASE_VER-Zip/
zip -r ../NotepadNext-${{ github.ref_name }}-win64.zip .
cd ..
gh release upload ${{ github.ref_name }} NotepadNext-${{ github.ref_name }}-win64.zip
- name: Upload Linux AppImage
run: |
gh release upload ${{ github.ref_name }} NotepadNext-Linux-Qt$QT_RELEASE_VER-AppImage/NotepadNext-${{ github.ref_name }}-x86_64.AppImage
- name: Upload macOS App
run: |
gh release upload ${{ github.ref_name }} NotepadNext-macOS-Qt$QT_RELEASE_VER/NotepadNext-${{ github.ref_name }}.dmg