Skip to content

Dev2alpha#181

Merged
mkdir700 merged 2 commits intoalphafrom
dev2alpha
Sep 16, 2025
Merged

Dev2alpha#181
mkdir700 merged 2 commits intoalphafrom
dev2alpha

Conversation

@mkdir700
Copy link
Owner

@mkdir700 mkdir700 commented Sep 16, 2025

Summary by CodeRabbit

  • New Features
    • Regional update routing for users in China to improve download speed and reliability.
    • Added dedicated alpha and beta prerelease channels for China.
    • Production updates now consistently sourced from the stable feed for all users.
  • Chores
    • Release sync workflow now triggers on prereleases and can auto-populate release notes when manually run, with sensible fallbacks.

…xperience (#177)

- Set PRODUCTION URL to China mirror (http://release.echoplayer.z2blog.com/api/releases)
- Add CN_ALPHA and CN_BETA URLs for Chinese users' pre-release channels
- Simplify AppUpdater logic to use PRODUCTION URL for all stable releases
- Maintain GitHub URLs for non-CN users in test mode
- Improve logging to distinguish China mirror usage
…gger without description (#179)

- Add logic to automatically fetch release description from GitHub API when manual workflow trigger doesn't provide release_body
- Fallback to informative default message if release not found or has no description
- Maintain existing behavior when release_body is explicitly provided
- Improve user experience by eliminating need to manually copy descriptions
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

Walkthrough

Adds prerelease trigger and description-fetch fallback to the GitHub Actions workflow. Updates feed URLs with CN-specific endpoints. Modifies AppUpdater to route feeds based on IP-derived country, selecting CN alpha/beta or production feeds for China users while preserving GitHub-based logic for others; production always uses production feed.

Changes

Cohort / File(s) Summary
Workflow: Release sync
.github/workflows/sync-release-to-gitcode.yml
Trigger includes prereleased. Manual run now fetches release_body via GitHub API when absent, with default fallback on 404/empty. Non-functional whitespace tweaks elsewhere.
Config: Feed URLs
packages/shared/config/constant.ts
Updated FeedUrl.PRODUCTION to http://release.echoplayer.z2blog.com/api/releases. Added FeedUrl.CN_BETA and FeedUrl.CN_ALPHA. Trailing comma on PRERELEASE_LOWEST.
Updater: IP-based routing
src/main/services/AppUpdater.ts
Introduces IP country check. CN users: use production for latest; for testPlan pre-releases, select CN_ALPHA or CN_BETA. Non-CN retains GitHub latest/prerelease behavior. Production path now always uses production feed. Logging adjusted.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as AppUpdater
  participant IP as IP Service
  participant GH as GitHub Releases
  participant CN as CN Release API

  User->>App: checkForUpdates(mode, channel, testPlan?)
  App->>IP: _getIpCountry()
  IP-->>App: countryCode

  alt mode == production
    App->>CN: setFeedURL(FeedUrl.PRODUCTION)
    App-->>User: proceed with production updates
  else mode == latest (test plan latest)
    alt countryCode == CN
      App->>CN: setFeedURL(FeedUrl.PRODUCTION)
      App-->>User: using production releases for CN user
    else Non-CN
      App->>GH: setFeedURL(FeedUrl.GITHUB_LATEST)
      App-->>User: using GitHub latest releases
    end
  else mode == prerelease (specific tag)
    alt countryCode == CN
      App->>CN: setFeedURL(FeedUrl.CN_ALPHA or FeedUrl.CN_BETA)
      App-->>User: using CN prerelease feed
    else Non-CN
      App->>GH: compute prerelease URL from tag
      App->>GH: setFeedURL(prerelease URL)
      App-->>User: using GitHub prerelease feed
      opt if missing prerelease URL
        App->>CN: setFeedURL(FeedUrl.PRERELEASE_LOWEST)
        App-->>User: fallback to lowest prerelease, channel LATEST
      end
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

A rabbit checks the clouds for news,
Hops by IP to choose the views.
For CN skies, a local stream,
For others, GitHub’s shiny beam.
Releases sync, descriptions chime—
Carrots shipped on tag-time.
Thump-thump: deploy sublime.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "Dev2alpha" is a short branch-merge label that correctly indicates source and target branches but does not describe the substantive changes in this PR (release workflow changes, FeedUrl additions for CN, and IP-based update feed routing). Because it does not summarize the primary code changes, a teammate scanning history would not understand the PR's intent from the title alone. This makes the title non-descriptive and therefore inconclusive against the requirement to highlight the most important change. Please rename the PR to a concise, descriptive title that highlights the primary changes, for example: "Add CN-specific update feeds and IP-based routing; include prerelease in release workflow". A shorter acceptable alternative is "Add CN feed routing and extend release workflow for prereleases". Updating the title will help reviewers and future readers quickly understand the PR's main purpose.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev2alpha

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (8)
.github/workflows/sync-release-to-gitcode.yml (2)

399-415: Uploader step: minor hardening.

  • chmod +x is unnecessary since you invoke via node (harmless though).
  • Fail fast: enable set -eo pipefail to surface partial failures.
-            # Make upload script executable
-            chmod +x ./scripts/upload-assets.js
+            # Fail-fast in this step
+            set -eo pipefail

236-239: Avoid putting the GitCode token in URLs — use an Authorization header.

Query params like ?access_token= can leak in logs/proxies; GitCode supports Authorization: Bearer (and also PRIVATE-TOKEN), so send the token in a header instead. (docs.gitcode.com)

File: .github/workflows/sync-release-to-gitcode.yml — lines: 236-239 (also applies to: 264-267, 318-319, 366-366)

- "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/tags?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}")
+ -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \
+ "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/tags")
@@
- "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/tags/${{ steps.release.outputs.tag_name }}?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}")
+ -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \
+ "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/tags/${{ steps.release.outputs.tag_name }}")
@@
- "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}")
+ -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \
+ "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases")
@@
- "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/${{ steps.release.outputs.tag_name }}?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}")
+ -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \
+ "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/${{ steps.release.outputs.tag_name }}")
src/main/services/AppUpdater.ts (6)

117-139: IP-based routing: privacy default and UA.

  • Defaulting to 'CN' on any error will misroute most users when ipinfo fails. Default to non‑CN (or persist last known).
  • Reuse your existing generateUserAgent() for consistency.
  • Log with object-literal payload per project guideline.
   private async _getIpCountry() {
     try {
       // add timeout using AbortController
       const controller = new AbortController()
       const timeoutId = setTimeout(() => controller.abort(), 5000)

-      const ipinfo = await fetch('https://ipinfo.io/json', {
+      const ipinfo = await fetch('https://ipinfo.io/json', {
         signal: controller.signal,
         headers: {
-          'User-Agent':
-            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
+          'User-Agent': generateUserAgent(),
           'Accept-Language': 'en-US,en;q=0.9'
         }
       })

       clearTimeout(timeoutId)
       const data = await ipinfo.json()
-      return data.country || 'CN'
+      return (data.country || 'ZZ').toUpperCase()
     } catch (error) {
-      logger.error('Failed to get ipinfo:', error)
-      return 'CN'
+      logger.error('Failed to get ipinfo', { error })
+      return 'ZZ'
     }
   }

172-193: CN routing gated on release presence; CN users may never hit CN feeds.

if (testPlan && release) guards the CN prerelease path. When GitHub is blocked or rate‑limited (common in CN), release is null and CN users fall through to production feeds. Move CN selection to depend only on testPlan and channel, not on release.

Apply:

   private async _setFeedUrl(
     channel: UpgradeChannel,
     testPlan: boolean,
     release: GithubReleaseInfo | null = null
   ) {
     logger.info('Setting feed URL - testPlan:', testPlan)
-
-    // 获取IP地址归属地
-    const ipCountry = await this._getIpCountry()
-    logger.info('Detected IP country:', ipCountry)
-    const isChinaUser = ipCountry.toLowerCase() === 'cn'
+    const ipCountry = await this._getIpCountry()
+    logger.info('Detected IP country', { ipCountry })
+    const isChinaUser = ipCountry.toLowerCase() === 'cn'

     if (channel === UpgradeChannel.LATEST) {
       this.autoUpdater.channel = UpgradeChannel.LATEST
-      if (isChinaUser) {
-        this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION)
-        logger.info('Using production releases for CN user')
-      } else {
-        this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST)
-        logger.info('Using GitHub latest releases for test plan')
-      }
+      this.autoUpdater.setFeedURL(isChinaUser ? FeedUrl.PRODUCTION : FeedUrl.GITHUB_LATEST)
+      logger.info(isChinaUser ? 'Using production releases for CN user' : 'Using GitHub latest releases for non-CN user')
       return
     }

220-230: Production mode feed selection: simplify and fix double logging.

You set PRODUCTION, then overwrite with GITHUB_LATEST for non‑CN. Make it explicit and log once.

-    // Production mode
-    this.autoUpdater.channel = UpgradeChannel.LATEST
-    this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION)
-    logger.info('Using production feed URL')
-
-    logger.info('Detected IP country:', ipCountry)
-    if (ipCountry.toLowerCase() !== 'cn') {
-      this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST)
-      logger.info('Using GitHub releases for non-CN region')
-    }
+    // Production mode
+    this.autoUpdater.channel = UpgradeChannel.LATEST
+    if (isChinaUser) {
+      this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION)
+      logger.info('Using production feed URL for CN region')
+    } else {
+      this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST)
+      logger.info('Using GitHub releases for non-CN region')
+    }

76-115: Sorting by published_at may be NaN; fall back to created_at.

If published_at is null (drafty prereleases), getTime() is NaN and sort becomes unstable.

-      const release = matchingReleases.sort(
-        (a, b) =>
-          new Date(b.published_at || '').getTime() - new Date(a.published_at || '').getTime()
-      )[0]
+      const ts = (r: GithubReleaseInfo) =>
+        new Date(r.published_at || r.created_at).getTime()
+      const release = matchingReleases.sort((a, b) => ts(b) - ts(a))[0]

37-45: Logging style: use object-literal payloads; align with loggerService convention.

Several calls pass non‑object second args or string interpolation. Prefer logger.*('msg', { key }) consistently and consider centralizing on loggerService per project guidelines.

Do you want a sweep patch updating the touched lines to logger.*('...', { ... }) and switching to the shared logger service in main?

Also applies to: 47-50, 66-67, 98-101, 109-114, 177-183, 186-193, 201-209, 213-216, 223-229, 239-245, 282-289


256-270: Avoid unnecessary GitHub API when routing to CN.

You always query GitHub before deciding region. For CN, this adds latency/failure. Consider resolving IP country first and skipping _getPreReleaseVersionFromGithub when CN.

I can propose a small refactor to fetch ipCountry in checkForUpdates() and pass isChinaUser to _setFeedUrl() to short‑circuit GH calls.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c108ce and 118ba8f.

📒 Files selected for processing (3)
  • .github/workflows/sync-release-to-gitcode.yml (4 hunks)
  • packages/shared/config/constant.ts (1 hunks)
  • src/main/services/AppUpdater.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: 在组件/Hook 中避免硬编码尺寸和时长,优先使用 useTheme() 的 token(如 motionDurationMid、borderRadiusSM/MD 等)或集中定义的样式变量
定制 antd 组件样式时优先使用 styled-components(styled(Component) 包装),避免通过全局 SCSS 与全局 className 覆盖
项目使用 Zustand 结合 Immer 中间件与自定义中间件栈(持久化、DevTools、订阅选择器)进行状态管理

Files:

  • src/main/services/AppUpdater.ts
  • packages/shared/config/constant.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{tsx,ts}: Zustand 必须在组件/Hook 顶层使用 selector(useStore(selector));禁止在 useMemo/useEffect 内部调用 store Hook
避免使用返回对象的 useStore 选择器(如 useStore(s => ({ a: s.a, b: s.b }))),应使用单字段选择器或配合 shallow 比较器

Files:

  • src/main/services/AppUpdater.ts
  • packages/shared/config/constant.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: 统一使用 loggerService 记录日志,禁止使用 console
logger 使用示例:logger.error('Error in :', { error }); 第二个参数必须是对象字面量 {}

Files:

  • src/main/services/AppUpdater.ts
  • packages/shared/config/constant.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test (macos-latest, 20)
  • GitHub Check: test (windows-latest, 20)
  • GitHub Check: test (ubuntu-latest, 20)
🔇 Additional comments (2)
.github/workflows/sync-release-to-gitcode.yml (1)

5-5: Triggering on prereleases is good. Ensure idempotency.

This will fire on both prereleased and later published events; your existence checks should prevent duplicates. Looks good.

If you’ve seen duplicate runs still creating noise, consider adding a run-concurrency group keyed by tag to collapse redundant executions. Want a snippet?

packages/shared/config/constant.ts (1)

27-33: Switch updater feeds to HTTPS (critical — MITM risk)

HTTP update feeds allow MITM metadata/URL rewriting — change PRODUCTION/CN_BETA/CN_ALPHA to HTTPS. (owasp.org)

-  PRODUCTION = 'http://release.echoplayer.z2blog.com/api/releases',
+  PRODUCTION = 'https://release.echoplayer.z2blog.com/api/releases',
@@
-  CN_BETA = 'http://release.echoplayer.z2blog.com/api/beta/releases',
-  CN_ALPHA = 'http://release.echoplayer.z2blog.com/api/alpha/releases'
+  CN_BETA = 'https://release.echoplayer.z2blog.com/api/beta/releases',
+  CN_ALPHA = 'https://release.echoplayer.z2blog.com/api/alpha/releases'

If HTTPS isn’t available, hard‑pin SHA512 and enforce strict signature verification, or front these endpoints with a TLS‑terminating CDN (or adopt TUF-style signed metadata). (arxiv.org)

I couldn't reach the HTTPS endpoints during this check — confirm release.echoplayer.z2blog.com serves TLS or apply the mitigations above. ()

Comment on lines +65 to +93
# Handle release body - fetch from GitHub if not provided
if [ -z "${{ github.event.inputs.release_body }}" ]; then
echo "📄 No release description provided, fetching from GitHub API..."

release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")

if [ "$(echo "$release_response" | jq -r '.message // empty')" = "Not Found" ]; then
echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
github_release_body=$(echo "$release_response" | jq -r '.body // empty')
if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then
echo "⚠️ No description found in GitHub release, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
echo "✅ Successfully fetched release description from GitHub"
fi
fi

echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "$github_release_body" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "📝 Using provided release description"
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "${{ github.event.inputs.release_body }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick

Robust fallback for release_body; add HTTP code check and safer EOF delimiter.

Current logic assumes a successful 200. If rate‑limited or permissioned, jq parses an HTML/JSON error and we might emit an empty body. Also, the EOF delimiter could collide with content edge‑cases.

  • Check curl HTTP code and branch on non‑200.
  • Use a unique heredoc delimiter.

Apply:

-              release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-                "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")
+              release_response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
+                "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")
+              http_code="${release_response: -3}"
+              release_json="${release_response%???}"
-              if [ "$(echo "$release_response" | jq -r '.message // empty')" = "Not Found" ]; then
+              if [ "$http_code" != "200" ] || [ "$(echo "$release_json" | jq -r '.message // empty')" = "Not Found" ]; then
                 echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description"
                 github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
               else
-                github_release_body=$(echo "$release_response" | jq -r '.body // empty')
+                github_release_body=$(echo "$release_json" | jq -r '.body // empty')
                 if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then
                   echo "⚠️ No description found in GitHub release, using default description"
                   github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
                 else
                   echo "✅ Successfully fetched release description from GitHub"
                 fi
               fi
-              echo "release_body<<EOF" >> $GITHUB_OUTPUT
-              echo "$github_release_body" >> $GITHUB_OUTPUT
-              echo "EOF" >> $GITHUB_OUTPUT
+              delim="RELEASE_BODY_$(uuidgen)"
+              {
+                echo "release_body<<$delim"
+                echo "$github_release_body"
+                echo "$delim"
+              } >> "$GITHUB_OUTPUT"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Handle release body - fetch from GitHub if not provided
if [ -z "${{ github.event.inputs.release_body }}" ]; then
echo "📄 No release description provided, fetching from GitHub API..."
release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")
if [ "$(echo "$release_response" | jq -r '.message // empty')" = "Not Found" ]; then
echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
github_release_body=$(echo "$release_response" | jq -r '.body // empty')
if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then
echo "⚠️ No description found in GitHub release, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
echo "✅ Successfully fetched release description from GitHub"
fi
fi
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "$github_release_body" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "📝 Using provided release description"
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "${{ github.event.inputs.release_body }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
# Handle release body - fetch from GitHub if not provided
if [ -z "${{ github.event.inputs.release_body }}" ]; then
echo "📄 No release description provided, fetching from GitHub API..."
release_response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")
http_code="${release_response: -3}"
release_json="${release_response%???}"
if [ "$http_code" != "200" ] || [ "$(echo "$release_json" | jq -r '.message // empty')" = "Not Found" ]; then
echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
github_release_body=$(echo "$release_json" | jq -r '.body // empty')
if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then
echo "⚠️ No description found in GitHub release, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
echo "✅ Successfully fetched release description from GitHub"
fi
fi
delim="RELEASE_BODY_$(uuidgen)"
{
echo "release_body<<$delim"
echo "$github_release_body"
echo "$delim"
} >> "$GITHUB_OUTPUT"
else
echo "📝 Using provided release description"
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "${{ github.event.inputs.release_body }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
🤖 Prompt for AI Agents
.github/workflows/sync-release-to-gitcode.yml lines 65-93: the current
fetch-from-GitHub logic assumes a 200 response and uses a generic EOF which can
collide with content; update the curl call to capture both body and HTTP status
(e.g., curl -s -w "%{http_code}" ...) and parse/branch only when the status
equals 200 otherwise treat as not-found/error and set the default release_body;
also switch the GITHUB_OUTPUT heredoc delimiter to a unique token (e.g.,
RELEASE_BODY_EOF) to avoid collisions and ensure you only run jq on a successful
JSON response.

Comment on lines 196 to +216
if (testPlan && release) {
const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
if (preReleaseUrl) {
this.autoUpdater.setFeedURL(preReleaseUrl)
if (isChinaUser) {
// 为中国用户使用对应的预发布渠道
const chineseFeedUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
this.autoUpdater.setFeedURL(chineseFeedUrl)
this.autoUpdater.channel = channel
logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`)
return
}
logger.info(`Using Chinese pre-release URL: ${chineseFeedUrl} with channel: ${channel}`)
} else {
const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
if (preReleaseUrl) {
this.autoUpdater.setFeedURL(preReleaseUrl)
this.autoUpdater.channel = channel
logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`)
return
}

// if no prerelease url, use lowest prerelease version to avoid error
logger.warn('No prerelease URL found, falling back to lowest prerelease version')
this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
this.autoUpdater.channel = UpgradeChannel.LATEST
// if no prerelease url, use lowest prerelease version to avoid error
logger.warn('No prerelease URL found, falling back to lowest prerelease version')
this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
this.autoUpdater.channel = UpgradeChannel.LATEST
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Uncouple CN prerelease from GitHub availability; add proper fallback for non‑CN.

  • Always route CN test plans to CN_ALPHA/CN_BETA feeds regardless of GitHub.
  • For non‑CN, use GitHub prerelease when release is available; otherwise fall back to PRERELEASE_LOWEST.
-    if (testPlan && release) {
-      if (isChinaUser) {
-        // 为中国用户使用对应的预发布渠道
-        const chineseFeedUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
-        this.autoUpdater.setFeedURL(chineseFeedUrl)
-        this.autoUpdater.channel = channel
-        logger.info(`Using Chinese pre-release URL: ${chineseFeedUrl} with channel: ${channel}`)
-      } else {
-        const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
-        if (preReleaseUrl) {
-          this.autoUpdater.setFeedURL(preReleaseUrl)
-          this.autoUpdater.channel = channel
-          logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`)
-          return
-        }
-
-        // if no prerelease url, use lowest prerelease version to avoid error
-        logger.warn('No prerelease URL found, falling back to lowest prerelease version')
-        this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
-        this.autoUpdater.channel = UpgradeChannel.LATEST
-      }
-      return
-    }
+    if (testPlan) {
+      if (isChinaUser) {
+        const cnUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
+        this.autoUpdater.setFeedURL(cnUrl)
+        this.autoUpdater.channel = channel
+        logger.info('Using Chinese pre-release URL', { channel, url: cnUrl })
+        return
+      }
+      if (release) {
+        const ghUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
+        this.autoUpdater.setFeedURL(ghUrl)
+        this.autoUpdater.channel = channel
+        logger.info('Using GitHub pre-release URL', { channel, url: ghUrl })
+        return
+      }
+      logger.warn('No prerelease info available; falling back to lowest prerelease version')
+      this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
+      this.autoUpdater.channel = UpgradeChannel.LATEST
+      return
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (testPlan && release) {
const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
if (preReleaseUrl) {
this.autoUpdater.setFeedURL(preReleaseUrl)
if (isChinaUser) {
// 为中国用户使用对应的预发布渠道
const chineseFeedUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
this.autoUpdater.setFeedURL(chineseFeedUrl)
this.autoUpdater.channel = channel
logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`)
return
}
logger.info(`Using Chinese pre-release URL: ${chineseFeedUrl} with channel: ${channel}`)
} else {
const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
if (preReleaseUrl) {
this.autoUpdater.setFeedURL(preReleaseUrl)
this.autoUpdater.channel = channel
logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`)
return
}
// if no prerelease url, use lowest prerelease version to avoid error
logger.warn('No prerelease URL found, falling back to lowest prerelease version')
this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
this.autoUpdater.channel = UpgradeChannel.LATEST
// if no prerelease url, use lowest prerelease version to avoid error
logger.warn('No prerelease URL found, falling back to lowest prerelease version')
this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
this.autoUpdater.channel = UpgradeChannel.LATEST
}
if (testPlan) {
if (isChinaUser) {
const cnUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
this.autoUpdater.setFeedURL(cnUrl)
this.autoUpdater.channel = channel
logger.info('Using Chinese pre-release URL', { channel, url: cnUrl })
return
}
if (release) {
const ghUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
this.autoUpdater.setFeedURL(ghUrl)
this.autoUpdater.channel = channel
logger.info('Using GitHub pre-release URL', { channel, url: ghUrl })
return
}
logger.warn('No prerelease info available; falling back to lowest prerelease version')
this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
this.autoUpdater.channel = UpgradeChannel.LATEST
return
}
🤖 Prompt for AI Agents
In src/main/services/AppUpdater.ts around lines 196-216, the current logic ties
selecting the Chinese CN_ALPHA/CN_BETA feed to the presence of a GitHub
`release` and uses a redundant truthy check for the constructed `preReleaseUrl`;
change it so CN test plans always set the feed URL to CN_ALPHA or CN_BETA and
return immediately, and for non-China users check if `release` exists — if so
set the GitHub prerelease URL and return, otherwise log the warning and fall
back to FeedUrl.PRERELEASE_LOWEST with channel UpgradeChannel.LATEST. Ensure you
remove the unnecessary `if (preReleaseUrl)` truthy check and instead test `if
(release)` before using the GitHub URL.

@mkdir700 mkdir700 merged commit df42152 into alpha Sep 16, 2025
5 checks passed
@mkdir700 mkdir700 deleted the dev2alpha branch September 16, 2025 04:46
@coderabbitai coderabbitai bot mentioned this pull request Sep 16, 2025
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