fix: rewrite Linglong packaging workflow following official guidelines

Based on linyaps-packager-skill reference:
- Use correct ll-builder workflow: build -> list -> export
- Output .layer files instead of .linglong/.uab
- Use proper PREFIX variable format ( instead of )
- Add proper error handling with GitHub Actions annotations
- Update linglong.yaml to follow official template format

References:
- https://github.com/linglongdev/linyaps-packager-skill
- https://github.com/myml/linglong-builder-action
This commit is contained in:
lincube
2026-06-25 16:41:12 +08:00
parent f7926a287f
commit e8254e5048
2 changed files with 65 additions and 45 deletions

View File

@@ -634,40 +634,58 @@ jobs:
echo "LINGLONG_AVAILABLE=false" >> $GITHUB_ENV echo "LINGLONG_AVAILABLE=false" >> $GITHUB_ENV
fi fi
- name: Package as Linglong - name: Build Linglong package
if: env.LINGLONG_AVAILABLE == 'true' if: env.LINGLONG_AVAILABLE == 'true'
run: | run: |
version="${{ needs.prepare.outputs.version }}" version="${{ needs.prepare.outputs.version }}"
publishDir="publish/linux-x64" publishDir="publish/linux-x64"
linglongDir="build-linglong" linglongDir="build-linglong"
release_dir="$PWD/release-assets"
# Create Linglong build directory mkdir -p "$linglongDir" "$release_dir"
mkdir -p "$linglongDir"
# Copy linglong.yaml and update version # Copy linglong.yaml and update version
cp packaging/linglong/linglong.yaml "$linglongDir/" cp packaging/linglong/linglong.yaml "$linglongDir/"
sed -i "s/version: .*/version: ${version}/" "$linglongDir/linglong.yaml" sed -i "s/version: .*/version: ${version}/" "$linglongDir/linglong.yaml"
# Create project structure for Linglong build # Create project structure for Linglong build
mkdir -p "$linglongDir/project" # ll-builder expects the project files in /project inside the container
cp -r "$publishDir" "$linglongDir/project/" mkdir -p "$linglongDir/publish"
cp -r LanMountainDesktop/packaging "$linglongDir/project/LanMountainDesktop/" cp -r "$publishDir"/* "$linglongDir/publish/"
cp -r LanMountainDesktop "$linglongDir/LanMountainDesktop"
# Build Linglong package # Copy linglong.yaml to the build directory
cp "$linglongDir/linglong.yaml" "$linglongDir/"
# Build using ll-builder
cd "$linglongDir" cd "$linglongDir"
ll-builder build || { ll-builder build || {
echo "Warning: Linglong build failed" echo "::warning::Linglong build failed"
exit 0 exit 0
} }
# Find and copy the generated package # List available refs
LINGLONG_PKG=$(find . -name "*.uab" -o -name "*.linglong" 2>/dev/null | head -1) ll-builder list
# Export the layer
# Get the first available ref
REF=$(ll-builder list | head -1 | awk '{print $1}')
if [ -n "$REF" ]; then
ll-builder export --ref "$REF" || {
echo "::warning::Linglong export failed"
exit 0
}
# Find and copy the generated layer file
LINGLONG_PKG=$(find . -name "*.layer" 2>/dev/null | head -1)
if [ -n "$LINGLONG_PKG" ]; then if [ -n "$LINGLONG_PKG" ]; then
mkdir -p "$PWD/../release-assets" cp "$LINGLONG_PKG" "$release_dir/LanMountainDesktop-${version}-linux-x64.layer"
cp "$LINGLONG_PKG" "$PWD/../release-assets/LanMountainDesktop-${version}-linux-x64.linglong" echo "✓ Linglong package created: LanMountainDesktop-${version}-linux-x64.layer"
echo "Linglong package created successfully"
else else
echo "Warning: Linglong package not found after build" echo "::warning::Linglong layer file not found after export"
fi
else
echo "::warning::No refs available for export"
fi fi
- name: Build AppImage - name: Build AppImage
@@ -859,7 +877,7 @@ jobs:
name: release-linux-x64 name: release-linux-x64
path: | path: |
release-assets/files-linux-x64.zip release-assets/files-linux-x64.zip
release-assets/*.linglong release-assets/*.layer
release-assets/*.AppImage release-assets/*.AppImage
release-assets/*.flatpak release-assets/*.flatpak
*.deb *.deb

View File

@@ -1,4 +1,4 @@
version: '1' version: "1"
package: package:
id: com.lanmountain.desktop id: com.lanmountain.desktop
@@ -20,59 +20,61 @@ sources:
build: | build: |
# Create directory structure following Linglong conventions # Create directory structure following Linglong conventions
mkdir -p ${PREFIX}/bin mkdir -p $PREFIX/bin
mkdir -p ${PREFIX}/lib mkdir -p $PREFIX/lib
mkdir -p ${PREFIX}/share/applications mkdir -p $PREFIX/share/applications
mkdir -p ${PREFIX}/share/icons/hicolor/128x128/apps mkdir -p $PREFIX/share/icons/hicolor/128x128/apps
mkdir -p ${PREFIX}/share/icons/hicolor/256x256/apps mkdir -p $PREFIX/share/icons/hicolor/256x256/apps
mkdir -p ${PREFIX}/share/icons/hicolor/scalable/apps mkdir -p $PREFIX/share/icons/hicolor/scalable/apps
# Copy the pre-built application files # Copy the pre-built application files
# The build artifacts should be in /project/publish/linux-x64 # The build artifacts should be in /project/publish/linux-x64
if [ -d "/project/publish/linux-x64" ]; then if [ -d "/project/publish/linux-x64" ]; then
# Copy main application (includes .NET runtime) # Copy main application (includes .NET runtime)
cp -r /project/publish/linux-x64/app-*/* ${PREFIX}/lib/ cp -r /project/publish/linux-x64/app-*/* $PREFIX/lib/
# Copy Launcher (AOT compiled, independent) # Copy Launcher (AOT compiled, independent)
cp /project/publish/linux-x64/LanMountainDesktop.Launcher ${PREFIX}/bin/ cp /project/publish/linux-x64/LanMountainDesktop.Launcher $PREFIX/bin/
chmod +x ${PREFIX}/bin/LanMountainDesktop.Launcher chmod +x $PREFIX/bin/LanMountainDesktop.Launcher
# Copy AirAppRuntime wrapper and DLL # Copy AirAppRuntime wrapper and DLL
cp /project/publish/linux-x64/LanMountainDesktop.AirAppRuntime ${PREFIX}/bin/ cp /project/publish/linux-x64/LanMountainDesktop.AirAppRuntime $PREFIX/bin/
cp /project/publish/linux-x64/LanMountainDesktop.AirAppRuntime.dll ${PREFIX}/lib/ cp /project/publish/linux-x64/LanMountainDesktop.AirAppRuntime.dll $PREFIX/lib/
chmod +x ${PREFIX}/bin/LanMountainDesktop.AirAppRuntime chmod +x $PREFIX/bin/LanMountainDesktop.AirAppRuntime
# Copy AirAppHost # Copy AirAppHost
if [ -d "/project/publish/linux-x64/AirAppHost" ]; then if [ -d "/project/publish/linux-x64/AirAppHost" ]; then
cp -r /project/publish/linux-x64/AirAppHost ${PREFIX}/lib/ cp -r /project/publish/linux-x64/AirAppHost $PREFIX/lib/
fi fi
else else
echo "Error: Build artifacts not found at /project/publish/linux-x64" echo "Error: Build artifacts not found at /project/publish/linux-x64"
exit 1 exit 1
fi fi
# Create desktop file using printf to avoid heredoc issues # Create desktop file
printf '%s\n' '[Desktop Entry]' > ${PREFIX}/share/applications/com.lanmountain.desktop.desktop cat > $PREFIX/share/applications/com.lanmountain.desktop.desktop << EOF
printf '%s\n' 'Type=Application' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop [Desktop Entry]
printf '%s\n' 'Version=1.0' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Type=Application
printf '%s\n' 'Name=LanMountainDesktop' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Version=1.0
printf '%s\n' 'Comment=LanMountainDesktop desktop shell' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Name=LanMountainDesktop
printf '%s\n' 'Exec=/opt/apps/com.lanmountain.desktop/files/bin/LanMountainDesktop.Launcher %U' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Comment=LanMountainDesktop desktop shell
printf '%s\n' 'Icon=lanmountaindesktop' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Exec=/opt/apps/com.lanmountain.desktop/files/bin/LanMountainDesktop.Launcher %U
printf '%s\n' 'Terminal=false' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Icon=lanmountaindesktop
printf '%s\n' 'Categories=Utility;Education;' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Terminal=false
printf '%s\n' 'StartupWMClass=LanMountainDesktop' >> ${PREFIX}/share/applications/com.lanmountain.desktop.desktop Categories=Utility;Education;
StartupWMClass=LanMountainDesktop
EOF
# Copy icon files # Copy icon files
if [ -f "/project/LanMountainDesktop/packaging/linux/lanmountaindesktop.png" ]; then if [ -f "/project/LanMountainDesktop/packaging/linux/lanmountaindesktop.png" ]; then
cp /project/LanMountainDesktop/packaging/linux/lanmountaindesktop.png \ cp /project/LanMountainDesktop/packaging/linux/lanmountaindesktop.png \
${PREFIX}/share/icons/hicolor/256x256/apps/ $PREFIX/share/icons/hicolor/256x256/apps/
cp /project/LanMountainDesktop/packaging/linux/lanmountaindesktop.png \ cp /project/LanMountainDesktop/packaging/linux/lanmountaindesktop.png \
${PREFIX}/share/icons/hicolor/128x128/apps/ $PREFIX/share/icons/hicolor/128x128/apps/
fi fi
# Set executable permissions # Set executable permissions
chmod +x ${PREFIX}/bin/* chmod +x $PREFIX/bin/*
chmod +x ${PREFIX}/lib/LanMountainDesktop.AirAppRuntime 2>/dev/null || true chmod +x $PREFIX/lib/LanMountainDesktop.AirAppRuntime 2>/dev/null || true
echo "Linglong build completed successfully" echo "Linglong build completed successfully"