Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
fix(desktop): authenticate GitHub release discovery during packaging
Leggett0477192e2e7b
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex 2a7fe57f..f57851f8 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -238,6 +238,7 @@ jobs:fiexit "$release_status"env:+ GH_TOKEN: ${{ github.token }}OPENCREATOR_DESKTOP_TARGET_PLATFORM: ${{ matrix.platform }}OPENCREATOR_DESKTOP_TARGET_ARCH: ${{ matrix.arch }}CSC_LINK: ${{ secrets.MACOS_CERTIFICATE }}@@ -250,6 +251,7 @@ jobs:if: matrix.platform == 'win32'run: pnpm desktop:distenv:+ GH_TOKEN: ${{ github.token }}OPENCREATOR_DESKTOP_TARGET_PLATFORM: ${{ matrix.platform }}OPENCREATOR_DESKTOP_TARGET_ARCH: ${{ matrix.arch }}- name: 验证实际打包应用diff --git a/apps/desktop/scripts/install-creator-runtime-dependencies.mjs b/apps/desktop/scripts/install-creator-runtime-dependencies.mjsindex 1f66543d..cf31c29d 100644--- a/apps/desktop/scripts/install-creator-runtime-dependencies.mjs+++ b/apps/desktop/scripts/install-creator-runtime-dependencies.mjs@@ -91,16 +91,27 @@ function readCachedYtDlpRelease() {function readReleaseText(url) {const args = [- '--fail', '--silent', '--show-error', '--location',+ '--fail-with-body', '--silent', '--show-error', '--location','--retry', '3', '--connect-timeout', '20', '--max-time', '60','--header', 'Cache-Control: no-cache'];+ let input;+ if (new URL(url).origin === 'https://api.github.com') {+ const token = process.env.GH_TOKEN?.trim() || process.env.GITHUB_TOKEN?.trim();+ if (token) {+ if (/[\r\n]/.test(token)) throw new Error('Invalid GitHub API token');+ // Keep credentials out of process arguments and command failure messages.+ args.push('--config', '-');+ input = `header = ${JSON.stringify(`Authorization: Bearer ${token}`)}\n`;+ }+ }if (proxy) args.push('--proxy', proxy);args.push(url);return execFileSync('curl', args, {cwd: rootDir,encoding: 'utf8',- stdio: ['ignore', 'pipe', 'inherit'],+ input,+ stdio: ['pipe', 'pipe', 'inherit'],maxBuffer: 4 * 1024 * 1024});}diff --git a/apps/desktop/test/creator-runtime-updates.test.mjs b/apps/desktop/test/creator-runtime-updates.test.mjsindex 35384d73..bd46ad71 100644--- a/apps/desktop/test/creator-runtime-updates.test.mjs+++ b/apps/desktop/test/creator-runtime-updates.test.mjs@@ -108,6 +108,8 @@ describe('Creator Runtime dependency updates', () => {vi.stubEnv('OPENCREATOR_DESKTOP_OFFLINE', '0');vi.stubEnv('OPENCREATOR_DOWNLOAD_PROXY', '');vi.stubEnv('OPENCREATOR_YT_DLP_PATH', '');+ vi.stubEnv('GH_TOKEN', '');+ vi.stubEnv('GITHUB_TOKEN', '');vi.spyOn(console, 'log').mockImplementation(() => undefined);run = vi.fn((command, args) => {expect(command).toBe('curl');@@ -139,6 +141,42 @@ describe('Creator Runtime dependency updates', () => {const install = () => import('../scripts/install-creator-runtime-dependencies.mjs');+ it.each([+ ['ghs_test_primary', 'ghs_test_fallback', 'ghs_test_primary'],+ ['', 'ghs_test_fallback', 'ghs_test_fallback']+ ])('authenticates GitHub API discovery without exposing credentials in curl arguments (%#)', async (ghToken, githubToken, expected) => {+ vi.stubEnv('GH_TOKEN', ghToken);+ vi.stubEnv('GITHUB_TOKEN', githubToken);+ await install();+ const [, args, options] = run.mock.calls[0];+ expect(args.at(-1)).toBe(latestUrl);+ expect(args).toContain('--fail-with-body');+ expect(args).toEqual(expect.arrayContaining(['--config', '-']));+ expect(args.join(' ')).not.toContain(expected);+ expect(options.input).toBe(`header = "Authorization: Bearer ${expected}"\n`);+ expect(options.stdio[0]).toBe('pipe');+ for (const [, downloadArgs, downloadOptions] of run.mock.calls.slice(1)) {+ expect(downloadArgs.join(' ')).not.toContain(expected);+ expect(downloadOptions.input).toBeUndefined();+ }+ });++ it('does not send the API token to a release checksum download', async () => {+ vi.stubEnv('GH_TOKEN', 'ghs_test_api_only');+ const release = metadata();+ delete release.assets[0].digest;+ run.mockImplementationOnce(() => JSON.stringify(release))+ .mockImplementationOnce((command, args, options) => {+ expect(command).toBe('curl');+ expect(args.at(-1)).toBe(`${repository}/releases/download/${newVersion}/SHA2-256SUMS`);+ expect(args.join(' ')).not.toContain('ghs_test_api_only');+ expect(options.input).toBeUndefined();+ return `${asset().sha256} yt-dlp\n`;+ });+ await install();+ expect(readFileSync(join(root, 'yt-dlp'), 'utf8')).toBe(contents(newVersion));+ });+it('updates a populated cache and records the verified release for each invocation', async () => {for (const version of [newVersion, '2026.10.11.233141']) {currentVersion = version;diff --git a/apps/desktop/test/release-workflow.test.mjs b/apps/desktop/test/release-workflow.test.mjsindex 1c06403a..ec24e87c 100644--- a/apps/desktop/test/release-workflow.test.mjs+++ b/apps/desktop/test/release-workflow.test.mjs@@ -71,6 +71,16 @@ describe('Desktop release workflow', () => {expect(releaseWorkflow).not.toContain('WINDOWS-UNSIGNED.txt');});+ it('provides GitHub API authentication to both desktop packaging steps', () => {+ const macStep = releaseWorkflow.split('name: 生成 macOS 正式签名安装包')[1]+ .split('name: 生成 Windows 未签名安装包')[0];+ const windowsStep = releaseWorkflow.split('name: 生成 Windows 未签名安装包')[1]+ .split('name: 验证实际打包应用')[0];+ for (const step of [macStep, windowsStep]) {+ expect(step).toContain('GH_TOKEN: ${{ github.token }}');+ }+ });+it('reuses the successful master CI instead of repeating all tests', () => {expect(releaseWorkflow).toContain('name: 校验同一提交的 CI 已通过');expect(releaseWorkflow).toContain('--workflow ci.yml');