Browse Source

CI on Linux and Win (#1582)

Le Tan 4 năm trước cách đây
mục cha
commit
13af4b2ed1

+ 127 - 0
.github/workflows/ci-linux.yml

@@ -0,0 +1,127 @@
+name: CI-Linux
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+  # Allows you to run this workflow manually from the Actions tab.
+  workflow_dispatch:
+
+env:
+    VNOTE_VER: 3.0.0
+
+jobs:
+  build-linux:
+    name: Build On Ubuntu
+    runs-on: ubuntu-latest
+    timeout-minutes: 120
+
+    steps:
+      # Checks-out your repository under $GITHUB_WORKSPACE.
+      - uses: actions/checkout@v2
+        with:
+          fetch-depth: 1
+
+      - name: Init Submodules
+        shell: bash
+        run: |
+          auth_header="$(git config --local --get http.https://github.com/.extraheader)"
+          git submodule sync --recursive
+          git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
+
+      - name: Install linuxdeploy
+        uses: miurahr/install-linuxdeploy-action@v1
+        with:
+            plugins: qt appimage
+
+      - name: Install dependencies
+        run: |
+            sudo DEBIAN_FRONTEND=noninteractive apt-get update
+            sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libfcitx-qt5-dev tree
+
+      - name: Install Qt
+        uses: jurplel/install-qt-action@v2
+        with:
+          version: 5.12.10
+          target: desktop
+          arch: ${{matrix.config.arch}}
+          modules: qtwebchannel qtwebengine qtsvg qtlocation qttools qttranslations
+          tools: tools_openssl_x64,1.1.1-4,qt.tools.openssl.gcc_64
+
+      - name: Create Build Dir
+        shell: bash
+        run: mkdir build
+        working-directory: ${{runner.workspace}}
+
+      - name: Compile qt5ct
+        shell: bash
+        run: |
+            wget -c https://excellmedia.dl.sourceforge.net/project/qt5ct/qt5ct-1.1.tar.bz2
+            tar xf qt5ct-1.*.tar.bz2
+            cd qt5ct-1.*/
+            QT_SELECT=5 qmake
+            make -j$(nproc) && sudo make install
+        working-directory: ${{runner.workspace}}/build
+
+      - name: Configure Project
+        shell: bash
+        run: |
+            qmake -v
+            cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so ./
+            sudo chmod +rwx ./libfcitxplatforminputcontextplugin.so
+            cp ./libfcitxplatforminputcontextplugin.so $Qt5_Dir/plugins/platforminputcontexts
+            qmake CONFIG+=release -spec linux-g++-64 ${GITHUB_WORKSPACE}/vnote.pro
+        working-directory: ${{runner.workspace}}/build
+
+      - name: Build Project
+        shell: bash
+        run: make -j$(nproc)
+        working-directory: ${{runner.workspace}}/build
+
+      - name: Install Project
+        shell: bash
+        run: |
+          mkdir AppDir
+          make install INSTALL_ROOT=${{runner.workspace}}/build/AppDir
+          tree AppDir
+        working-directory: ${{runner.workspace}}/build
+
+      - name: Package Project
+        shell: bash
+        run: |
+          # Move the lib out to avoid duplication
+          mv AppDir/usr/lib ./
+          LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
+          # copy translations
+          mkdir -p AppDir/usr/translations
+          cp $Qt5_Dir/translations/qt_zh_CN.qm AppDir/usr/translations
+          # package qt5ct (EXTRA_QT_PLUGINS seems not work)
+          # EXTRA_QT_PLUGINS="platformthemes/libqt5ct.so;styles/libqt5ct-style.so"
+          mkdir -p AppDir/usr/plugins/platformthemes
+          mkdir -p AppDir/usr/plugins/styles
+          cp $Qt5_Dir/plugins/platformthemes/* AppDir/usr/plugins/platformthemes/
+          cp $Qt5_Dir/plugins/styles/* AppDir/usr/plugins/styles/
+          # package libssl.so and libcrypto.so
+          Qt5_Tools=$Qt5_Dir/../../Tools
+          linuxdeploy-x86_64.AppImage --appdir ./AppDir --plugin qt --output appimage -l $Qt5_Tools/OpenSSL/binary/lib/libcrypto.so.1.1 -l $Qt5_Tools/OpenSSL/binary/lib/libssl.so.1.1
+          mv VNote*.AppImage vnote-linux-x64_v${{env.VNOTE_VER}}.AppImage
+          cp vnote-linux-x64_v${{env.VNOTE_VER}}.AppImage vnote-linux-x64.AppImage
+          tree AppDir
+        working-directory: ${{runner.workspace}}/build
+
+      - name: Archive Artifacts
+        uses: actions/upload-artifact@v2
+        with:
+          name: vnote-linux-x64_v${{env.VNOTE_VER}}
+          path: ${{runner.workspace}}/build/vnote-linux-x64_v${{env.VNOTE_VER}}.AppImage
+
+      - name: Update Continuous Build Release
+        if: github.ref == 'refs/heads/master'
+        uses: johnwbyrd/[email protected]
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+          files: ${{runner.workspace}}/build/vnote-linux-x64.AppImage
+          release: Continuous Build
+          tag: continuous-build

+ 11 - 1
.github/workflows/ci-win.yml

@@ -81,7 +81,7 @@ jobs:
           windeployqt.exe --dir "%DISTRIB_PATH%" .\src\release\vnote.exe
           copy .\src\release\vnote.exe "%DISTRIB_PATH%\vnote.exe"
           copy .\src\release\extra.rcc "%DISTRIB_PATH%\extra.rcc"
-          copy .\libs\vtextedit\src\libs\syntax-highlighting\release\KSyntaxHighlighting.dll "%DISTRIB_PATH%\KSyntaxHighlighting.dll"
+          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"
           rem set qt_dir=%Qt5_Dir:/=\%
           rem for %%I in ("%qt_dir%\..\..") do set "qt_topdir=%%~fI"
@@ -92,6 +92,7 @@ jobs:
           copy "%GITHUB_WORKSPACE%\COPYING.LESSER" "%DISTRIB_PATH%\COPYING.LESSER"
           echo %GITHUB_SHA% > "%DISTRIB_PATH%\commit"
           del /F /Q "%DISTRIB_PATH%\translations\qt_*.qm"
+          7z a vnote-win-${{matrix.config.platform}}.zip "%DISTRIB_PATH%"
         working-directory: ${{runner.workspace}}/build
         env:
           DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote
@@ -103,3 +104,12 @@ jobs:
           path: ${{env.DISTRIB_PATH}}
         env:
           DISTRIB_PATH: ${{runner.workspace}}/build/distrib/vnote
+
+      - name: Update Continuous Build Release
+        if: github.ref == 'refs/heads/master'
+        uses: johnwbyrd/[email protected]
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+          files: ${{runner.workspace}}/build/vnote-win-${{matrix.config.platform}}.zip
+          release: Continuous Build
+          tag: continuous-build

+ 1 - 1
libs/vtextedit

@@ -1 +1 @@
-Subproject commit 1dacef91657e44b110218a377a27a10bfd762616
+Subproject commit 00aa03be1fee3bd661e88d0250af8a3db33c73b3

+ 2 - 1
src/core/configmgr.cpp

@@ -158,7 +158,8 @@ void ConfigMgr::checkAppConfig()
 
     // Load extra data.
     splash->showMessage("Loading extra resource data");
-    const QString extraRcc(QStringLiteral("extra.rcc"));
+    const QString extraRcc(PathUtils::concatenateFilePath(QCoreApplication::applicationDirPath(),
+                                                          QStringLiteral("vnote_extra.rcc")));
     bool ret = QResource::registerResource(extraRcc);
     if (!ret) {
         Exception::throwOne(Exception::Type::FailToReadFile,

BIN
src/data/core/logo/128x128/vnote.png


BIN
src/data/core/logo/16x16/vnote.png


BIN
src/data/core/logo/256x256/vnote.png


BIN
src/data/core/logo/32x32/vnote.png


BIN
src/data/core/logo/48x48/vnote.png


BIN
src/data/core/logo/64x64/vnote.png


+ 13 - 0
src/data/core/vnote.desktop

@@ -0,0 +1,13 @@
+[Desktop Entry]
+Type=Application
+Name=VNote
+Name[zh]=VNote笔记
+GenericName=Note-taking Application
+GenericName[zh]=笔记软件
+Comment=A pleasant note-taking platform
+Comment[zh]=一个舒适的笔记平台
+Icon=vnote
+Terminal=false
+Exec=vnote %F
+MimeType=text/markdown;
+Categories=Qt;Utility;TextEditor;Office;

+ 48 - 4
src/src.pro

@@ -13,11 +13,11 @@ TARGET = vnote
 TEMPLATE = app
 
 win32:CONFIG(release, debug|release) {
-    DESTDIR = $$OUT_PWD/release
+    SRC_DESTDIR = $$OUT_PWD/release
 } else:win32:CONFIG(debug, debug|release) {
-    DESTDIR = $$OUT_PWD/debug
+    SRC_DESTDIR = $$OUT_PWD/debug
 } else {
-    DESTDIR = $$OUT_PWD
+    SRC_DESTDIR = $$OUT_PWD
 }
 
 RC_ICONS = data/core/icons/vnote.ico
@@ -53,8 +53,52 @@ win32 {
     rcc_binary.depend_command = $$[QT_HOST_BINS]/rcc -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
 }
 rcc_binary.input = RCC_BINARY_SOURCES
-rcc_binary.output = $$DESTDIR/${QMAKE_FILE_IN_BASE}.rcc
+rcc_binary.output = $$SRC_DESTDIR/vnote_${QMAKE_FILE_IN_BASE}.rcc
 rcc_binary.CONFIG += no_link target_predeps
 QMAKE_EXTRA_COMPILERS += rcc_binary
 
 OTHER_FILES += $$RCC_BINARY_SOURCES
+
+## INSTALLS
+unix:!macx {
+    isEmpty(PREFIX): PREFIX = /usr
+    DATADIR = $${PREFIX}/share
+    BINDIR = $${PREFIX}/bin
+    LIBDIR = $${PREFIX}/lib
+    INCLUDEDIR = $${PREFIX}/include
+
+    # install desktop file
+    desktop.path = $${DATADIR}/applications
+    desktop.files += data/core/vnote.desktop
+
+    # install icons
+    icon16.path = $${DATADIR}/icons/hicolor/16x16/apps
+    icon16.files = data/core/logo/16x16/vnote.png
+
+    icon32.path = $${DATADIR}/icons/hicolor/32x32/apps
+    icon32.files = data/core/logo/32x32/vnote.png
+
+    icon48.path = $${DATADIR}/icons/hicolor/48x48/apps
+    icon48.files = data/core/logo/48x48/vnote.png
+
+    icon64.path = $${DATADIR}/icons/hicolor/64x64/apps
+    icon64.files = data/core/logo/64x64/vnote.png
+
+    icon128.path = $${DATADIR}/icons/hicolor/128x128/apps
+    icon128.files = data/core/logo/128x128/vnote.png
+
+    icon256.path = $${DATADIR}/icons/hicolor/256x256/apps
+    icon256.files = data/core/logo/256x256/vnote.png
+
+    iconsvg.path = $${DATADIR}/icons/hicolor/scalable/apps
+    iconsvg.files = data/core/logo/vnote.svg
+
+    target.path = $${BINDIR}
+
+    extraresource.path = $${BINDIR}
+    extraresource.extra = cp $${SRC_DESTDIR}/vnote_extra.rcc $(INSTALL_ROOT)$${BINDIR}/vnote_extra.rcc
+
+    INSTALLS += target desktop icon16 icon32 icon48 icon64 icon128 icon256 iconsvg
+    INSTALLS += extraresource
+    message("VNote will be installed in prefix $${PREFIX}")
+}

+ 2 - 0
tests/common.pri

@@ -6,3 +6,5 @@ QT += core gui widgets network svg webenginewidgets webchannel
 QT += testlib
 
 CONFIG += c++14 testcase
+
+CONFIG += no_testcase_installs