Skip to content

Commit

Permalink
try fix macOS CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tamlok committed May 12, 2024
1 parent f5b69b7 commit 4f1c67e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 87 deletions.
95 changes: 18 additions & 77 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@ on:

env:
VNOTE_VER: 3.17.0
CMAKE_VER: 3.24.3

jobs:
build:
name: Build On MacOS
runs-on: macos-latest
timeout-minutes: 120

strategy:
matrix:
config:
# - {
# name: "Build Qt 5.12",
# qt: 5.12.12
# }
- {
name: "Build Qt 5.15",
qt: 5.15.2
}

steps:
# Checks-out your repository under $GITHUB_WORKSPACE.
- uses: actions/checkout@v2
Expand All @@ -46,6 +35,15 @@ jobs:
run: |
brew install tree
- name: Install a fresh CMake
run: |
wget --no-verbose https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-Darwin-x86_64.tar.gz
tar xzf cmake-${CMAKE_VER}-Darwin-x86_64.tar.gz
sudo rm -f /usr/local/bin/cmake /usr/local/bin/cpack
sudo ln -s ${{runner.workspace}}/cmake-${CMAKE_VER}-Darwin-x86_64/CMake.app/Contents/bin/cmake /usr/local/bin/cmake
sudo ln -s ${{runner.workspace}}/cmake-${CMAKE_VER}-Darwin-x86_64/CMake.app/Contents/bin/cpack /usr/local/bin/cpack
working-directory: ${{runner.workspace}}

- name: Install macdeployqtfix
run: |
git clone https://github.com/tamlok/macdeployqtfix.git macdeployqtfix --depth=1
Expand All @@ -56,89 +54,32 @@ jobs:
uses: actions/cache@v1 # not v2!
with:
path: ../Qt
key: ${{ runner.os }}-QtCache-${{ matrix.config.qt }}
key: ${{ runner.os }}-QtCache-6.5

- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.config.qt }}
version: 6.5.3
target: desktop
modules: qtwebengine
cached: ${{ steps.cache-qt.outputs.cache-hit }}
modules: 'qtwebengine qtwebchannel qtpositioning qtpdf qtimageformats qt5compat qtserialport'
tools: 'tools_opensslv3_src'
cache: 'true'
setup-python: 'false'


- name: Create Build Dir
run: mkdir build
working-directory: ${{runner.workspace}}

- name: Configure Project
run: |
qmake -v
qmake CONFIG+=release ${GITHUB_WORKSPACE}/vnote.pro
cmake --version
cmake -DMACDEPLOYQTFIX_EXECUTABLE=${{runner.workspace}}/macdeployqtfix/macdeployqtfix.py ${GITHUB_WORKSPACE}
working-directory: ${{runner.workspace}}/build

- name: Build Project
run: make -j4
working-directory: ${{runner.workspace}}/build

- name: Deploy VSyntaxHighlighting Framework
run: |
my_lib_name=VSyntaxHighlighting
my_lib_framework=${my_lib_name}.framework
my_lib_dir=./libs/vtextedit/src/libs/syntax-highlighting
frameworks_dir=./src/vnote.app/Contents/Frameworks
mkdir -p ${frameworks_dir}
cp -R ${my_lib_dir}/${my_lib_framework} ${frameworks_dir}
working-directory: ${{runner.workspace}}/build

- name: Deploy VTextEdit Framework
run: |
my_lib_name=VTextEdit
my_lib_framework=${my_lib_name}.framework
my_lib_dir=./libs/vtextedit/src/editor
frameworks_dir=./src/vnote.app/Contents/Frameworks
mkdir -p ${frameworks_dir}
cp -R ${my_lib_dir}/${my_lib_framework} ${frameworks_dir}
working-directory: ${{runner.workspace}}/build

- name: Cleanup rpath
run: |
app_target=./src/vnote.app/Contents/MacOS/vnote
install_name_tool -delete_rpath ${PWD}/src/../libs/vtextedit/src/editor ${app_target}
install_name_tool -delete_rpath ${PWD}/src/../libs/vtextedit/src/libs/syntax-highlighting ${app_target}
working-directory: ${{runner.workspace}}/build

- name: Mac Deploy
run: |
pushd src
macdeployqt vnote.app
# Remove unused sql drivers
rm vnote.app/Contents/Plugins/sqldrivers/libqsqlodbc.dylib
rm vnote.app/Contents/Plugins/sqldrivers/libqsqlpsql.dylib
python ${{runner.workspace}}/macdeployqtfix/macdeployqtfix.py vnote.app/Contents/MacOS/vnote $Qt5_Dir
# Fix Helpers/QtWebEngineProcess.app
pushd vnote.app/Contents/Frameworks/QtWebEngineCore.framework/Versions/5/Helpers
python ${{runner.workspace}}/macdeployqtfix/macdeployqtfix.py QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess $Qt5_Dir
popd
popd
tree ./
working-directory: ${{runner.workspace}}/build

- name: Package Project
run: |
mkdir -p distrib/vnote
pushd distrib/vnote
mv ../../src/vnote.app ./
ln -s /Applications ./Applications
popd
sleep 60
hdiutil create -srcfolder ./distrib/vnote -format UDBZ vnote-mac-x64_v${{env.VNOTE_VER}}.dmg
cp vnote-mac-x64_v${{env.VNOTE_VER}}.dmg vnote-mac-x64-qt${{matrix.config.qt}}.dmg
mv vnote-mac-x64_v${{env.VNOTE_VER}}.dmg vnote-mac-x64-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.dmg
cmake --build . --target pack
working-directory: ${{runner.workspace}}/build

- name: Archive Artifacts
Expand Down
27 changes: 21 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,33 @@ if(WIN32)
endif()

# Installation
install(TARGETS vnote
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/vnote_extra.rcc"
DESTINATION ${CMAKE_INSTALL_BINDIR})

if (WIN32)
install(FILES "${PROJECT_SOURCE_DIR}/package/qt.conf"
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS vnote RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${PROJECT_SOURCE_DIR}/package/qt.conf" DESTINATION ${CMAKE_INSTALL_BINDIR})
elseif(APPLE)

set(CMAKE_MACOSX_BUNDLE ON)
set(CMAKE_MACOSX_RPATH ON)
install(TARGETS vnote BUNDLE DESTINATION . RUNTIME DESTINATION .)
set_target_properties(vnote
PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}"
MACOSX_BUNDLE_INFO_STRING "${PROJECT_DESCRIPTION}"
MACOSX_BUNDLE_ICON_FILE "${VX_APP_ICON_MACOS}"
MACOSX_BUNDLE_GUI_IDENTIFIER "fun.vnote.app"
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_COPYRIGHT "Distributed under LGPL-3.0 license. Copyright (c) 2024 app.vnote.fun"
)
else()
install(TARGETS vnote
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

set(desktop.path applications)
set(desktop.files data/core/vnote.desktop)
set(icon16.path icons/hicolor/16x16/apps)
Expand Down
4 changes: 4 additions & 0 deletions src/CPackMacDeployQt.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute_process(COMMAND "${MACDEPLOYQT_EXECUTABLE}" ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app -dmg
--always-overwirte
WORKING_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}
)
20 changes: 17 additions & 3 deletions src/Packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ add_dependencies(pack lrelease)

set(CPACK_GENERATOR)

set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_LIST_DIR}/data/core/logo/64x64/vnote.png")

if(WIN32)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}" DOC "Path to the windeployqt utility")

Expand All @@ -124,19 +126,31 @@ if(WIN32)

windeployqt(vnote)
elseif(APPLE)
message(STATUS "MACDeployQtExecutable: ${MACDEPLOYQT_EXECUTABLE}")
if (MACDEPLOYQT_EXECUTABLE)
message(STATUS "Package generation - MacOS - DMG")

list(APPEND CPACK_GENERATOR External)
set(CPACK_BUNDLE_NAME "${PROJECT_NAME}" )
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_LIST_DIR}/data/core/Info.plist")
set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_LIST_DIR}/data/core/icons/vnote.icns")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
set(CPACK_DMG_FORMAT "UDBZ")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CPackMacDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
include(InstallRequiredSystemLibraries)
endif()
else()
message(STATUS "LinuxDeployExecutable: ${LINUXDEPLOY_EXECUTABLE}")
if(LINUXDEPLOY_EXECUTABLE)
message(STATUS "Package generation - Linux - AppImage")

set(CPACK_GENERATOR "External;${CPACK_GENERATOR}")
list(APPEND CPACK_GENERATOR External)
set(VX_APPIMAGE_DEST_DIR "${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/Linux/External/AppImage")
set(VX_APPIMAGE_DESKTOP_FILE "${VX_APPIMAGE_DEST_DIR}${CMAKE_INSTALL_PREFIX}/share/applications/vnote.desktop")
configure_file(${CMAKE_CURRENT_LIST_DIR}/CPackLinuxDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
endif()

set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_LIST_DIR}/data/core/logo/64x64/vnote.png")
endif()

include(CPack)
2 changes: 1 addition & 1 deletion src/data/core/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<key>CFBundleIconFile</key>
<string>vnote.icns</string>
<key>CFBundleIdentifier</key>
<string>com.vnotex.vnote</string>
<string>fun.vnote.app</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
Expand Down

0 comments on commit 4f1c67e

Please sign in to comment.