diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 45ff83fe..e32efd9d 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -236,12 +236,14 @@ jobs: - name: (FIXME) Run qmllint run: docker run --rm -v "$(pwd):/src" --entrypoint '' -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' cmake --build build --target all_qmllint || true - - name: Upload AppImage artifact + - name: Upload AppImage and zsync artifacts uses: actions/upload-artifact@v4 with: if-no-files-found: error name: ${{ steps.build.outputs.artifact_name }}-${{ runner.os }}-${{ matrix.build-type }} - path: ${{ steps.build.outputs.appimage_path }} + path: | + ${{ steps.build.outputs.appimage_path }} + ${{ steps.build.outputs.zsync_path }} - name: Login to GitHub Container Registry if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} diff --git a/Dockerfiles/README.md b/Dockerfiles/README.md index 8f7f88c7..4d0be26d 100644 --- a/Dockerfiles/README.md +++ b/Dockerfiles/README.md @@ -15,3 +15,30 @@ docker build -f ./ubuntu-aqtinstall-6 -t zjeffer:notes/ubuntu-aqtinstall-6.4.3 . ```bash docker push ``` + +### AppImage update artifacts + +The AppImage build produces a matching `.AppImage` and `.AppImage.zsync` pair. CI +includes both files in the AppImage artifact. The build fails if either file is +missing or if the AppImage does not contain the configured update information. + +By default, AppImageUpdate follows stable releases of `nuttyartist/notes`, with a +separate asset pattern for each Qt major version and architecture. For Qt 6 on +x86_64, the embedded update information is: + +```text +gh-releases-zsync|nuttyartist|notes|latest|Notes_*-Qt6.*-x86_64.AppImage.zsync +``` + +To build for another repository or update channel, pass +`-e LDAI_UPDATE_INFORMATION='...'` to `docker run`. The legacy +`UPDATE_INFORMATION` variable is also accepted; `LDAI_UPDATE_INFORMATION` takes +precedence when both are set. For a local update test, use a `zsync|http://...` +URL served by a local HTTP server that supports range requests. + +When publishing a stable release, attach both generated files directly to the +same GitHub release. Do not change the AppImage after generating its `.zsync` +file. CI uploads build artifacts only; it does not create or publish a release. +Existing AppImages without update information need a one-time manual upgrade to +an enabled build. This enables external AppImageUpdate tools; Notes' built-in +update checker is configured separately. diff --git a/Dockerfiles/appimage-qt6 b/Dockerfiles/appimage-qt6 index 3afdc914..885e20c6 100644 --- a/Dockerfiles/appimage-qt6 +++ b/Dockerfiles/appimage-qt6 @@ -12,6 +12,7 @@ ARG DEBIAN_FRONTEND=noninteractive # Install all required dependencies: # # - appstream: Used to validate the AppStream metadata file. +# - binutils: Used to verify embedded AppImage update information. # - cmake: Used to help build the application. # - desktop-file-utils: Used to validate the desktop file. # - file: Required by linuxdeploy. @@ -29,10 +30,11 @@ ARG DEBIAN_FRONTEND=noninteractive # - libxkbcommon-x11-0: Used as dependency of the resulting AppImage. # - make: Used to help build the application. # - python3/python3-pip: Used to install and run aqtinstall. +# - zsync: Provides zsyncmake to generate AppImage update control files. RUN apt-get update && \ - apt-get install -y --no-install-recommends appstream cmake desktop-file-utils file git g++ libdbus-1-3 \ + apt-get install -y --no-install-recommends appstream binutils cmake desktop-file-utils file git g++ libdbus-1-3 \ libegl1 libfontconfig1 libgl-dev libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0 \ - libxkbcommon-dev libxkbcommon-x11-0 make python3 python3-pip && \ + libxkbcommon-dev libxkbcommon-x11-0 make python3 python3-pip zsync && \ # TODO: Remove the next 4 lines when targeting Qt 6.5+, which doesn't require libssl 1.1. echo 'deb http://security.ubuntu.com/ubuntu focal-security main' > /etc/apt/sources.list.d/focal-security.list && \ apt-get update && \ diff --git a/Dockerfiles/appimage_entrypoint.sh b/Dockerfiles/appimage_entrypoint.sh index 1a70ab80..0e60854d 100755 --- a/Dockerfiles/appimage_entrypoint.sh +++ b/Dockerfiles/appimage_entrypoint.sh @@ -129,17 +129,42 @@ if [[ "${GIT_REVISION}" == 'ON' ]]; then app_version="${app_version}+g$(git rev-parse --short HEAD)" fi shopt -u nocasematch -artifact_name="Notes_${app_version}-Qt${QT_VERSION}-$(arch)" +appimage_arch="$(arch)" +artifact_name="Notes_${app_version}-Qt${QT_VERSION}-${appimage_arch}" appimage_name="${artifact_name}.AppImage" +appimage_path="${BUILD_DIR}/${appimage_name}" +zsync_path="${appimage_path}.zsync" + +# Keep Qt variants and architectures on their own stable update channels. +export LDAI_UPDATE_INFORMATION="${LDAI_UPDATE_INFORMATION:-${UPDATE_INFORMATION:-gh-releases-zsync|nuttyartist|notes|latest|Notes_*-Qt${QT_VERSION%%.*}.*-${appimage_arch}.AppImage.zsync}}" +# Older versions of linuxdeploy's AppImage plugin use this variable instead. +export UPDATE_INFORMATION="${LDAI_UPDATE_INFORMATION}" + +# A previous build must not hide a missing output from this packaging run. +rm -f -- "${appimage_path}" "${zsync_path}" msg 'Running linuxdeploy (final run)...' export LINUXDEPLOY_OUTPUT_VERSION="${app_version}" export OUTPUT="${appimage_name}" (cd "${BUILD_DIR}" && linuxdeploy ${LINUXDEPLOY_FINAL_OPTIONS}) +for artifact_path in "${appimage_path}" "${zsync_path}"; do + if [ ! -s "${artifact_path}" ]; then + msg "Fatal: Packaging did not produce '${artifact_path}'." + exit 1 + fi +done + +msg 'Verifying embedded AppImage update information...' +if ! readelf --string-dump=.upd_info "${appimage_path}" | sed -n 's/^ *\[[^]]*\] *//p' | grep -Fxq -- "${LDAI_UPDATE_INFORMATION}"; then + msg 'Fatal: AppImage update information is missing or does not match the configured update channel.' + exit 1 +fi + # Needed for GitHub Actions. if [ -f /GITHUB_OUTPUT ]; then msg "Note: File '/GITHUB_OUTPUT' exists, assuming we're running on GitHub Actions." echo "artifact_name=${artifact_name}" >>'/GITHUB_OUTPUT' - echo "appimage_path=${BUILD_DIR}/${appimage_name}" >>'/GITHUB_OUTPUT' + echo "appimage_path=${appimage_path}" >>'/GITHUB_OUTPUT' + echo "zsync_path=${zsync_path}" >>'/GITHUB_OUTPUT' fi