Skip to content

Rebrand as OpenStream (StudioAs Inc.) + CI: build APK → send to Telegram - #1

Open
TheRealAshik wants to merge 2 commits into
mainfrom
rebrand/openstream
Open

TheRealAshik wants to merge 2 commits into
mainfrom
rebrand/openstream

Conversation

@TheRealAshik

@TheRealAshik TheRealAshik commented Nov 6, 2026 •

Copy link
Copy Markdown

What this does

Renames the product to OpenStream under StudioAs Inc. (lead developer @TheRealAshik) and adds a CI pipeline that builds the APKs and posts them to Telegram.

1. Rebrand

Surface Before After
Kotlin package / applicationId / namespace app.moviedb app.openstream
Module namespaces app.moviedb.core, .designsystem, .home, .detail, .favorites app.openstream.*
Compose theme MoviedbTheme OpenStreamTheme
XML style Theme.Moviedb Theme.OpenStream
Deps.APP_NAME MovieDB OpenStream
rootProject.name moviedb openstream
Launcher label (app_name) moviedb OpenStream
Home screen title (home_title) MovieDB OpenStream
README / docs MovieDB, upstream ainulbedjo/owl image URLs OpenStream + studio credit, in-repo screenshot/ assets

The diff touches 141 paths (GitHub lists one moved file as a separate delete + add, because its content changed enough to skip rename detection). Every source directory was moved with git mv so history follows the files, and package declarations were verified against their paths (120 Kotlin files with a package declaration, 0 mismatches). themoviedb.org API/image URLs were explicitly protected from the rename and are unchanged.

2. CI: build → Telegram

.github/workflows/android.yml — two jobs:

  • 🧪 Unit tests: ./gradlew testDebugUnitTest on JDK 21.
  • 📦 Build APK: assembleDebug + assembleRelease, renames them to OpenStream-<flavor>-<shortsha>.apk, uploads a 30-day artifact, then sends both files to Telegram via scripts/telegram_send.py.

Triggers: push to main and rebrand/**, tags v*, PRs to main, and workflow_dispatch (with a toggle to skip the Telegram post).

The send step keeps the env block you asked for:

- name: 📨 Send APKs to Telegram
  env:
    API_ID: ${{ secrets.TELEGRAM_API_ID }}
    API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
    BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
    CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
    TOPIC_ID: ${{ secrets.TELEGRAM_TOPIC_ID }}

scripts/telegram_send.py is checked in rather than pulled from an unnamed third-party action, because that step receives API_HASH + BOT_TOKEN and it should be auditable. It uses Telethon over MTProto (client.start(bot_token=...), which is why API_ID/API_HASH are needed at all), routes to TOPIC_ID via reply_to with a graceful fallback to the chat root, sends each APK as a document with a caption containing sha/branch/size/run link, and reads credentials only from the environment. Tested locally against a stubbed Telethon: init → bot login → get_entity → topic send → fallback path all behave, and the missing-secret / missing-file / >50 MB cases exit with clear errors.

3. Secrets to configure

Repo Settings → Secrets and variables → Actions:

  • TMDB_ACCESS_TOKEN, TMDB_API_KEY — core/build.gradle.kts reads access_token/api_key from local.properties, so the workflow writes that file from secrets and deletes it in an always() cleanup step. Without a token the APK still builds but every API call fails at runtime, so the step emits a ::warning::.
  • TELEGRAM_API_ID, TELEGRAM_API_HASH, TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, and optionally TELEGRAM_TOPIC_ID.

The Telegram bot must be a member of the target chat (admin with "Send messages" for channels), and TOPIC_ID only works in a forum-enabled supergroup.

Things worth knowing before merging

  • Workflow gating was broken on the first commit and is fixed here. The initial version put secrets.* inside a step if:, which GitHub does not allow; the first Actions run died at parse time in 0s with no log. The reworked version probes secret presence in a preceding step that emits only a boolean, and moves branch/run values into env: so nothing untrusted is interpolated into the shell. actionlint now reports zero findings, and both the push and pull_request runs start normally (run 42240728129 / 42240734494).
  • Not compiled here. The sandbox has no Android SDK, so this branch is verified structurally (package/path consistency, YAML parses, script unit behaviour) but assembleDebug was never run. First CI run is the real test.
  • API 37 package ids. sdkmanager has no platforms;android-37 — only android-37.0, 37.1, 37.2 (plus build-tools;37.0.0, which does exist). The workflow tries the ids in a tolerant loop and lets AGP auto-download whatever remains. If the build job complains about the compile SDK, pin the exact extension version in Deps.COMPILE_SDK.
  • Release APK is unsigned. app/build.gradle.kts has no signingConfig, so assembleRelease produces an APK you can't install over a signed one. The caption labels it "Release (unsigned)". Say the word and I'll wire a keystore from secrets (KEYSTORE_BASE64 + passwords) into the workflow.
  • Room schema path. core/schemas/*.json stores table SQL only, no class names, so the package rename doesn't change schema identity. But applicationId changing from app.moviedb to app.openstream means an existing MovieDB install won't upgrade in place — it's a separate app now.
  • Icon/logo art is still the upstream owl. Replacing brand artwork is a design task, not a text rename; the adaptive icon and README logo are unchanged apart from links.

Attribution

This is a rebrand of MovieDB by Ainul (ainulbedjo/owl), which is MIT licensed. The upstream copyright and permission notice stay in LICENSE — the license requires that in any copy or derivative — with StudioAs Inc. added as the holder of the OpenStream modifications. The README states the lineage in plain terms rather than hiding it.

Test plan

  • Merge to a test branch and run the workflow manually (workflow_dispatch, Telegram toggle off) to confirm the build matrix.
  • Add the Telegram secrets, run again with the toggle on, and confirm both APKs land in the intended topic.
  • Install the debug APK on a device and check the launcher label reads "OpenStream" and the Home title renders.
  • Verify TMDB calls succeed with TMDB_ACCESS_TOKEN set.

Product identity
- Rename the Kotlin package and applicationId/namespace app.moviedb -> app.openstream
  across all modules (app, core, designsystem, feature/{home,detail,favorites}).
- MoviedbTheme -> OpenStreamTheme, Theme.Moviedb -> Theme.OpenStream,
  Deps.APP_NAME -> "OpenStream", rootProject.name -> "openstream".
- Launcher label and the Home title string now read "OpenStream".
- README, docs and screenshot links rewritten for the fork, pointing at in-repo assets.
- Studio credit: StudioAs Inc., lead developer @TheRealAshik (README + docs + LICENSE).

CI: .github/workflows/android.yml
- Unit tests, then assembleDebug + assembleRelease with JDK 21.
- APKs are renamed OpenStream-{debug,release}-<sha>.apk, uploaded as artifacts, and
  sent to Telegram by scripts/telegram_send.py (Telethon, MTProto bot upload).
- TMDB access_token/api_key injected into local.properties from secrets and cleaned up
  afterwards, since core/build.gradle.kts reads them from that file.
- Send step needs TELEGRAM_API_ID/API_HASH/BOT_TOKEN/CHAT_ID and optional TOPIC_ID, and
  is skipped for fork pull requests so secrets never reach untrusted code.

Attribution
- Upstream MIT copyright (Ainul / ainulbedjo/owl) is retained in LICENSE as the license
  requires; StudioAs Inc. is listed as the copyright holder of the OpenStream changes.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR renames the project to OpenStream and introduces a CI pipeline that builds APKs and posts them to Telegram. The rebrand itself (package/namespace/string renames) looks mechanically clean. The critical issues are in the new CI workflow and Telegram send script.

🔴 Must-Fix Before Merge

  1. Supply-chain risk in .github/workflows/android.yml — All third-party actions are pinned to mutable major-version tags (@v7, @v6, @v4). This job receives BOT_TOKEN and API_HASH as secrets; a tag re-point is all it takes to exfiltrate them. Every action must be pinned to an immutable full commit SHA.

  2. pipefail + head -n1 crash risk — The release APK collection step (find ... | head -n1) under set -euo pipefail can fail with SIGPIPE (exit 141) when find produces more output than head reads. A || true guard and an explicit empty-check are needed.

  3. Silent over-limit failure in scripts/telegram_send.py — When an APK exceeds the 50 MB Telegram bot limit, a warning is printed but the upload is attempted anyway, failing with a cryptic API error. The function should exit with a non-zero return code at that point.

  4. Missing success log for topic sends in scripts/telegram_send.py — A successful send_file via reply_to hits continue and skips the ✅ Sent print. CI logs will show no confirmation for topic deliveries, making it unverifiable whether the file was actually sent.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.


⚠️ This PR contains more than 30 files. Amazon Q is better at reviewing smaller PRs, and may miss issues in larger changesets.

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: All action steps are pinned to mutable major-version tags (@v7, @v6, @v4) rather than immutable commit SHAs. This CI job receives BOT_TOKEN and API_HASH as environment secrets — a tag can be silently re-pointed to malicious code that exfiltrates those credentials. Pin every third-party action to a full commit SHA (e.g., actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683).

Comment on lines +125 to +126
release_apk="$(find app/build/outputs/apk/release -name '*.apk' | head -n1)"
cp "$release_apk" "$out/OpenStream-release-$short.apk"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Crash Risk: find ... | head -n1 under set -euo pipefail can cause a spurious SIGPIPE (exit code 141) when find has more results than head consumes, which pipefail treats as a pipeline failure. Additionally, if find returns no APK (e.g., assembleRelease only produced app-release-unsigned.apk in a subdirectory), release_apk is empty and the subsequent cp "$release_apk" silently copies nothing with a confusing error. Use a || true to suppress the SIGPIPE and add an explicit check for an empty result.

Suggested change
release_apk="$(find app/build/outputs/apk/release -name '*.apk' | head -n1)"
cp "$release_apk" "$out/OpenStream-release-$short.apk"
release_apk="$(find app/build/outputs/apk/release -name '*.apk' | head -n1 || true)"
if [ -z "$release_apk" ]; then
echo "::error::No release APK found under app/build/outputs/apk/release"
exit 1
fi
cp "$release_apk" "$out/OpenStream-release-$short.apk"

Comment thread scripts/telegram_send.py
Comment on lines +133 to +141
for path, caption in zip(files, captions):
print(f"→ {path} ({human_size(path.stat().st_size)})")
print(caption)
if path.stat().st_size > BOT_UPLOAD_LIMIT:
print(
"⚠️ Over the 50 MB bot upload limit — this send will fail. "
"Use a user session or split the build.",
file=sys.stderr,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: When a file exceeds the 50 MB bot upload limit, the warning is printed but execution continues and asyncio.run(upload(...)) is still called. The upload will then fail with a cryptic Telegram API rejection rather than a clean early exit. Add a hard exit after the warning to fail fast with a clear error message.

Suggested change
for path, caption in zip(files, captions):
print(f"→ {path} ({human_size(path.stat().st_size)})")
print(caption)
if path.stat().st_size > BOT_UPLOAD_LIMIT:
print(
"⚠️ Over the 50 MB bot upload limit — this send will fail. "
"Use a user session or split the build.",
file=sys.stderr,
)
for path, caption in zip(files, captions):
print(f"→ {path} ({human_size(path.stat().st_size)})")
print(caption)
if path.stat().st_size > BOT_UPLOAD_LIMIT:
print(
"⚠️ Over the 50 MB bot upload limit — this send will fail. "
"Use a user session or split the build.",
file=sys.stderr,
)
return 1

Comment thread scripts/telegram_send.py
Comment on lines +96 to +110
if topic_id:
try:
await client.send_file(entity, str(path), reply_to=int(topic_id), **kwargs)
continue
except (ValueError, TypeError):
# Older/newer Telethon naming for forum topics; fall through.
pass
except Exception as exc: # noqa: BLE001 - topic routing is best effort
print(
f"⚠️ TOPIC_ID={topic_id} rejected ({exc.__class__.__name__}); "
"sending to the chat instead.",
file=sys.stderr,
)
await client.send_file(entity, str(path), **kwargs)
print(f"✅ Sent {path.name}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: When topic_id is set and the broad except Exception branch is hit (line 103–108), the code prints a warning and then falls through to await client.send_file(entity, str(path), **kwargs) at line 109. However, print(f"✅ Sent {path.name}") at line 110 is only reached via the fallback path — this means a successful topic send via continue correctly skips the success print. The bug is that a successful topic send never prints the ✅ confirmation, making it impossible to verify in CI logs that the file was actually sent.

Suggested change
if topic_id:
try:
await client.send_file(entity, str(path), reply_to=int(topic_id), **kwargs)
continue
except (ValueError, TypeError):
# Older/newer Telethon naming for forum topics; fall through.
pass
except Exception as exc: # noqa: BLE001 - topic routing is best effort
print(
f"⚠️ TOPIC_ID={topic_id} rejected ({exc.__class__.__name__}); "
"sending to the chat instead.",
file=sys.stderr,
)
await client.send_file(entity, str(path), **kwargs)
print(f"✅ Sent {path.name}")
if topic_id:
try:
await client.send_file(entity, str(path), reply_to=int(topic_id), **kwargs)
print(f"✅ Sent {path.name} (topic {topic_id})")
continue
except (ValueError, TypeError):
# Older/newer Telethon naming for forum topics; fall through.
pass
except Exception as exc: # noqa: BLE001 - topic routing is best effort
print(
f"⚠️ TOPIC_ID={topic_id} rejected ({exc.__class__.__name__}); "
"sending to the chat instead.",
file=sys.stderr,
)
await client.send_file(entity, str(path), **kwargs)
print(f"✅ Sent {path.name}")

The first Actions run failed at parse time (0s, no log) because the send step
referenced `secrets.*` in its `if:` expression, which GitHub does not allow in
step conditionals. Presence of the Telegram secrets is now probed in a preceding
step that exports only a boolean output, and the branch/run values move into the
step `env:` block so nothing untrusted is interpolated into the shell body.

actionlint now reports no findings for this workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant