Add portable packaging: AppImage for Linux, zip for Windows

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AgelandClaude Sonnet 4.6 committed 2026-03-16 21:05:54 +01:00
1 parent ca307e6383
commit 4e8cc5063a
5 files changed
+210 -5

No files matched your search

+38 -5
View File
@@ -1,5 +1,6 @@
stages: stages:
- build - build
- package
- wiki - wiki
variables: variables:
@@ -67,13 +68,45 @@ build-windows:
expire_in: 1 day expire_in: 1 day
when: on_success when: on_success
# ── Package Linux as AppImage ─────────────────────────────────────────────
package-linux:
stage: package
image: "${DOCKER_IMAGE}"
needs:
- build-linux
script:
- chmod +x packaging/package-linux.sh
- packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" dist
artifacts:
name: "asteria-qt-linux-appimage-${CI_COMMIT_SHORT_SHA}"
paths:
- dist/*.AppImage
expire_in: 1 day
when: on_success
# ── Package Windows as portable zip ──────────────────────────────────────────
package-windows:
stage: package
image: "${DOCKER_IMAGE}"
needs:
- build-windows
script:
- chmod +x packaging/package-windows.sh
- packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" dist
artifacts:
name: "asteria-qt-windows-portable-${CI_COMMIT_SHORT_SHA}"
paths:
- dist/asteria-qt-windows.zip
expire_in: 1 day
when: on_success
# ── Update wiki with latest dev build links ──────────────────────────────────── # ── Update wiki with latest dev build links ────────────────────────────────────
update-wiki: update-wiki:
stage: wiki stage: wiki
image: alpine:latest image: alpine:latest
needs: needs:
- build-linux - package-linux
- build-windows - package-windows
before_script: before_script:
- apk add --no-cache curl jq - apk add --no-cache curl jq
script: script:
@@ -85,14 +118,14 @@ update-wiki:
- PROJECT_URL="https://gitlab.com/asteria-bookreader/asteria-qt" - PROJECT_URL="https://gitlab.com/asteria-bookreader/asteria-qt"
- API_URL="https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}" - API_URL="https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}"
- ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw" - ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw"
- LINUX_URL="${ARTIFACTS_URL}/build-linux/asteria-qt?job=build-linux" - LINUX_URL="${ARTIFACTS_URL}/dist/Asteria-x86_64.AppImage?job=package-linux"
- WINDOWS_URL="${ARTIFACTS_URL}/build-windows/asteria-qt.exe?job=build-windows" - WINDOWS_URL="${ARTIFACTS_URL}/dist/asteria-qt-windows.zip?job=package-windows"
- | - |
HTTP_CODE=$(curl -s -o /tmp/wiki.json -w '%{http_code}' \ HTTP_CODE=$(curl -s -o /tmp/wiki.json -w '%{http_code}' \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"${API_URL}/wikis/Asteria") "${API_URL}/wikis/Asteria")
NEW_SECTION=$(printf '## Latest dev builds\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [asteria-qt](%s) |\n| Windows (x86_64) | [asteria-qt.exe](%s) |' \ NEW_SECTION=$(printf '## Latest dev builds\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |' \
"${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \ "${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
"${LINUX_URL}" "${WINDOWS_URL}") "${LINUX_URL}" "${WINDOWS_URL}")
+31
View File
@@ -58,4 +58,35 @@ ENV QT_LINUX_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64
ENV QT_WINDOWS_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_64 ENV QT_WINDOWS_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_64
ENV MINGW_SYSROOT=/opt/mingw-sysroot ENV MINGW_SYSROOT=/opt/mingw-sysroot
# ── linuxdeploy + Qt plugin (for AppImage packaging) ────────────────────────
RUN wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \
-O /usr/local/bin/linuxdeploy && \
chmod +x /usr/local/bin/linuxdeploy && \
wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage \
-O /usr/local/bin/linuxdeploy-plugin-qt && \
chmod +x /usr/local/bin/linuxdeploy-plugin-qt
# ── FUSE not available in Docker — extract AppImage tools ────────────────────
RUN cd /tmp && \
/usr/local/bin/linuxdeploy --appimage-extract && \
mv squashfs-root /opt/linuxdeploy && \
ln -sf /opt/linuxdeploy/AppRun /usr/local/bin/linuxdeploy && \
/usr/local/bin/linuxdeploy-plugin-qt --appimage-extract && \
mv squashfs-root /opt/linuxdeploy-plugin-qt && \
ln -sf /opt/linuxdeploy-plugin-qt/AppRun /usr/local/bin/linuxdeploy-plugin-qt
# ── appimagetool (for final AppImage creation) ──────────────────────────────
RUN wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage \
-O /tmp/appimagetool && \
chmod +x /tmp/appimagetool && \
cd /tmp && /tmp/appimagetool --appimage-extract && \
mv squashfs-root /opt/appimagetool && \
ln -sf /opt/appimagetool/AppRun /usr/local/bin/appimagetool && \
rm /tmp/appimagetool
# ── file utility (needed by linuxdeploy for ELF detection) ──────────────────
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends file patchelf zip && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build WORKDIR /build
+8
View File
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=Asteria
Comment=Cross-platform book reader
Exec=asteria-qt
Icon=asteria-qt
Categories=Office;Viewer;
MimeType=application/epub+zip;text/plain;application/x-fictionbook+xml;
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# Package Linux build as AppImage
# Usage: package-linux.sh <build-dir> <qt-dir> <output-dir>
set -euo pipefail
BUILD_DIR="${1:?Usage: package-linux.sh <build-dir> <qt-dir> <output-dir>}"
QT_DIR="${2:?}"
OUTPUT_DIR="${3:?}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
APPDIR="${BUILD_DIR}/AppDir"
rm -rf "$APPDIR"
# linuxdeploy handles AppDir structure, library bundling, and AppRun
export QMAKE="$QT_DIR/bin/qmake"
export QML_SOURCES_PATHS="$PROJECT_DIR/src/qml"
export LD_LIBRARY_PATH="$QT_DIR/lib:${LD_LIBRARY_PATH:-}"
export OUTPUT="Asteria-x86_64.AppImage"
linuxdeploy \
--appdir "$APPDIR" \
--executable "$BUILD_DIR/asteria-qt" \
--desktop-file "$PROJECT_DIR/packaging/asteria-qt.desktop" \
--icon-file "$PROJECT_DIR/src/assets/moon1.svg" \
--plugin qt \
--output appimage
mkdir -p "$OUTPUT_DIR"
mv "$OUTPUT" "$OUTPUT_DIR/"
+102
View File
@@ -0,0 +1,102 @@
#!/bin/bash
# Package Windows build as a portable directory with all DLLs
# Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir>
set -euo pipefail
BUILD_DIR="${1:?Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir>}"
QT_DIR="${2:?}"
MINGW_SYSROOT="${3:?}"
OUTPUT_DIR="${4:?}"
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
DIST_DIR="${BUILD_DIR}/dist"
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
# Copy the main executable
cp "$BUILD_DIR/asteria-qt.exe" "$DIST_DIR/"
# Use windeployqt to gather Qt dependencies
# windeployqt6 from the cross-compiled Qt may not work on Linux host,
# so we manually copy the required DLLs
# Qt DLLs
QT_DLLS=(
Qt6Core.dll
Qt6Gui.dll
Qt6Qml.dll
Qt6Quick.dll
Qt6Widgets.dll
Qt6Concurrent.dll
Qt6Svg.dll
Qt6QuickControls2.dll
Qt6QuickControls2Impl.dll
Qt6QuickTemplates2.dll
Qt6QuickLayouts.dll
Qt6QmlModels.dll
Qt6QmlWorkerScript.dll
Qt6Network.dll
Qt6OpenGL.dll
Qt6QmlMeta.dll
)
for dll in "${QT_DLLS[@]}"; do
if [ -f "$QT_DIR/bin/$dll" ]; then
cp "$QT_DIR/bin/$dll" "$DIST_DIR/"
fi
done
# Qt plugins
mkdir -p "$DIST_DIR/platforms"
cp "$QT_DIR/plugins/platforms/qwindows.dll" "$DIST_DIR/platforms/" 2>/dev/null || true
mkdir -p "$DIST_DIR/imageformats"
cp "$QT_DIR/plugins/imageformats/"*.dll "$DIST_DIR/imageformats/" 2>/dev/null || true
mkdir -p "$DIST_DIR/iconengines"
cp "$QT_DIR/plugins/iconengines/"*.dll "$DIST_DIR/iconengines/" 2>/dev/null || true
mkdir -p "$DIST_DIR/tls"
cp "$QT_DIR/plugins/tls/"*.dll "$DIST_DIR/tls/" 2>/dev/null || true
# QML modules
mkdir -p "$DIST_DIR/qml"
for mod in QtQuick QtQml Qt5Compat; do
if [ -d "$QT_DIR/qml/$mod" ]; then
cp -r "$QT_DIR/qml/$mod" "$DIST_DIR/qml/"
fi
done
# MinGW runtime DLLs
MINGW_DLLS=(
libgcc_s_seh-1.dll
libstdc++-6.dll
libwinpthread-1.dll
)
for dll in "${MINGW_DLLS[@]}"; do
find /usr/lib/gcc/x86_64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "/usr/x86_64-w64-mingw32/lib/$dll" ]; then
cp "/usr/x86_64-w64-mingw32/lib/$dll" "$DIST_DIR/"
fi
done
# Third-party DLLs from sysroot
if [ -f "$MINGW_SYSROOT/lib/libuchardet.dll" ]; then
cp "$MINGW_SYSROOT/lib/libuchardet.dll" "$DIST_DIR/"
elif [ -f "$MINGW_SYSROOT/bin/libuchardet.dll" ]; then
cp "$MINGW_SYSROOT/bin/libuchardet.dll" "$DIST_DIR/"
fi
# Create qt.conf for portable deployment
cat > "$DIST_DIR/qt.conf" << 'EOF'
[Paths]
Plugins = .
Qml2Imports = qml
EOF
# Create zip archive
mkdir -p "$OUTPUT_DIR"
cp -r "$DIST_DIR" "$OUTPUT_DIR/asteria-qt-windows"
cd "$OUTPUT_DIR" && zip -r "asteria-qt-windows.zip" asteria-qt-windows/ && rm -rf asteria-qt-windows/