Skip to content

Commit

Permalink
[更新] 多平台打包和安装脚本改进
Browse files Browse the repository at this point in the history
  - 更新了Ubuntu、macOS和Windows平台的打包脚本,增强了可维护性和操作的灵活性。
  - 引入了7z压缩格式支持,优化了软件分发过程。
  - **Ubuntu**:
    - 新增DEBIAN控制文件,定义了包信息和管理脚本。
    - 更新了`.desktop`和`.sh`脚本,适配新的包管理方式。
    - 移除了旧的打包脚本部分,统一使用新的打包逻辑。
  - **macOS**:
    - 改进了`package.sh`脚本,增加了7z压缩格式的软件包生成。
    - 优化了应用打包流程,确保了框架的完整性。
  - **Windows**:
    - 引入了Inno Setup编译脚本(`.iss`),标准化了安装程序的生成。
    - 更新了PowerShell脚本(`package.ps1`),增加了7z压缩包的创建。
    - 修正了Visual C++运行时的安装指令,确保了依赖的正确安装。
- **其他改进**:
  - 统一了`.gitignore`文件,排除了打包目录和生成的安装程序。
  - 清理了工作流中不再需要的文件和脚本,精简了项目结构。
  • Loading branch information
RealChuan committed May 22, 2024
1 parent b42cf68 commit d209342
Show file tree
Hide file tree
Showing 15 changed files with 649 additions and 15 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,16 @@ jobs:
sudo chmod 755 ./packaging/ubuntu/package.sh
./packaging/ubuntu/package.sh
- name: 7z package
- name: Check packages
shell: bash
run: |
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} ${{ env.PACKET_DIR }}/*
ls -al ${{ env.RELEASES_DIR }}
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{matrix.arch}}-${{ matrix.build_type }}
path: ${{ env.artifactPath }}
path: ${{ env.RELEASES_DIR }}

release:
name: Release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ tags
.vscode
bin-*
build
packet
releases
11 changes: 6 additions & 5 deletions packaging/macos/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ macdeployqt "${packet_dir}/Qt-App.app" -always-overwrite

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

# package with 7z
zip_path="${releases_dir}/Qt-App.7z"
7z a -t7z -r -mx=9 -mmt "${zip_path}" "${packet_dir}/Qt-App.app"

# package with dmg
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}"
mv -v "${packet_dir}/Qt-App.dmg" "${releases_dir}"

echo "Deployment macos completed."
9 changes: 9 additions & 0 deletions packaging/ubuntu/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: qt-app
Version: 0.1.1
Architecture: amd64
Description: qt-app
Section: admin
Priority: optional
Maintainer: https://github.com/RealChuan
Homepage: https://github.com/RealChuan/Qt-App
Depends: libc6 (>= 2.35)
8 changes: 8 additions & 0 deletions packaging/ubuntu/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -e

chmod +x /opt/Qt-App/Qt-App
chmod +x /opt/Qt-App/Qt-App.sh
chmod 777 /opt/Qt-App/app.png
chmod 744 /usr/share/applications/Qt-App.desktop

exit 0
20 changes: 20 additions & 0 deletions packaging/ubuntu/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh -e

delete_file_or_dir() {
local target=$1

if [ -e "$target" ]; then
if [ -d "$target" ]; then
rm -rf "$target"
else
rm "$target"
fi
fi
}

if [ "$1" = "remove" -o "$1" = "purge" ]; then
delete_file_or_dir ~/.config/Youth/Qt-App
delete_file_or_dir ~/.config/Youth/CrashReport
fi

exit 0
6 changes: 6 additions & 0 deletions packaging/ubuntu/DEBIAN/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

killall -q -9 Qt-App || true
killall -q -9 CrashReport || true

exit 0
6 changes: 6 additions & 0 deletions packaging/ubuntu/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

killall -q -9 Qt-App || true
killall -q -9 CrashReport || true

exit 0
9 changes: 5 additions & 4 deletions packaging/ubuntu/Qt-App.desktop
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[Desktop Entry]
Type=Application
Name=Qt-App
Comment=A qt Application template
GenericName=Qt-App
Exec=AppRun %F
Icon=app
Comment=Edit this default file
Terminal=true
Type=Application
StartupNotify=false
StartupWMClass=U-Backup
Categories=Utility;
X-AppImage-Version=9e82467
2 changes: 2 additions & 0 deletions packaging/ubuntu/Qt-App.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/Qt-App/Qt-App
24 changes: 24 additions & 0 deletions packaging/ubuntu/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,28 @@ linuxdeployqt ${packet_dir}/Qt-App \
sudo chmod +x *.AppImage
cd "${project_dir}"

mv -v "${packet_dir}"/*.AppImage "$releases_dir"

# package with 7z
zip_path="${releases_dir}/Qt-App.7z"
7z a -t7z -r -mx=9 -mmt "${zip_path}" "${packet_dir}"/*

# package with deb
mkdir -p "${project_dir}"/packaging/Qt-App/
mv -v "${packet_dir}"/* "${project_dir}"/packaging/Qt-App
mkdir -p "${packet_dir}"/opt
mv -v "${project_dir}"/packaging/Qt-App "${packet_dir}"/opt/
cp -rv "${project_dir}"/packaging/ubuntu/DEBIAN "${packet_dir}"/
cp -rv "${project_dir}"/packaging/ubuntu/usr "${packet_dir}"/
cp -v "${project_dir}"/packaging/ubuntu/Qt-App.sh "${packet_dir}"/opt/Qt-App/

sudo chmod -R +x "${packet_dir}"/DEBIAN
sudo chmod 777 "${packet_dir}"/opt/Qt-App/app.png
sudo chmod 744 "${packet_dir}"/usr/share/applications/Qt-App.desktop

deb_path="${releases_dir}/Qt-App.deb"
sudo dpkg -b ${packet_dir}/. ${deb_path}

sudo chmod -R +x ${releases_dir}

echo "Deployment ubuntu completed."
10 changes: 10 additions & 0 deletions packaging/ubuntu/usr/share/applications/Qt-App.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Name=Qt-App
Comment=A qt Application template
GenericName=Qt-App
Exec=/opt/Qt-App/Qt-App
Icon=/opt/Qt-App/app.png
Type=Application
StartupNotify=false
StartupWMClass=U-Backup
Categories=Utility;
Loading

0 comments on commit d209342

Please sign in to comment.