Skip to content

Commit

Permalink
try fix Win CI (#2492)
Browse files Browse the repository at this point in the history
fix CI and openssl
  • Loading branch information
tamlok committed May 3, 2024
1 parent a049689 commit 522b374
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 94 deletions.
123 changes: 38 additions & 85 deletions .github/workflows/ci-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:

# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled'
required: false
default: false

env:
VNOTE_VER: 3.17.0
Expand All @@ -19,23 +25,26 @@ jobs:
timeout-minutes: 120

strategy:
fail-fast: false
matrix:
config:
- {
name: "Build On Win64 Qt 5.15",
arch: win64_msvc2019_64,
platform: x64,
qt: 5.15.2,
qt_modules: qtwebengine,
qt_tools: tools_opensslv3_x64
qt_tools: tools_opensslv3_x64,
qt_major: 5,
suffix: "-windows7"
}
- {
name: "Build On Win64 Qt 6.5",
arch: win64_msvc2019_64,
platform: x64,
qt: 6.5.2,
qt_modules: "qtwebengine qtwebchannel qtpositioning qtpdf qtimageformats qt5compat",
qt_tools: tools_opensslv3_x64
qt_tools: tools_opensslv3_x64,
qt_major: 6,
suffix: ""
}

steps:
Expand Down Expand Up @@ -80,94 +89,44 @@ jobs:
git clone https://github.com/tamlok/openssl-utils.git openssl-utils.git --depth=1
working-directory: ${{runner.workspace}}/build

- name: Download JOM
uses: suisei-cn/actions-download-file@v1
with:
url: http://download.qt.io/official_releases/jom/jom.zip
target: ${{runner.temp}}\

- name: Unzip JOM
run: |
7z x jom.zip -ojom
working-directory: ${{runner.temp}}
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Configure and Build Project
shell: cmd
run: |
qmake --version
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{matrix.config.platform}}
qmake -r -spec win32-msvc CONFIG-=debug CONFIG+=release %GITHUB_WORKSPACE%\vnote.pro
${{runner.temp}}\jom\jom
working-directory: ${{runner.workspace}}/build

- name: Package Project 1
shell: cmd
run: |
qmake --version
mkdir "%DISTRIB_PATH%"
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{matrix.config.platform}}
windeployqt.exe --dir "%DISTRIB_PATH%" .\src\release\vnote.exe
copy .\src\release\vnote.exe "%DISTRIB_PATH%\vnote.exe"
copy .\src\release\vnote_extra.rcc "%DISTRIB_PATH%\vnote_extra.rcc"
copy .\libs\vtextedit\src\libs\syntax-highlighting\release\VSyntaxHighlighting.dll "%DISTRIB_PATH%\VSyntaxHighlighting.dll"
copy .\libs\vtextedit\src\editor\release\VTextEdit.dll "%DISTRIB_PATH%\VTextEdit.dll"
copy "%GITHUB_WORKSPACE%\package\qt.conf" "%DISTRIB_PATH%\qt.conf"
copy "%GITHUB_WORKSPACE%\README.md" "%DISTRIB_PATH%\README.md"
copy "%GITHUB_WORKSPACE%\COPYING.LESSER" "%DISTRIB_PATH%\COPYING.LESSER"
echo %GITHUB_SHA% > "%DISTRIB_PATH%\commit"
del /F /Q "%DISTRIB_PATH%\translations\qt_*.qm"
cmake --version
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DQT_DEFAULT_MAJOR_VERSION=${{matrix.config.qt_major}} -DOPENSSL_EXTRA_LIB_DIR=${{runner.workspace}}\build\openssl-utils.git\1.1.1j\Win_x64 %GITHUB_WORKSPACE%
cmake --build .
cmake --build . --target=deploy
cmake --build . --target=pack
cmake --build . --target=install
7z x VNote*.zip -o*
dir
working-directory: ${{runner.workspace}}/build
env:
DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote

- name: "Package Project: Copy OpenSSL on 5.15"
shell: cmd
- name: Rename on 5.15
shell: bash
if: ${{startsWith(matrix.config.qt, '5.15')}}
run: |
set openssl_dir=openssl-utils.git\1.1.1j\Win_${{matrix.config.platform}}
copy %openssl_dir%\lib*.dll "%DISTRIB_PATH%\"
working-directory: ${{runner.workspace}}/build
env:
DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote

- name: Package Project 2
shell: cmd
run: |
7z a vnote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}.zip "%DISTRIB_PATH%"
copy vnote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}.zip vnote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.zip
working-directory: ${{runner.workspace}}/build
env:
DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote

- name: Package Installer
if: ${{startsWith(matrix.config.qt, '6.')}}
shell: cmd
run: |
copy "%GITHUB_WORKSPACE%\src\data\core\icons\vnote.ico" "%DISTRIB_PATH%\vnote.ico"
git clone https://github.com/vnotex/mkmsi.git mkmsi.git --depth=1
python .\mkmsi.git\mkmsi.py --auto-create qt --source-dir "%DISTRIB_PATH%" --wix-root "C:\Program Files (x86)\WiX Toolset v3.11" --merge-module "C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC140_CRT_${{matrix.config.platform}}.msm" --add-desktop-shortcut --project-version ${{env.VNOTE_VER}} --license %GITHUB_WORKSPACE%\package\lgpl-3.0.rtf --executable vnote.exe --wix-banner %GITHUB_WORKSPACE%\package\wix_banner.png --wix-dialog %GITHUB_WORKSPACE%\package\wix_dialog.png VNote
move VNote.msi .\distrib\VNote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.msi
del "%DISTRIB_PATH%\vnote.ico"
mv VNote-${{env.VNOTE_VER}}-win64 VNote-${{env.VNOTE_VER}}-win64${{matrix.config.suffix}}
working-directory: ${{runner.workspace}}/build
env:
DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote

- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: vnote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}
path: ${{env.DISTRIB_PATH}}
env:
DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote
name: VNote-${{env.VNOTE_VER}}-win64${{matrix.config.suffix}}
path: ${{runner.workspace}}/build/VNote-${{env.VNOTE_VER}}-win64${{matrix.config.suffix}}

- name: Archive Installer
if: ${{startsWith(matrix.config.qt, '6.')}}
if: ${{!startsWith(matrix.config.qt, '5.15')}}
uses: actions/upload-artifact@v2
with:
name: VNote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.msi
path: ${{runner.workspace}}/build/distrib/VNote*.msi
env:
DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote
name: VNote-${{env.VNOTE_VER}}-win64${{matrix.config.suffix}}.msi
path: ${{runner.workspace}}/build/VNote*.msi

- name: Update Tag
if: github.ref == 'refs/heads/master'
Expand All @@ -181,24 +140,18 @@ jobs:
uses: johnwbyrd/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: ${{runner.workspace}}/build/vnote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}.zip
# glob not supported
files: ${{runner.workspace}}/build/VNote-${{env.VNOTE_VER}}-win64${{matrix.config.suffix}}
release: Continuous Build
tag: continuous-build

- name: Test
shell: cmd
run: |
dir .
dir .\distrib
working-directory: ${{runner.workspace}}/build

- name: Release
if: github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, '[Release]')
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
# We need hard code here.
artifacts: "D:/a/vnote/build/vnote-win-${{matrix.config.platform}}-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.zip"
# glob not supported
artifacts: ${{runner.workspace}}/build/VNote-${{env.VNOTE_VER}}-win64${{matrix.config.suffix}}
commit: master
tag: v${{env.VNOTE_VER}}
allowUpdates: true
Expand Down
34 changes: 25 additions & 9 deletions src/Packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@

find_package(Qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED COMPONENTS Core)

get_target_property(QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
get_target_property(QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
get_filename_component(QT_BIN_DIR "${QMAKE_EXECUTABLE}" DIRECTORY)
execute_process(COMMAND ${QMAKE_EXECUTABLE} -query QT_VERSION OUTPUT_VARIABLE QT_VERSION)

set(QT_TOOLS_DIR "${QT_BIN_DIR}/../../../Tools")

# To use the specific version of Qt
set(WINDEPLOYQT_EXECUTABLE "${QT_BIN_DIR}/windeployqt")
set(WINDEPLOYQT_EXECUTABLE "${QT_BIN_DIR}/windeployqt.exe")

find_program(LINUXDEPLOY_EXECUTABLE linuxdeploy linuxdeploy-x86_64.AppImage HINTS "${QT_BIN_DIR}")
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${QT_BIN_DIR}")
find_program(MACDEPLOYQTFIX_EXECUTABLE macdeployqtfix.py HINTS "${QT_BIN_DIR}")
find_package(Python)

mark_as_advanced(WINDEPLOYQT_EXECUTABLE LINUXDEPLOY_EXECUTABLE MACDEPLOYQT_EXECUTABLE)

function(windeployqt target)
# Bundle Library Files
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)

if(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
set(WINDEPLOYQT_ARGS --debug)
else()
set(WINDEPLOYQT_ARGS --release)
if ((QT_DEFAULT_MAJOR_VERSION GREATER 5))
if(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
set(WINDEPLOYQT_ARGS --debug)
else()
set(WINDEPLOYQT_ARGS --release)
endif()
endif()

message(INFO " debug: windeployqt:${WINDEPLOYQT_EXECUTABLE}")

add_custom_target(deploy
COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/winqt/"
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}"
${WINDEPLOYQT_ARGS}
--verbose 0
--no-quick-import
--no-opengl-sw
--no-compiler-runtime
Expand All @@ -48,6 +51,19 @@ function(windeployqt target)
add_dependencies(deploy lrelease)

install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/winqt/" DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)

cmake_path(NORMAL_PATH QT_TOOLS_DIR OUTPUT_VARIABLE QT_TOOLS_DIR)
set(OPENSSL_ROOT_DIR "${QT_TOOLS_DIR}/OpenSSL/Win_x64" CACHE STRING "OpenSSL dir")
file(GLOB OPENSSL_LIBS_FILES "${OPENSSL_ROOT_DIR}/bin/lib*.dll")
cmake_path(NORMAL_PATH OPENSSL_LIBS_FILES OUTPUT_VARIABLE OPENSSL_LIBS_FILES)
install(FILES ${OPENSSL_LIBS_FILES} DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)

message(INFO " debug: OpenSSLExtraLIBDIR:${OPENSSL_EXTRA_LIB_DIR}")
file(GLOB OPENSSL_EXTRA_LIB_FILES "${OPENSSL_EXTRA_LIB_DIR}/lib*.dll")
cmake_path(NORMAL_PATH OPENSSL_EXTRA_LIB_FILES OUTPUT_VARIABLE OPENSSL_EXTRA_LIB_FILES)
message(INFO " debug: OpenSSLExtraLibFiles:${OPENSSL_EXTRA_LIB_FILES}")
install(FILES ${OPENSSL_EXTRA_LIB_FILES} DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)

set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
endfunction()
Expand Down

0 comments on commit 522b374

Please sign in to comment.