From 44a7fdb90ed46e0f1d0a11234c65478065f66b47 Mon Sep 17 00:00:00 2001 From: professorDeveloper <108933534+professorDeveloper@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:35:49 +0500 Subject: [PATCH 1/2] Release: Android TV, Apple TV and LG webOS in one release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One run of Release → Telegram now builds the signed Android TV APK, an unsigned Apple TV IPA (macOS runner, for sideloading) and the webOS IPK, stamps one version into all three, and attaches them to one GitHub Release with one banner, page and Telegram post. Apple TV and webOS can be switched off per run. webos-release.yml is folded into it; tvos-release.yml stays for TestFlight once the apple-tv environment has secrets. --- .github/workflows/release.yml | 230 +++++++++++++++++++++++++--- .github/workflows/webos-release.yml | 60 -------- tools/release/release_banner.py | 27 +++- tools/release/release_page.py | 120 +++++++++++---- tools/release/release_page_test.py | 20 ++- tools/release/stamp_version.py | 36 ++++- webos/README.md | 5 +- webos/test/compat.test.js | 3 +- 8 files changed, 378 insertions(+), 123 deletions(-) delete mode 100644 .github/workflows/webos-release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d286c4c..aa0f1c4f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,12 +2,20 @@ name: Release → Telegram run-name: >- Release ${{ inputs.version != '' && inputs.version || inputs.bump }} -# Builds a signed Android TV APK, then records it in git, uploads it to the -# CDN, optionally offers it to the in-app updater, and sends it to Telegram. +# One release for every TV app, under one version: a signed Android TV APK, an +# unsigned Apple TV IPA (macOS runner) and an LG webOS IPK. It records them in +# git, attaches all three to one GitHub Release, puts the APK on the CDN, +# optionally offers it to the in-app updater, and sends everything to Telegram. # Runs only from Actions → this workflow → Run workflow, on the default branch. # -# Order: version + guard → tests → APK → bump commit, tag, GitHub Release → -# CDN + updater → Telegram. Nothing is pushed or published until the APK built. +# Order: version + guard → tests → APK, IPA, IPK → bump commit, tag, GitHub +# Release → CDN + updater → Telegram. Nothing is pushed or published until +# every requested build succeeded. +# +# Apple TV: there is no Apple distribution certificate here, so the IPA is not +# signed and people sideload it (Sideloadly, Xcode), which signs it with their +# own Apple ID. TestFlight stays in tvos-release.yml, for when the apple-tv +# environment has its secrets. # # Secrets: # ANDROID_TV_KEYSTORE_B64 base64 of the release keystore (.jks) @@ -68,6 +76,14 @@ on: description: 'Proceed if the published version cannot be read (a readable one is always enforced)' type: boolean default: false + apple_tv: + description: 'Also build the Apple TV IPA (unsigned, for sideloading)' + type: boolean + default: true + webos: + description: 'Also build the LG webOS IPK' + type: boolean + default: true concurrency: group: release-${{ github.ref }} @@ -88,6 +104,7 @@ jobs: code: ${{ steps.resolve.outputs.code }} tag: ${{ steps.resolve.outputs.tag }} bumped: ${{ steps.resolve.outputs.bumped }} + platforms: ${{ steps.resolve.outputs.platforms }} steps: - name: Refuse anything but the default branch env: @@ -107,6 +124,8 @@ jobs: env: BUMP: ${{ inputs.bump }} EXPLICIT: ${{ inputs.version }} + APPLE_TV: ${{ inputs.apple_tv }} + WEBOS: ${{ inputs.webos }} run: | set -euo pipefail GRADLE=app/build.gradle.kts @@ -155,11 +174,20 @@ jobs: exit 1 fi + if [ "${WEBOS}" = true ] && ! [[ "${NEW_NAME}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "::error title=Bad version for webOS::webOS takes only x.y.z, not '${NEW_NAME}'. Pick another version or untick webos." + exit 1 + fi + PLATFORMS=androidtv + if [ "${APPLE_TV}" = true ]; then PLATFORMS="${PLATFORMS},appletv"; fi + if [ "${WEBOS}" = true ]; then PLATFORMS="${PLATFORMS},webos"; fi + { echo "name=${NEW_NAME}" echo "code=${NEW_CODE}" echo "tag=${TAG}" echo "bumped=${BUMPED}" + echo "platforms=${PLATFORMS}" } >> "$GITHUB_OUTPUT" { echo "### Release version" @@ -335,9 +363,130 @@ jobs: dist/SHA256SUMS if-no-files-found: error + appletv: + name: Apple TV IPA + needs: version + if: inputs.apple_tv + runs-on: macos-26 + timeout-minutes: 30 + env: + HOMEBREW_NO_AUTO_UPDATE: '1' + HOMEBREW_NO_INSTALL_CLEANUP: '1' + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: '1' + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + + - name: Stamp the resolved version into the build + env: + NAME: ${{ needs.version.outputs.name }} + CODE: ${{ needs.version.outputs.code }} + run: python3 tools/release/stamp_version.py "${NAME}" "${CODE}" + + - name: Select Xcode + run: apple-tv/scripts/select-xcode.sh 26 + + - name: Install project generator + run: brew install xcodegen + + # No signing identity exists on this runner, and none is wanted: the + # sideloading tool signs the app with the installer's own Apple ID. + - name: Archive for Apple TV, unsigned + working-directory: apple-tv + run: | + set -euo pipefail + xcodegen generate + xcodebuild archive -project SozoTV.xcodeproj -scheme SozoTV -configuration Release \ + -destination 'generic/platform=tvOS' -archivePath build/release/SozoTV.xcarchive \ + CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -quiet + + - name: Package the IPA and check its version + env: + NAME: ${{ needs.version.outputs.name }} + CODE: ${{ needs.version.outputs.code }} + run: | + set -euo pipefail + APP=apple-tv/build/release/SozoTV.xcarchive/Products/Applications/SozoTV.app + PLIST="${APP}/Info.plist" + GOT_NAME="$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "${PLIST}")" + GOT_CODE="$(/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' "${PLIST}")" + if [ "${GOT_NAME}" != "${NAME}" ] || [ "${GOT_CODE}" != "${CODE}" ]; then + echo "::error title=Version mismatch::IPA carries ${GOT_NAME} (${GOT_CODE}), the release is ${NAME} (${CODE})." + exit 1 + fi + lipo -info "${APP}/SozoTV" + mkdir -p ipa/Payload dist + cp -R "${APP}" ipa/Payload/ + (cd ipa && zip -qry "../dist/sozo-tv-${NAME}-appletv.ipa" Payload) + ls -lh dist + echo "- Apple TV IPA **${NAME} (${CODE})**, unsigned" >> "$GITHUB_STEP_SUMMARY" + + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: sozo-tv-appletv + path: dist/*.ipa + if-no-files-found: error + + webos: + name: LG webOS IPK + needs: version + if: inputs.webos + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + + - name: Stamp the resolved version into the build + env: + NAME: ${{ needs.version.outputs.name }} + CODE: ${{ needs.version.outputs.code }} + run: python3 tools/release/stamp_version.py "${NAME}" "${CODE}" + + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: '22' + cache: npm + cache-dependency-path: webos/package-lock.json + + - name: Test and package + working-directory: webos + run: | + set -euo pipefail + npm ci --ignore-scripts + npm test + npm run package + + - name: Name the IPK after the release + env: + NAME: ${{ needs.version.outputs.name }} + run: | + set -euo pipefail + IPK="webos/dist/ipk/com.soplay.sozo.webos_${NAME}_all.ipk" + if [ ! -f "${IPK}" ]; then + echo "::error title=No IPK::expected ${IPK}; found: $(ls webos/dist/ipk)" + exit 1 + fi + mkdir -p dist + cp "${IPK}" "dist/sozo-tv-${NAME}-webos.ipk" + ls -lh dist + echo "- LG webOS IPK **${NAME}**" >> "$GITHUB_STEP_SUMMARY" + + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: sozo-tv-webos + path: dist/*.ipk + if-no-files-found: error + git: name: Commit, tag and GitHub Release - needs: [version, apk] + needs: [version, apk, appletv, webos] + # Apple TV and webOS may be switched off (skipped); a failed one stops it. + if: >- + ${{ !cancelled() && needs.apk.result == 'success' + && needs.appletv.result != 'failure' && needs.webos.result != 'failure' }} runs-on: ubuntu-latest timeout-minutes: 15 permissions: @@ -355,8 +504,17 @@ jobs: - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: - name: sozo-tv-apk + pattern: sozo-tv-* path: dist + merge-multiple: true + + - name: One checksum file for every app + run: | + set -euo pipefail + shopt -s nullglob + (cd dist && sha256sum -- *.apk *.ipa *.ipk > SHA256SUMS) + cat dist/SHA256SUMS + ls -lh dist - name: Commit the bump and push the tag id: tag @@ -365,6 +523,7 @@ jobs: CODE: ${{ needs.version.outputs.code }} TAG: ${{ needs.version.outputs.tag }} BUMPED: ${{ needs.version.outputs.bumped }} + PLATFORMS: ${{ needs.version.outputs.platforms }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} run: | set -euo pipefail @@ -387,10 +546,10 @@ jobs: PREV="$(git describe --tags --abbrev=0 HEAD 2>/dev/null || true)" git log ${PREV:+"${PREV}..HEAD"} --first-parent --format=%s > "${RUNNER_TEMP}/changes.txt" python3 tools/release/release_banner.py --version "${NAME}" --out "${BANNER}" \ - --log "${RUNNER_TEMP}/changes.txt" --keep \ + --log "${RUNNER_TEMP}/changes.txt" --platforms "${PLATFORMS}" --keep \ || echo "::warning title=No banner::the release page will have none" [ -f "${BANNER}" ] && git add "${BANNER}" - git add app/build.gradle.kts + git add app/build.gradle.kts apple-tv/project.yml webos/appinfo.json webos/js/app.js git commit -m "chore: ${NAME} (${CODE})" fi git tag "${TAG}" @@ -421,6 +580,7 @@ jobs: SHA: ${{ steps.tag.outputs.sha }} NOTES: ${{ inputs.notes }} UPDATER: ${{ inputs.updater }} + PLATFORMS: ${{ needs.version.outputs.platforms }} run: | set -euo pipefail if [ "${MODE}" = skip ]; then @@ -430,7 +590,9 @@ jobs: # What the backend reads when it takes this release from GitHub: the # versionCode no file name states plainly, the APK, and whether to - # offer it to installed TVs. + # offer it to installed TVs. Only the APK: the backend has no Apple + # TV or webOS download rows, and would file anything listed here + # under Android TV. APK_NAME="$(basename "$(find dist -name '*.apk' | head -1)")" jq -n --arg version "${NAME}" --argjson build "${CODE}" --arg sha "${SHA}" \ --arg notes "${NOTES}" --arg apk "${APK_NAME}" --arg updater "${UPDATER}" \ @@ -439,6 +601,7 @@ jobs: > "dist/sozo-tv-${NAME}-release.json" FILES=(dist/*.apk dist/SHA256SUMS "dist/sozo-tv-${NAME}-release.json") + for f in dist/*.ipa dist/*.ipk; do [ -f "${f}" ] && FILES+=("${f}"); done if gh release view "${TAG}" >/dev/null 2>&1; then gh release upload "${TAG}" "${FILES[@]}" --clobber else @@ -446,7 +609,7 @@ jobs: git log ${PREV:+"${PREV}..${SHA}"} --first-parent --format=%s > changes.txt python3 tools/release/release_page.py --version "${NAME}" --sha "${SHA}" \ --repo "${GH_REPO}" --tag "${TAG}" --assets dist --previous "${PREV}" \ - --log changes.txt --intro "${NOTES}" --auto --out RELEASE_NOTES.md + --log changes.txt --intro "${NOTES}" --platforms "${PLATFORMS}" --auto --out RELEASE_NOTES.md echo "── notes ──"; cat RELEASE_NOTES.md ARGS=(--target "${SHA}" --title "Sozo TV ${NAME}" --notes-file RELEASE_NOTES.md) if [ "${MODE}" = draft ]; then @@ -463,6 +626,7 @@ jobs: publish: name: CDN and in-app updater needs: [version, apk, git] + if: ${{ !cancelled() && needs.git.result == 'success' }} runs-on: ubuntu-latest timeout-minutes: 20 outputs: @@ -638,7 +802,7 @@ jobs: echo "::notice title=Updater::androidtv now offers versionCode ${CODE}" deliver: - needs: [version, apk, git, publish] + needs: [version, apk, appletv, webos, git, publish] # Always, even when something failed: a release that goes quiet is # indistinguishable from one nobody started. if: ${{ always() && !cancelled() }} @@ -656,8 +820,9 @@ jobs: - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 continue-on-error: true with: - name: sozo-tv-apk + pattern: sozo-tv-* path: dist + merge-multiple: true # The banner as a picture (Telegram cannot show SVG) and the caption. # Neither is fatal: without them the announcement goes out as text. @@ -666,14 +831,16 @@ jobs: env: NAME: ${{ needs.version.outputs.name }} NOTES: ${{ inputs.notes }} + PLATFORMS: ${{ needs.version.outputs.platforms }} run: | set -uo pipefail [ -n "${NAME}" ] || exit 0 PREV="$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)" git log ${PREV:+"${PREV}..HEAD"} --first-parent --format=%s > changes.txt python3 tools/release/release_page.py --version "${NAME}" --log changes.txt \ - --intro "${NOTES}" --telegram caption.html - python3 tools/release/release_banner.py --version "${NAME}" --still --log changes.txt --out banner.svg + --intro "${NOTES}" --platforms "${PLATFORMS}" --telegram caption.html + python3 tools/release/release_banner.py --version "${NAME}" --still --log changes.txt \ + --platforms "${PLATFORMS}" --out banner.svg timeout 120 sudo apt-get install -y -qq fonts-inter >/dev/null 2>&1 || true CHROME="$(command -v google-chrome || command -v chromium || command -v chromium-browser || true)" if [ -n "${CHROME}" ]; then @@ -703,6 +870,8 @@ jobs: CDN_URL: ${{ needs.publish.outputs.cdn_url }} UPDATER_STATUS: ${{ needs.publish.outputs.updater }} RELEASE_STATUS: ${{ needs.git.outputs.release }} + APPLE_TV_RESULT: ${{ needs.appletv.result }} + WEBOS_RESULT: ${{ needs.webos.result }} run: | set -uo pipefail @@ -732,6 +901,21 @@ jobs: exit 0 fi + if [ "${APPLE_TV_RESULT}" = failure ] || [ "${WEBOS_RESULT}" = failure ]; then + MSG="$(printf '⚠️ Sozo TV %s — release YIQILDI (Apple TV: %s, webOS: %s). Hech narsa chiqarilmadi.\n\n🔎 %s' \ + "${VERSION_NAME:-?}" "${APPLE_TV_RESULT}" "${WEBOS_RESULT}" "${RUN_URL}")" + for raw in "${CHATS[@]}"; do + chat="$(echo "${raw}" | xargs)" + [ -z "${chat}" ] && continue + curl -sS -X POST "${API}/sendMessage" \ + --data-urlencode "chat_id=${chat}" \ + --data-urlencode "text=${MSG}" \ + --data "disable_web_page_preview=true" -o /dev/null || true + done + echo "::warning title=Nothing delivered::A TV build failed, so nothing was released; a failure notice was sent instead." + exit 0 + fi + # 1. The announcement: banner, caption, buttons. A draft's page is # not public, so only a published release gets its button. BUTTONS="$(jq -cn --arg cdn "${CDN_URL}" --arg rel "${REL_URL}" \ @@ -767,6 +951,15 @@ jobs: fi FOOT="${FOOT}$(printf '\n\n💡 O‘rnatish: TV’da Downloader ilovasi orqali APK havolasini oching yoki USB orqali.')" + # Under the other two files: what they are and how they get onto a TV. + caption_for() { + case "$1" in + *.apk) printf '%s' "${FOOT}" ;; + *.ipa) printf '🍎 Sozo TV %s · Apple TV (tvOS 17+)\n\nImzosiz IPA: Sideloadly yoki Xcode orqali o‘z Apple ID’ingiz bilan o‘rnating. Bepul Apple ID’da 7 kunda qayta o‘rnatish kerak bo‘ladi.\n📖 Yo‘riqnoma: %s' "${VERSION_NAME}" "${REL_URL}" ;; + *.ipk) printf '🟣 Sozo TV %s · LG webOS (webOS 4+)\n\nTV’da Developer Mode ilovasini yoqing, so‘ng kompyuterdan ares-install bilan o‘rnating.\n📖 Yo‘riqnoma: %s' "${VERSION_NAME}" "${REL_URL}" ;; + esac + } + announce() { local chat="$1" if [ -s banner.png ] && [ -s caption.html ]; then @@ -788,18 +981,19 @@ jobs: } send_apk() { - local chat="$1" f size - for f in dist/*.apk; do + local chat="$1" f size cap + for f in dist/*.apk dist/*.ipa dist/*.ipk; do [ -f "${f}" ] || continue size="$(stat -c%s "${f}")" + cap="$(caption_for "${f}")" if [ "${size}" -gt "${MAX}" ]; then curl -sS --fail-with-body -X POST "${API}/sendMessage" --data-urlencode "chat_id=${chat}" \ - --data-urlencode "text=${FOOT}"$'\n\n'"⬇️ $(basename "${f}") ($((size/1024/1024)) MB) Telegram limitidan katta: ${REL_URL}" \ + --data-urlencode "text=${cap}"$'\n\n'"⬇️ $(basename "${f}") ($((size/1024/1024)) MB) Telegram limitidan katta: ${REL_URL}" \ --data "parse_mode=HTML" -o /tmp/tg_doc.json || return 1 continue fi curl -sS --fail-with-body -X POST "${API}/sendDocument" -F "chat_id=${chat}" \ - -F "document=@${f}" -F "caption=${FOOT}" -F "parse_mode=HTML" -o /tmp/tg_doc.json || return 1 + -F "document=@${f}" -F "caption=${cap}" -F "parse_mode=HTML" -o /tmp/tg_doc.json || return 1 echo " ✓ $(basename "${f}")" done } diff --git a/.github/workflows/webos-release.yml b/.github/workflows/webos-release.yml deleted file mode 100644 index 4d84c9e9..00000000 --- a/.github/workflows/webos-release.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: webOS release - -# Run by hand from the Actions tab. The version comes from webos/appinfo.json, -# so raise it there first. CI artifacts expire; a release keeps the ipk. -on: - workflow_dispatch: - inputs: - prerelease: - description: 'Mark as a pre-release (keep on until it has run on a real TV)' - type: boolean - default: true - -concurrency: - group: webos-release - cancel-in-progress: false - -permissions: - contents: write - -jobs: - release: - name: Test, package and publish the ipk - runs-on: ubuntu-latest - timeout-minutes: 15 - defaults: - run: - working-directory: webos - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: npm - cache-dependency-path: webos/package-lock.json - - name: Install - run: npm ci --ignore-scripts - - name: Unit and ES5 checks - run: npm test - - name: Build the ipk - run: npm run package - - name: Publish - env: - GH_TOKEN: ${{ github.token }} - PRERELEASE: ${{ inputs.prerelease }} - run: | - set -euo pipefail - version=$(node -p "require('./appinfo.json').version") - tag="webos-v$version" - if gh release view "$tag" >/dev/null 2>&1; then - echo "::error::$tag already exists. Raise the version in webos/appinfo.json." - exit 1 - fi - cd dist/ipk - ipk=$(ls ./*.ipk) - sha256sum "$ipk" > "$ipk.sha256" - flag=() - if [ "$PRERELEASE" = true ]; then flag=(--prerelease); fi - gh release create "$tag" "$ipk" "$ipk.sha256" \ - --target "$GITHUB_SHA" --title "Sozo for LG webOS $version" \ - --notes "Install steps: webos/README.md." --latest=false "${flag[@]}" diff --git a/tools/release/release_banner.py b/tools/release/release_banner.py index d1af8c0a..8dd21190 100644 --- a/tools/release/release_banner.py +++ b/tools/release/release_banner.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Draws the Android TV release banner for one version. +"""Draws the Sozo TV release banner for one version. The artwork and its animation are the phone app's v3.2.0 banner (banner-template.svg, copied from the sozo repository's tool/release_banner.py @@ -15,9 +15,10 @@ chips: Server switching | Corner player | 16 languages --> -Every key is optional. Without the comment, the eyebrow says ANDROID TV and -the month, the tagline is a generic one, and the chips name the areas of the -merged changes (see banner_text). +Every key is optional. Without the comment, the eyebrow says ANDROID TV (or +SMART TV when Apple TV or webOS ship too) and the month, the tagline is a +generic one, and the chips name the TVs released, then the areas of the merged +changes (see banner_text). --still writes a copy without animation, the frame a viewer with reduced motion sees. It is the one rendered to PNG for Telegram, which cannot show SVG. @@ -75,11 +76,15 @@ def kind_of(version): return "PATCH RELEASE" if parts[2] not in ("", "0") else "NEW RELEASE" -def banner_text(version, notes_text="", areas=(), today=None): +PLATFORMS = {"androidtv": "Android TV", "appletv": "Apple TV", "webos": "LG webOS"} + + +def banner_text(version, notes_text="", areas=(), today=None, platforms=("androidtv",)): today = today or dt.date.today() block = parse_block(notes_text) patch = kind_of(version) == "PATCH RELEASE" - eyebrow = block.get("eyebrow") or "ANDROID TV" + several = len(platforms) > 1 + eyebrow = block.get("eyebrow") or ("SMART TV" if several else "ANDROID TV") if "·" not in eyebrow: eyebrow = f"{eyebrow} · {today.strftime('%B %Y')}" line1 = block.get("line1") or ("Fixes for what you reported," if patch @@ -88,7 +93,8 @@ def banner_text(version, notes_text="", areas=(), today=None): if block.get("chips"): chips = [c.strip() for c in block["chips"].split("|") if c.strip()] else: - chips = list(dict.fromkeys(a for a in areas if a)) + tvs = [PLATFORMS[p] for p in platforms if p in PLATFORMS] if several else [] + chips = list(dict.fromkeys(tvs + [a for a in areas if a])) if not chips: chips = ["Android TV", "Google TV · Shield"] return {"eyebrow": eyebrow.upper(), "version": f"v{version}", "line1": line1, @@ -148,6 +154,10 @@ def still(svg): return svg.replace("@media (prefers-reduced-motion: reduce){", "@media all{", 1) +def platform_list(text): + return [p for p in (x.strip() for x in text.split(",")) if p in PLATFORMS] or ["androidtv"] + + def main(): p = argparse.ArgumentParser() p.add_argument("--version", required=True) @@ -156,6 +166,7 @@ def main(): p.add_argument("--root", default=".") p.add_argument("--log", default="", help="`git log --format=%%s` since the last tag; its areas are the chips when the notes name none") p.add_argument("--keep", action="store_true", help="leave an existing banner alone") + p.add_argument("--platforms", default="androidtv", help="comma-separated: androidtv,appletv,webos") a = p.parse_args() root = Path(a.root) out = Path(a.out) @@ -173,7 +184,7 @@ def main(): else: from release_page import areas, changes log = Path(a.log).read_text(encoding="utf-8").splitlines() if a.log else [] - t = banner_text(a.version, notes_text, areas(changes(log))) + t = banner_text(a.version, notes_text, areas(changes(log)), platforms=platform_list(a.platforms)) svg = render((root / TEMPLATE).read_text(encoding="utf-8"), t, a.still) out.parent.mkdir(parents=True, exist_ok=True) out.write_text(svg, encoding="utf-8") diff --git a/tools/release/release_page.py b/tools/release/release_page.py index a6928f12..ffd13712 100644 --- a/tools/release/release_page.py +++ b/tools/release/release_page.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 -"""Builds the Android TV release body from release/notes/v.md. +"""Builds the Sozo TV release body from release/notes/v.md. A copy of the phone app's tool/compose_release_notes.py (sozo repository), -adapted to one APK and the TV's paths. +adapted to the TV apps (Android TV APK, Apple TV IPA, LG webOS IPK) and the +TV repository's paths. Images may be written relative to the notes file. They become links to the exact commit being released, so they work in a draft before anything reaches @@ -30,7 +31,7 @@ import sys from pathlib import Path -from release_banner import banner_text, kind_of +from release_banner import PLATFORMS, banner_text, kind_of, platform_list IMAGE_BLOCK = re.compile(r']*>\s*(]*>)\s*

\n?', re.I) @@ -78,13 +79,22 @@ def markdown(match): return MD_IMG.sub(markdown, HTML_IMG.sub(html, text)) +# (file extension, device column, platform key), in the order of the table. +KINDS = [ + (".apk", "📺 Android TV, Google TV, Shield, TV boxes", "androidtv"), + (".ipa", "🍎 Apple TV (tvOS 17+), unsigned: sideload it", "appletv"), + (".ipk", "🟣 LG TV, webOS 4 and newer (Developer Mode)", "webos"), +] + + def downloads_table(assets, repo, tag, version): names = sorted(p.name for p in assets.iterdir()) if assets.is_dir() else [] rows = [] - for name in names: - if name.startswith(f"sozo-tv-{version}-") and name.endswith(".apk"): - url = f"https://github.com/{repo}/releases/download/{tag}/{name}" - rows.append(f"| 📺 Android TV, Google TV, Shield, TV boxes | [`{name}`]({url}) |") + for ext, device, _ in KINDS: + for name in names: + if name.startswith(f"sozo-tv-{version}-") and name.endswith(ext): + url = f"https://github.com/{repo}/releases/download/{tag}/{name}" + rows.append(f"| {device} | [`{name}`]({url}) |") if not rows: return "The files are attached to this release." lines = ["| Device | File |", "|---|---|", *rows] @@ -169,10 +179,70 @@ def compose(version, sha, repo, tag, assets, repo_root, warn): return text.replace("", downloads_table(assets, repo, tag, version)) -def generate(version, sha, repo, tag, previous, assets, repo_root, log_lines, intro=""): +INSTALL = { + "androidtv": [ + "
", + "📺 How to install it on an Android TV", + "", + "- **Updating:** if Sozo TV is already installed, it offers this version itself.", + "- **With Downloader:** install *Downloader* from the TV's app store, allow it to install", + " apps, and open the APK link above in it.", + "- **With a USB stick:** copy the APK onto it and open it with the TV's file manager.", + "", + "If the TV says the app is not installed, an older Sozo TV signed with a different key", + "is on it: uninstall that one first.", + "
", + ], + "appletv": [ + "
", + "🍎 How to install it on an Apple TV", + "", + "Sozo is not on the App Store, and this IPA is not signed. A sideloading tool signs it", + "with your own Apple ID while it installs:", + "", + "- **Sideloadly** (Windows/macOS): pair the Apple TV over Wi-Fi, drop the IPA in, sign in", + " with your Apple ID and press Start.", + "- **Xcode** (macOS): Window → Devices and Simulators, pair the Apple TV, then install the", + " IPA after signing it with your team.", + "", + "With a free Apple ID the app stops opening after 7 days and has to be installed again;", + "a paid developer account makes that a year.", + "
", + ], + "webos": [ + "
", + "🟣 How to install it on an LG TV (webOS)", + "", + "1. On the TV, install **Developer Mode** from the LG Content Store, sign in with a free", + " LG Developer account, turn on **Dev Mode Status** and let the TV restart.", + "2. In Developer Mode, turn on **Key Server**.", + "3. On a computer with Node.js on the same network:", + "", + " ```sh", + " npx @webos-tools/cli ares-setup-device # name tv, the TV's IP, port 9922, user prisoner", + " npx @webos-tools/cli ares-novacom --device tv --getkey", + " npx @webos-tools/cli ares-install --device tv sozo-tv--webos.ipk", + " ```", + "", + "Developer Mode runs out unless **EXTEND** is pressed in time; the app is removed with it.", + "On a rooted TV, install the IPK with Homebrew Channel or webOS Dev Manager instead.", + "
", + ], +} + + +def shipped(assets, version): + """Platform keys whose file is among the assets, in table order.""" + names = [p.name for p in assets.iterdir()] if assets.is_dir() else [] + return [key for ext, _, key in KINDS + if any(n.startswith(f"sozo-tv-{version}-") and n.endswith(ext) for n in names)] + + +def generate(version, sha, repo, tag, previous, assets, repo_root, log_lines, intro="", platforms=None): """A page in the layout of the phone app's v3.2.0 notes, for a version nobody wrote up.""" items = changes(log_lines) - t = banner_text(version, "", areas(items)) + platforms = platforms or shipped(assets, version) or ["androidtv"] + t = banner_text(version, "", areas(items), platforms=platforms) patch = kind_of(version) == "PATCH RELEASE" lines = [ '

', @@ -203,18 +273,10 @@ def generate(version, sha, repo, tag, previous, assets, repo_root, log_lines, in lines += [ "---", "", "## ⬇ Download", "", downloads_table(assets, repo, tag, version), "", - "

", - "📺 How to install it on a TV", - "", - "- **Updating:** if Sozo TV is already installed, it offers this version itself.", - "- **With Downloader:** install *Downloader* from the TV's app store, allow it to install", - " apps, and open the APK link above in it.", - "- **With a USB stick:** copy the APK onto it and open it with the TV's file manager.", - "", - "If the TV says the app is not installed, an older Sozo TV signed with a different key", - "is on it: uninstall that one first.", - "
", - "", + ] + for key in platforms: + lines += [l.replace("", version) for l in INSTALL[key]] + [""] + lines += [ "---", "", "## 💬 Join the community", "", f"- 📣 **Telegram**: [@sozoapp](https://telegram.me/sozoapp) for new versions and announcements first.", "- 🎧 **Discord**: [discord.gg/n22URhYvMR](https://discord.gg/n22URhYvMR) to suggest ideas and report bugs.", @@ -255,15 +317,18 @@ def shorten(md, limit=230): return md -def telegram_caption(version, notes_text, log_lines, intro=""): - t = banner_text(version, notes_text, areas(changes(log_lines))) +def telegram_caption(version, notes_text, log_lines, intro="", platforms=("androidtv",)): + t = banner_text(version, notes_text, areas(changes(log_lines)), platforms=platforms) kind = "yamoq (patch)" if kind_of(version) == "PATCH RELEASE" else "yangi versiya" head = [f"📺 Sozo TV v{html.escape(version)} · {kind}", f"{html.escape(t['line1'])} {html.escape(t['line2'])}"] + if len(platforms) > 1: + head.append("🖥 " + " · ".join(PLATFORMS[p] for p in platforms)) if intro.strip(): head += ["", f"📝 {html.escape(intro.strip())}"] head += ["", "✨ Nima yangi"] - tail = ["", "⬇️ APK shu xabar ostida · 📣 @sozoapp"] + files = "APK" if list(platforms) == ["androidtv"] else "Fayllar" + tail = ["", f"⬇️ {files} shu xabar ostida · 📣 @sozoapp"] bullets = [] uz = UZ_SUMMARY.search(notes_text or "") @@ -299,6 +364,7 @@ def main(): parser.add_argument("--intro", default="", help="text from the release form, put on top") parser.add_argument("--auto", action="store_true", help="generate a page when there are no notes") parser.add_argument("--root", default=".") + parser.add_argument("--platforms", default="", help="androidtv,appletv,webos (default: from --assets)") args = parser.parse_args() root = Path(args.root).resolve() log_lines = read_log(args.log) @@ -307,7 +373,8 @@ def main(): notes = notes_path(root, args.version) text = notes.read_text(encoding="utf-8") if notes.is_file() else "" Path(args.telegram).write_text( - telegram_caption(args.version, text, log_lines, args.intro), encoding="utf-8") + telegram_caption(args.version, text, log_lines, args.intro, + platform_list(args.platforms)), encoding="utf-8") if not args.out: return 0 @@ -315,7 +382,8 @@ def main(): body = compose(args.version, args.sha, args.repo, args.tag, Path(args.assets), root, warn) if body is None and args.auto: body = generate(args.version, args.sha, args.repo, args.tag, args.previous, - Path(args.assets), root, log_lines, args.intro) + Path(args.assets), root, log_lines, args.intro, + platform_list(args.platforms) if args.platforms else None) if body is None: print(f"No release/notes/v{args.version}.md") return 3 diff --git a/tools/release/release_page_test.py b/tools/release/release_page_test.py index a5185b0e..9b5c3748 100644 --- a/tools/release/release_page_test.py +++ b/tools/release/release_page_test.py @@ -50,11 +50,26 @@ def test_generated_page(self): out = generate("1.0.4", SHA, REPO, "v1.0.4", "1.0.2", self.assets, self.root, LOG, "Hotfix.") for part in ("Sozo TV v1.0.4 is a patch release", "Hotfix.", "### ▶️ Player", "[#40](https://github.com/o/r/pull/40)", "sozo-tv-1.0.4-4.apk", - "How to install it on a TV", "compare/1.0.2...v1.0.4", "sozo-tv?style"): + "How to install it on an Android TV", "compare/1.0.2...v1.0.4", "sozo-tv?style"): self.assertIn(part, out) self.assertNotIn("macOS", out) + self.assertNotIn("Apple TV", out) self.assertNotIn("a banner and a Telegram post", out) + def test_all_three_tvs(self): + for name in ("sozo-tv-1.0.4-webos.ipk", "sozo-tv-1.0.4-appletv.ipa"): + (self.assets / name).write_bytes(b"x") + out = generate("1.0.4", SHA, REPO, "v1.0.4", "", self.assets, self.root, LOG) + apk, ipa, ipk = (out.index(f"sozo-tv-1.0.4-{n}") for n in ("4.apk", "appletv.ipa", "webos.ipk")) + self.assertLess(apk, ipa) + self.assertLess(ipa, ipk) + for part in ("install it on an Android TV", "install it on an Apple TV", + "install it on an LG TV", "ares-install --device tv sozo-tv-1.0.4-webos.ipk"): + self.assertIn(part, out) + cap = telegram_caption("1.0.4", "", LOG, platforms=["androidtv", "appletv", "webos"]) + self.assertIn("🖥 Android TV · Apple TV · LG webOS", cap) + self.assertIn("⬇️ Fayllar shu xabar ostida", cap) + def test_caption(self): out = telegram_caption("1.0.4", "", LOG, "Bugun") self.assertTrue(out.startswith("📺 Sozo TV v1.0.4 · yamoq (patch)")) @@ -75,6 +90,9 @@ def test_tv_words(self): self.assertEqual(t["line2"], "on the big screen.") self.assertEqual(t["chips"], ["Android TV", "Google TV · Shield"]) self.assertEqual(banner_text("2.0.0", "", ["Player"])["line1"], "Everything new in Sozo TV 2.0.0,") + all3 = banner_text("1.0.4", "", ["Player"], dt.date(2026, 11, 14), ["androidtv", "appletv", "webos"]) + self.assertEqual(all3["eyebrow"], "SMART TV · NOVEMBER 2026") + self.assertEqual(all3["chips"], ["Android TV", "Apple TV", "LG webOS", "Player"]) def test_render(self): template = TEMPLATE.read_text(encoding="utf-8") diff --git a/tools/release/stamp_version.py b/tools/release/stamp_version.py index c284b3ef..f9c74c9f 100644 --- a/tools/release/stamp_version.py +++ b/tools/release/stamp_version.py @@ -1,22 +1,42 @@ #!/usr/bin/env python3 -"""Writes versionName and versionCode into app/build.gradle.kts. +"""Writes one release version into all three TV apps. python3 tools/release/stamp_version.py 1.0.4 4 + +Android TV: versionName/versionCode in app/build.gradle.kts. +Apple TV: MARKETING_VERSION/CURRENT_PROJECT_VERSION in apple-tv/project.yml. +LG webOS: "version" in webos/appinfo.json and VERSION in webos/js/app.js. + webOS only takes x.y.z; any other name leaves it as it is. """ import re import sys +from pathlib import Path + -PATH = 'app/build.gradle.kts' +def sub_once(path, pattern, repl): + p = Path(path) + src = p.read_text(encoding='utf-8') + out, n = re.subn(pattern, repl, src, count=1, flags=re.M) + if n != 1: + sys.exit(f'{path}: expected one match for {pattern}') + p.write_text(out, encoding='utf-8') def main() -> None: name, code = sys.argv[1], sys.argv[2] - src = open(PATH, encoding='utf-8').read() - src, n1 = re.subn(r'(?m)^(\s*versionCode\s*=\s*)\d+', rf'\g<1>{code}', src, count=1) - src, n2 = re.subn(r'(?m)^(\s*versionName\s*=\s*)"[^"]*"', rf'\g<1>"{name}"', src, count=1) - if n1 != 1 or n2 != 1: - sys.exit(f'expected one versionCode and one versionName, replaced {n1}/{n2}') - open(PATH, 'w', encoding='utf-8').write(src) + sub_once('app/build.gradle.kts', r'^(\s*versionCode\s*=\s*)\d+', rf'\g<1>{code}') + sub_once('app/build.gradle.kts', r'^(\s*versionName\s*=\s*)"[^"]*"', rf'\g<1>"{name}"') + + if Path('apple-tv/project.yml').is_file(): + sub_once('apple-tv/project.yml', r'^(\s*MARKETING_VERSION:\s*)"[^"]*"', rf'\g<1>"{name}"') + sub_once('apple-tv/project.yml', r'^(\s*CURRENT_PROJECT_VERSION:\s*)"[^"]*"', rf'\g<1>"{code}"') + + if Path('webos/appinfo.json').is_file(): + if re.fullmatch(r'\d+\.\d+\.\d+', name): + sub_once('webos/appinfo.json', r'^(\s*"version"\s*:\s*)"[^"]*"', rf'\g<1>"{name}"') + sub_once('webos/js/app.js', r"^(\s*var VERSION = )'[^']*'", rf"\g<1>'{name}'") + else: + print(f'::warning::webOS takes only x.y.z; {name} not written to webos/') if __name__ == '__main__': diff --git a/webos/README.md b/webos/README.md index ae93387a..cdb5c3be 100644 --- a/webos/README.md +++ b/webos/README.md @@ -36,7 +36,10 @@ allowed, because `service/` is held to ES5 by the tests. `hls.min.js`, so the ES5 checks would no longer describe what ships. The `webOS CI` workflow also builds the ipk and keeps it as the `sozo-webos-ipk` artifact for 14 days. -The `webOS release` workflow, run by hand, publishes it as a `webos-v` GitHub pre-release. The version comes from `appinfo.json`. +The TV release workflow (`.github/workflows/release.yml`, Actions → Release → Telegram) builds this ipk +together with the Android TV APK and the Apple TV IPA, gives all three the same version (it writes it into +`appinfo.json` and `js/app.js`), and attaches the ipk to the same GitHub Release as +`sozo-tv--webos.ipk`. ## Install with Developer Mode diff --git a/webos/test/compat.test.js b/webos/test/compat.test.js index 732d822b..420220ff 100644 --- a/webos/test/compat.test.js +++ b/webos/test/compat.test.js @@ -96,7 +96,8 @@ test('css stays inside the Chromium 53 baseline', () => { test('appinfo.json holds the agreed manifest', () => { const a = JSON.parse(read('appinfo.json')); assert.equal(a.id, 'com.soplay.sozo.webos'); - assert.equal(a.version, '1.0.0'); + assert.match(a.version, /^\d+\.\d+\.\d+$/); + assert.match(read('js/app.js'), new RegExp("var VERSION = '" + a.version.replace(/\./g, '\\.') + "'")); assert.equal(a.type, 'web'); assert.equal(a.main, 'index.html'); assert.equal(a.resolution, '1920x1080'); From c15c28ef626786455856793840006501270886fd Mon Sep 17 00:00:00 2001 From: professorDeveloper <108933534+professorDeveloper@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:49:18 +0500 Subject: [PATCH 2/2] Mirror every published release to Sozo-app/sozo-tv mirror-release.yml copies the tag (made through the API at the same commit), title, notes and files of a published release to the organization's copy. It runs on Publish, by hand, and from release.yml when that publishes itself. --- .github/workflows/mirror-release.yml | 126 +++++++++++++++++++++++++++ .github/workflows/release.yml | 8 +- 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mirror-release.yml diff --git a/.github/workflows/mirror-release.yml b/.github/workflows/mirror-release.yml new file mode 100644 index 00000000..250bb797 --- /dev/null +++ b/.github/workflows/mirror-release.yml @@ -0,0 +1,126 @@ +name: Mirror release → Sozo-app +run-name: Mirror ${{ inputs.tag || github.event.release.tag_name }} to Sozo-app + +# Copies a published release of this repository to the Sozo-app organization's +# copy of it (Sozo-app/): the tag at the same commit, the title, +# the notes and every file. +# +# Runs when a release is published here, and by hand (Actions → this workflow) +# for a release that changed afterwards, e.g. files added by a later run. +# release.yml starts it too when it publishes or adds files itself, because +# what GITHUB_TOKEN does starts no workflow. +# +# The organization's repositories are forks whose branches went their own way, +# so no branch is touched. The tag is made through the API: forks see the +# commits of this repository, so nothing has to be pushed. The copy is built as +# a draft and published once its files are attached, which also keeps the +# fork's own `push: tags` release workflow from building anything (its gate +# skips a tag that already has a release). +# +# Secret: SOZO_APP_TOKEN, a token that can write the organization's repository +# (fine-grained: resource owner Sozo-app, Contents read and write). +# Optional variable: MIRROR_REPO, owner/name of the copy if it is not +# Sozo-app/. + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: 'Tag of a published release in this repository, e.g. v3.2.1' + required: true + type: string + +permissions: + contents: read + +concurrency: + group: mirror-release-${{ inputs.tag || github.event.release.tag_name }} + cancel-in-progress: false + +jobs: + mirror: + # The organization's fork carries this file too; it must not copy itself. + if: github.repository_owner == 'professorDeveloper' + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Copy the release + env: + TAG: ${{ inputs.tag || github.event.release.tag_name }} + SRC: ${{ github.repository }} + DEST: ${{ vars.MIRROR_REPO || format('Sozo-app/{0}', github.event.repository.name) }} + SRC_TOKEN: ${{ github.token }} + DEST_TOKEN: ${{ secrets.SOZO_APP_TOKEN }} + run: | + set -euo pipefail + if [ -z "${DEST_TOKEN}" ]; then + echo "::error title=No SOZO_APP_TOKEN::Add a token that can write ${DEST} as the SOZO_APP_TOKEN secret of ${SRC}." + exit 1 + fi + src() { GH_TOKEN="${SRC_TOKEN}" gh "$@"; } + dest() { GH_TOKEN="${DEST_TOKEN}" gh "$@"; } + + # /releases/tags/ answers only for a published release. + if ! src api "repos/${SRC}/releases/tags/${TAG}" > rel.json; then + echo "::error title=No published release::${SRC} has no published release ${TAG}." + exit 1 + fi + SHA="$(src api "repos/${SRC}/commits/${TAG}" --jq .sha)" + LATEST="$(src api "repos/${SRC}/releases/latest" --jq .tag_name 2>/dev/null || true)" + MAKE_LATEST=false + if [ "${LATEST}" = "${TAG}" ]; then MAKE_LATEST=true; fi + echo "${SRC} ${TAG} at ${SHA} → ${DEST} (latest: ${MAKE_LATEST})" + + # The tag the copy already has must be this commit; an existing one + # that is not is somebody else's, and is left for a person to sort out. + if dest api "repos/${DEST}/git/ref/tags/${TAG}" > ref.json 2>/dev/null; then + HAVE="$(jq -r .object.sha ref.json)" + if [ "$(jq -r .object.type ref.json)" = tag ]; then + HAVE="$(dest api "repos/${DEST}/git/tags/${HAVE}" --jq .object.sha)" + fi + if [ "${HAVE}" != "${SHA}" ]; then + echo "::error title=Tag differs::${DEST} already has ${TAG} at ${HAVE}, not ${SHA}. Delete it there and run this again." + exit 1 + fi + fi + + # Links to this release's files point at the copy's files instead. + jq --arg src "github.com/${SRC}/releases/download/" \ + --arg dest "github.com/${DEST}/releases/download/" \ + --arg sha "${SHA}" '{ + tag_name: .tag_name, target_commitish: $sha, name: .name, + body: ((.body // "") | split($src) | join($dest)), + prerelease: .prerelease }' rel.json > fields.json + + # Includes drafts, which /releases/tags/ does not see. + ID="$(dest api --paginate "repos/${DEST}/releases" \ + --jq ".[] | select(.tag_name == \"${TAG}\") | .id" | head -1)" + if [ -n "${ID}" ]; then + dest api -X PATCH "repos/${DEST}/releases/${ID}" --input fields.json > /dev/null + echo "Updating the existing release ${ID}" + else + jq '. + {draft: true}' fields.json > create.json + ID="$(dest api -X POST "repos/${DEST}/releases" --input create.json --jq .id)" + echo "Created draft ${ID}" + fi + + mkdir -p assets + src release download "${TAG}" -R "${SRC}" -D assets + shopt -s nullglob + FILES=(assets/*) + if [ "${#FILES[@]}" -gt 0 ]; then + ls -lh assets + dest release upload "${TAG}" -R "${DEST}" "${FILES[@]}" --clobber + fi + + dest api -X PATCH "repos/${DEST}/releases/${ID}" -F draft=false \ + -f make_latest="${MAKE_LATEST}" --jq .html_url > url.txt + echo "::notice title=Mirrored::$(cat url.txt)" + { + echo "### ${TAG} → ${DEST}" + echo "" + echo "- $(cat url.txt)" + echo "- ${#FILES[@]} files, commit \`${SHA}\`" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa0f1c4f..f5b73a74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -491,6 +491,7 @@ jobs: timeout-minutes: 15 permissions: contents: write + actions: write # starts mirror-release.yml outputs: sha: ${{ steps.tag.outputs.sha }} release: ${{ steps.release.outputs.status }} @@ -617,10 +618,15 @@ jobs: fi gh release create "${TAG}" "${FILES[@]}" "${ARGS[@]}" fi - if [ "${MODE}" = draft ]; then + if [ "$(gh release view "${TAG}" --json isDraft --jq .isDraft)" = true ]; then echo "status=draft" >> "$GITHUB_OUTPUT" else echo "status=published" >> "$GITHUB_OUTPUT" + # What GITHUB_TOKEN publishes starts no workflow, so the copy for + # the Sozo-app organization is started by hand. A draft is copied + # when somebody presses Publish. + gh workflow run mirror-release.yml --ref "${GITHUB_REF_NAME}" -f tag="${TAG}" \ + || echo "::warning title=Not mirrored::Run 'Mirror release → Sozo-app' for ${TAG} by hand." fi publish: