Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(ci): generate nightly changelog without duplicate drafts (#994)

Mao Mrdd63cebb2acf
diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml
index fbfabd29..a36e6711 100644
--- a/.github/workflows/release-nightly.yml
+++ b/.github/workflows/release-nightly.yml
@@ -285,7 +285,7 @@ jobs:
day="${NIGHTLY_TAG#nightly-}"
title="Nightly ${day:0:4}-${day:4:2}-${day:6:2} (${NIGHTLY_SHA:0:7})"
- args=(--draft --prerelease --to "$NIGHTLY_TAG" --name "$title")
+ args=(--prerelease --to "$NIGHTLY_TAG" --name "$title" --output "$RUNNER_TEMP/nightly_changelog.md")
if [ -n "$from" ]; then
args+=(--from "$from")
echo "变更日志范围:$from..$NIGHTLY_TAG"
@@ -293,8 +293,7 @@ jobs:
echo '::warning::找不到变更日志起点,按全部历史生成'
fi
- pnpm exec changelogithub "${args[@]}" || \
- echo '::warning::changelogithub 生成变更日志失败,Release 只保留产物与提示'
+ pnpm exec changelogithub "${args[@]}"
- name: Upload assets to the draft release
run: |
@@ -320,15 +319,10 @@ jobs:
- name: Compose release notes
run: |
set -euo pipefail
- body="$(gh release view "$NIGHTLY_TAG" --json body -q .body)"
-
{
- # 说明固定排在最前:变更日志步骤会重写正文,这里按需补回。
- if [ "$(printf '%s\n' "$body" | head -1)" != "$(printf '%s\n' "$NIGHTLY_DESCRIPTION" | head -1)" ]; then
- printf '%s\n' "$NIGHTLY_DESCRIPTION"
- echo
- fi
- printf '%s\n' "$body"
+ printf '%s\n' "$NIGHTLY_DESCRIPTION"
+ echo
+ cat "$RUNNER_TEMP/nightly_changelog.md"
echo
# 与正式版(release.yml 的 Append Artifacts section)保持同一份产物清单
echo '### 📦 Artifacts'
diff --git a/test/release-nightly.test.ts b/test/release-nightly.test.ts
index 4a6effd2..4004cfe4 100644
--- a/test/release-nightly.test.ts
+++ b/test/release-nightly.test.ts
@@ -75,6 +75,52 @@ async function pruneAssets(runnerTemp: string, tag: string, releases: Map<string
return github
}
+describe('nightly release notes', () => {
+ it.each([false, true])('composes fresh notes on repeated publication with changelog missing: %s', (missing) => {
+ const directory = mkdtempSync(path.join(tmpdir(), 'nightly-notes-'))
+ temporaryRepos.push(directory)
+ if (!missing)
+ writeFileSync(path.join(directory, 'nightly_changelog.md'), '### Bug Fixes\n- Fixed nightly publishing\n')
+ writeFileSync(path.join(directory, 'nightly_notes.md'), 'stale notes\n### Artifacts\n')
+ const body = stepBody(readSource(WORKFLOW), 'Compose release notes')
+ const script = body.split('run: |\n')[1]!.replace(/^ {10}/gm, '')
+ const bash = process.platform === 'win32' ? 'C:/Program Files/Git/bin/bash.exe' : 'bash'
+ const execute = () => execFileSync(bash, ['-c', `gh() { printf '%s\\n' "$*" > published.txt; }\n${script}`], {
+ cwd: directory,
+ env: { ...process.env, RUNNER_TEMP: directory.replace(/\\/g, '/'), NIGHTLY_TAG: 'nightly-20261009', NIGHTLY_SHA: 'abc1234', NIGHTLY_DESCRIPTION: 'Nightly warning' },
+ encoding: 'utf8',
+ timeout: 5000,
+ })
+ if (missing) {
+ expect(execute).toThrow()
+ expect(readdirSync(directory)).not.toContain('published.txt')
+ return
+ }
+ execute()
+ const notes = readFileSync(path.join(directory, 'nightly_notes.md'), 'utf8')
+ expect(notes).toContain('Nightly warning\n\n### Bug Fixes\n- Fixed nightly publishing\n')
+ expect(notes).not.toContain('stale notes')
+ expect(notes.match(/### 📦 Artifacts/g)).toHaveLength(1)
+ expect(notes).toContain('<!-- nightly-sha:abc1234 -->')
+ expect(readFileSync(path.join(directory, 'published.txt'), 'utf8')).toContain('--notes-file nightly_notes.md --draft=false --prerelease --latest=false')
+ })
+
+ it('generates changelog locally without creating a second release', () => {
+ const body = stepBody(readSource(WORKFLOW), 'Generate changelog')
+ expect(body).toContain('--output "$RUNNER_TEMP/nightly_changelog.md"')
+ expect(body).not.toContain('--draft')
+ expect(body).not.toMatch(/pnpm exec changelogithub[^\n]*\|\|/)
+ })
+
+ it('publishes the generated changelog instead of rereading an ambiguous release tag', () => {
+ const body = stepBody(readSource(WORKFLOW), 'Compose release notes')
+ expect(body).toContain('cat "$RUNNER_TEMP/nightly_changelog.md"')
+ expect(body).toContain('printf \'%s\\n\' "$NIGHTLY_DESCRIPTION"')
+ expect(body).not.toContain('gh release view')
+ expect(body).toContain('--notes-file nightly_notes.md --draft=false --prerelease --latest=false')
+ })
+})
+
describe('nightly release assets', () => {
it.each([
{ product: 'DSH Tauri', version: '0.22.4' },