Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
2

3
  • Loading branch information
RealChuan committed May 21, 2024
1 parent 200c8ae commit 2a4aa53
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ runs:
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-linux || (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: ${{ inputs.qt_ver }}
modules: ${{ inputs.qt_modules }}
Expand Down
47 changes: 31 additions & 16 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ on:

env:
MACOSX_DEPLOYMENT_TARGET: 11.0
PACKET_DIR: ./packaging/packet
RELEASES_DIR: ./packaging/releases

jobs:
build:
Expand Down Expand Up @@ -90,35 +92,48 @@ jobs:
-G "${{ matrix.generators }}"
cmake --build ./build --config ${{ matrix.build_type }}
- name: Deploy windows
if: startsWith(matrix.os, 'windows')
- name: Move compiled files to packaging/packet
shell: bash
run: |
./../../packaging/windows/deploy.sh
working-directory: ./bin-64/${{ matrix.build_type }}
- name: Deploy macos
if: startsWith(matrix.os, 'macos')
mkdir -p ${{ env.PACKET_DIR }}
mkdir -p ${{ env.RELEASES_DIR }}
mv -v ./bin-64/${{ matrix.build_type }}/* ${{ env.PACKET_DIR }}/
ls -al ${{ env.PACKET_DIR }}
- name: Download fonts
shell: bash
working-directory: ${{ env.PACKET_DIR }}
run: |
sudo chmod 755 ./../../packaging/macos/deploy.sh
./../../packaging/macos/deploy.sh
working-directory: ./bin-64/${{ matrix.build_type }}
- name: Deploy ubuntu
if: startsWith(matrix.os, 'ubuntu')
cmake -P ./../fonts.cmake
ls -al
ls -al ./fonts
- name: Packaging windows
if: startsWith(runner.os, 'Windows')
shell: pwsh
run: |
.\packaging\windows\package.ps1
- name: Packaging macos
if: startsWith(runner.os, 'macOS')
shell: bash
run: |
sudo chmod +x ./packaging/macos/package.sh
./packaging/macos/package.sh
- name: Packaging ubuntu
if: startsWith(runner.os, 'Linux')
shell: bash
run: |
sudo chmod 755 ./../../packaging/ubuntu/deploy.sh
./../../packaging/ubuntu/deploy.sh
working-directory: ./bin-64/${{ matrix.build_type }}
sudo chmod 755 ./packaging/ubuntu/package.sh
./packaging/ubuntu/package.sh
- name: 7z package
shell: bash
run: |
ls -al ./bin-64/${{ matrix.build_type }}
ls -al ${{ env.PACKET_DIR }}
CURRENT_DATE=$(date '+%Y%m%d')
filename=Qt-App_${{ runner.os }}_${{ matrix.arch }}_${CURRENT_DATE}.7z
echo "artifactPath=$filename" >> $GITHUB_ENV
7z a -t7z -r -mx=9 -mmt ${filename} ./bin-64/${{ matrix.build_type }}/*
7z a -t7z -r -mx=9 -mmt ${filename} ${{ env.PACKET_DIR }}/*
- name: Upload packages
uses: actions/upload-artifact@v4
with:
Expand Down
31 changes: 31 additions & 0 deletions packaging/fonts.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.10)

# 下载文件
file(
DOWNLOAD
"https://github.com/RealChuan/Qt-App/releases/download/0.0.1/fonts.7z"
"fonts.7z"
STATUS status
SHOW_PROGRESS)

list(GET status 0 error_code)
list(GET status 1 error_message)

if(error_code GREATER 0)
message(FATAL_ERROR "Error downloading file: ${error_message}")
endif()

# 解压文件
execute_process(COMMAND 7z x fonts.7z -o./fonts RESULT_VARIABLE error_code)

if(NOT error_code EQUAL 0)
message(FATAL_ERROR "Error extracting file")
endif()

execute_process(COMMAND rm -f fonts.7z)

# 列出文件
file(GLOB_RECURSE files ./fonts/*)
foreach(file IN LISTS files)
message("${file}")
endforeach()
33 changes: 0 additions & 33 deletions packaging/macos/deploy.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Path: packaging/macos/Qt-App.dmgbuild.py
# Use: dmgbuild -s ./packaging/macos/Qt-App.dmgbuild.py "Qt-App" bin-64/RelWithDebInfo/Qt-App.dmg
# Use: dmgbuild -s ./packaging/macos/dmgbuild.py "Qt-App" bin-64/RelWithDebInfo/Qt-App.dmg

import os.path
import plistlib
Expand Down Expand Up @@ -105,40 +105,3 @@ def icon_from_app(app_path):
label_pos = "bottom" # or 'right'
text_size = 16
icon_size = 128

# Code signing identity (optional)
# Developer ID Application: Your Name (XXXXXXXXXX)
# identity = "Developer ID Application: Your Name (XXXXXXXXXX)"

# Code signing entitlements (optional)
# entitlements = "entitlements.plist"

# Code signing requirements (optional)
# requirements = "requirements.plist"

# Code signing resource rules (optional)
# resource_rules = "resource-rules.plist"

# Code signing options (optional)
# code_sign = True

# Code signing flags (optional)
# code_sign_flags = "--deep"

# Code signing timestamp (optional)
# code_sign_timestamp = True

# Code signing identifier (optional)
# code_sign_identifier = "com.example.pkg"

# Code signing entitlements (optional)
# code_sign_entitlements = "entitlements.plist"

# Code signing requirements (optional)
# code_sign_requirements = "requirements.plist"

# Code signing resource rules (optional)
# code_sign_resource_rules = "resource-rules.plist"

# Code signing options (optional)
# code_sign_options = "--timestamp --options=runtime"
28 changes: 28 additions & 0 deletions packaging/macos/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -ex

cd "$(dirname "$0")"
cd ../..
project_dir="$(pwd)"
echo "Current directory: ${project_dir}"

packet_dir="${project_dir}/packaging/packet"
releases_dir="${project_dir}/packaging/releases"

sudo chmod -R +x ${packet_dir}
mv -vf "${packet_dir}/fonts" "${packet_dir}/Qt-App.app/Contents/MacOS/"

macdeployqt "${packet_dir}/Qt-App.app" -always-overwrite

ls -al "${packet_dir}/Qt-App.app/Contents/Frameworks"

pip3 install dmgbuild

cd "${packet_dir}"
dmgbuild -s "${project_dir}/packaging/macos/dmgbuild.py" "Qt-App.app" "Qt-App.dmg"

# 排除的文件名
EXCLUDE_FILE="Qt-App.dmg"
find . -maxdepth 1 ! -name "$EXCLUDE_FILE" ! -name "." ! -name ".." -exec rm -rf -- {} +
cd "${project_dir}"

echo "Deployment macos completed."
64 changes: 0 additions & 64 deletions packaging/ubuntu/deploy.sh

This file was deleted.

59 changes: 59 additions & 0 deletions packaging/ubuntu/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash -ex

cd "$(dirname "$0")"
cd ../..
project_dir="$(pwd)"
echo "Current directory: ${project_dir}"

packet_dir="${project_dir}/packaging/packet"
releases_dir="${project_dir}/packaging/releases"

sudo chmod -R +x ${packet_dir}

# 安装linuxdeployqt
sudo add-apt-repository universe
sudo apt update
sudo apt install -y libfuse2 libxcb-cursor0
wget -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" \
-O /usr/local/bin/linuxdeployqt
sudo chmod +x /usr/local/bin/linuxdeployqt

cp -vf "${project_dir}/packaging/ubuntu/Qt-App.desktop" ${packet_dir}/
cp -vf "${project_dir}/src/resource/icon/app.png" ${packet_dir}/

plugins="${packet_dir}/plugins"
if [ -d "${plugins}" ]; then
cp -vf "${plugins}"/* ${packet_dir}/
fi

# 删除测试文件
rm -rf "${packet_dir}/examples"
rm -f "${packet_dir}"/*Test*

export LD_LIBRARY_PATH=${packet_dir}:${packet_dir}/lib:$LD_LIBRARY_PATH

# 使用linuxdeployqt部署
cd "${packet_dir}"
so_files=$(find . -maxdepth 1 -name "*.so" -printf '%P\n')
for so_file in ${so_files}; do
linuxdeployqt ${so_file} \
-qmake=qmake \
-always-overwrite \
-unsupported-allow-new-glibc || true
done

# 删除插件
rm -f "${packet_dir}"/*plugin*.so
rm -f "${packet_dir}"/AppRun
mv -vf "${packet_dir}/"*.so "${packet_dir}/lib"

linuxdeployqt ${packet_dir}/Qt-App \
-executable=${packet_dir}/CrashReport \
-qmake=qmake \
-always-overwrite \
-unsupported-allow-new-glibc \
-appimage || true
sudo chmod +x *.AppImage
cd "${project_dir}"

echo "Deployment ubuntu completed."
32 changes: 0 additions & 32 deletions packaging/windows/deploy.sh

This file was deleted.

Loading

0 comments on commit 2a4aa53

Please sign in to comment.