6767 find artifacts -type f \( -name "*.plasmoid" -o -name "*.deb" -o -name "*.rpm" -o -name "*.AppImage" -o -name "*.msi" -o -name "*.exe" -o -name "*.dmg" \) -exec cp {} release/ \;
6868 ls -la release/
6969
70- - name : Generate latest.json for updater
70+ - name : Generate latest.json and collect updater artifacts
7171 shell : bash
7272 run : |
7373 VERSION="${{ needs.prepare.outputs.version }}"
@@ -76,102 +76,74 @@ jobs:
7676 REPO="jaredcat/plasmoid-lgtv-remote"
7777 TAG="${{ needs.prepare.outputs.version }}"
7878
79- # Read signatures from .sig files
80- read_sig() {
81- local pattern="$1"
82- local sig_file
83- sig_file=$(find artifacts -name "$pattern" -type f | head -1)
84- if [ -n "$sig_file" ] && [ -f "$sig_file" ]; then
85- cat "$sig_file"
86- else
87- echo ""
88- fi
79+ # Helper: find a single file by glob pattern within a directory, space-safe
80+ find_one() {
81+ find "$1" -name "$2" -type f -print0 2>/dev/null | head -z -n1 | tr -d '\0'
8982 }
9083
91- # Find updater artifact filenames
92- find_artifact() {
93- local pattern="$1"
94- local artifact
95- artifact=$(find artifacts -name "$pattern" -type f | head -1)
96- if [ -n "$artifact" ]; then
97- basename "$artifact"
98- else
99- echo ""
84+ # Helper: read signature content from a .sig file path
85+ sig_of() {
86+ local sig_file="${1}.sig"
87+ if [ -f "$sig_file" ]; then
88+ cat "$sig_file"
10089 fi
10190 }
10291
103- # Linux AppImage
104- LINUX_SIG=$(read_sig "*.AppImage.sig")
105- LINUX_FILE=$(find_artifact "*.AppImage")
106-
107- # Windows NSIS
108- WINDOWS_SIG=$(read_sig "*.nsis.zip.sig")
109- WINDOWS_FILE=$(find_artifact "*.nsis.zip")
110-
111- # macOS arm64
112- MACOS_ARM_SIG=$(read_sig "*.app.tar.gz.sig")
113- MACOS_ARM_FILE=""
114- # Find arm64 tar.gz specifically
115- for f in $(find artifacts/lgtv-tray-macos-arm64 -name "*.app.tar.gz" -type f 2>/dev/null); do
116- MACOS_ARM_FILE=$(basename "$f")
117- MACOS_ARM_SIG=$(cat "${f}.sig" 2>/dev/null || echo "")
118- break
119- done
120-
121- # macOS x64
122- MACOS_X64_SIG=""
123- MACOS_X64_FILE=""
124- for f in $(find artifacts/lgtv-tray-macos-x64 -name "*.app.tar.gz" -type f 2>/dev/null); do
125- MACOS_X64_FILE=$(basename "$f")
126- MACOS_X64_SIG=$(cat "${f}.sig" 2>/dev/null || echo "")
127- break
128- done
129-
130- # Build JSON (only include platforms with both file and signature)
131- PLATFORMS="{"
132- FIRST=true
133-
134- if [ -n "$LINUX_FILE" ] && [ -n "$LINUX_SIG" ]; then
135- PLATFORMS="$PLATFORMS\"linux-x86_64\":{\"url\":\"https://github.com/$REPO/releases/download/$TAG/$LINUX_FILE\",\"signature\":\"$LINUX_SIG\"}"
136- FIRST=false
137- fi
138-
139- if [ -n "$WINDOWS_FILE" ] && [ -n "$WINDOWS_SIG" ]; then
140- [ "$FIRST" = false ] && PLATFORMS="$PLATFORMS,"
141- PLATFORMS="$PLATFORMS\"windows-x86_64\":{\"url\":\"https://github.com/$REPO/releases/download/$TAG/$WINDOWS_FILE\",\"signature\":\"$WINDOWS_SIG\"}"
142- FIRST=false
143- fi
144-
145- if [ -n "$MACOS_ARM_FILE" ] && [ -n "$MACOS_ARM_SIG" ]; then
146- [ "$FIRST" = false ] && PLATFORMS="$PLATFORMS,"
147- PLATFORMS="$PLATFORMS\"darwin-aarch64\":{\"url\":\"https://github.com/$REPO/releases/download/$TAG/$MACOS_ARM_FILE\",\"signature\":\"$MACOS_ARM_SIG\"}"
148- FIRST=false
149- fi
150-
151- if [ -n "$MACOS_X64_FILE" ] && [ -n "$MACOS_X64_SIG" ]; then
152- [ "$FIRST" = false ] && PLATFORMS="$PLATFORMS,"
153- PLATFORMS="$PLATFORMS\"darwin-x86_64\":{\"url\":\"https://github.com/$REPO/releases/download/$TAG/$MACOS_X64_FILE\",\"signature\":\"$MACOS_X64_SIG\"}"
154- fi
92+ # Helper: URL-encode spaces in filename for GitHub release URLs
93+ url_encode() {
94+ echo "$1" | sed 's/ /%20/g'
95+ }
15596
156- PLATFORMS="$PLATFORMS}"
97+ # Build platform entries using jq for proper JSON construction
98+ PLATFORMS='{}'
15799
158- cat > release/latest.json <<EOF
159- {
160- "version": "$VERSION",
161- "pub_date": "$PUB_DATE",
162- "platforms": $PLATFORMS
100+ add_platform() {
101+ local key="$1" dir="$2" pattern="$3"
102+ local file sig name url
103+ file=$(find_one "$dir" "$pattern")
104+ if [ -z "$file" ]; then
105+ echo "WARN: no $pattern found in $dir"
106+ return
107+ fi
108+ sig=$(sig_of "$file")
109+ if [ -z "$sig" ]; then
110+ echo "WARN: no signature for $file"
111+ return
112+ fi
113+ name=$(basename "$file")
114+ url="https://github.com/$REPO/releases/download/$TAG/$(url_encode "$name")"
115+ PLATFORMS=$(echo "$PLATFORMS" | python3 -c "
116+ import sys, json
117+ d = json.load(sys.stdin)
118+ d['$key'] = {'url': '''$url''', 'signature': '''$sig'''}
119+ json.dump(d, sys.stdout)
120+ ")
121+ # Copy updater artifact + signature to release/
122+ cp "$file" release/
123+ cp "${file}.sig" release/
124+ echo "OK: $key -> $name"
163125 }
164- EOF
165-
166- # Strip leading whitespace from heredoc indentation
167- sed -i 's/^ //' release/latest.json
168126
169- # Pretty-print for verification
170- cat release/latest.json | python3 -m json.tool || cat release/latest.json
127+ add_platform "linux-x86_64" "artifacts/lgtv-tray-linux" "*.AppImage"
128+ add_platform "windows-x86_64" "artifacts/lgtv-tray-windows" "*.nsis.zip"
129+ add_platform "darwin-aarch64" "artifacts/lgtv-tray-macos-arm64" "*.app.tar.gz"
130+ add_platform "darwin-x86_64" "artifacts/lgtv-tray-macos-x64" "*.app.tar.gz"
131+
132+ python3 -c "
133+ import json, sys
134+ platforms = json.loads('''$PLATFORMS''')
135+ manifest = {
136+ 'version': '$VERSION',
137+ 'pub_date': '$PUB_DATE',
138+ 'platforms': platforms
139+ }
140+ with open('release/latest.json', 'w') as f:
141+ json.dump(manifest, f, indent=2)
142+ print(json.dumps(manifest, indent=2))
143+ "
171144
172- - name : Copy updater artifacts to release
173- run : |
174- find artifacts -type f \( -name "*.AppImage.sig" -o -name "*.nsis.zip" -o -name "*.nsis.zip.sig" -o -name "*.app.tar.gz" -o -name "*.app.tar.gz.sig" \) -exec cp {} release/ \;
145+ echo ""
146+ echo "=== release/ contents ==="
175147 ls -la release/
176148
177149 - name : Create Release
0 commit comments