fix: zip absolute path, publish failure comment, pass publish_status
- pr-publish-release.ts: Use resolve() for releaseDir to get absolute path;
zip command runs with cwd=artifactDir so relative path was resolving wrong
- build-pr.yml: Expose steps.publish.outcome as publish_status job output;
pass PUBLISH_STATUS env to update-comment-result job
- pr-build-result.ts: Read PUBLISH_STATUS, pass publishFailed to comment
- comment.ts: Show '⚠️ Release 发布失败' section in PR comment when
publish failed but installInfo is absent
This commit is contained in:
4 files changed
+21
-4
No files matched your search
@@ -117,7 +117,8 @@ export function generateResultComment (
|
|||||||
runId: string,
|
runId: string,
|
||||||
repository: string,
|
repository: string,
|
||||||
version?: string,
|
version?: string,
|
||||||
installInfo?: InstallInfo
|
installInfo?: InstallInfo,
|
||||||
|
publishFailed?: boolean
|
||||||
): string {
|
): string {
|
||||||
const runUrl = `https://github.com/${repository}/actions/runs/${runId}`;
|
const runUrl = `https://github.com/${repository}/actions/runs/${runId}`;
|
||||||
const shortSha = formatSha(prSha);
|
const shortSha = formatSha(prSha);
|
||||||
@@ -195,6 +196,16 @@ export function generateResultComment (
|
|||||||
`> 📦 [查看 Release 页面](${installInfo.releaseUrl})`,
|
`> 📦 [查看 Release 页面](${installInfo.releaseUrl})`,
|
||||||
'> ⚠️ 此为 PR 测试版本,约 24 小时后会被自动清理。'
|
'> ⚠️ 此为 PR 测试版本,约 24 小时后会被自动清理。'
|
||||||
);
|
);
|
||||||
|
} else if (publishFailed) {
|
||||||
|
lines.push(
|
||||||
|
'',
|
||||||
|
'---',
|
||||||
|
'',
|
||||||
|
'## ⚠️ Release 发布失败',
|
||||||
|
'',
|
||||||
|
'> ❌ PR Release 发布过程中出现错误,无法提供快速安装命令。',
|
||||||
|
`> 🔗 [查看构建日志](${runUrl}) 了解详情。`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加错误详情
|
// 添加错误详情
|
||||||
|
|||||||
@@ -51,12 +51,16 @@ async function main (): Promise<void> {
|
|||||||
// PR Release 信息(由 publish-pr-release job 传入)
|
// PR Release 信息(由 publish-pr-release job 传入)
|
||||||
const installUrl = getEnv('INSTALL_URL');
|
const installUrl = getEnv('INSTALL_URL');
|
||||||
const releaseUrl = getEnv('RELEASE_URL');
|
const releaseUrl = getEnv('RELEASE_URL');
|
||||||
|
const publishStatus = getEnv('PUBLISH_STATUS'); // 'success' | 'failure' | 'skipped' | ''
|
||||||
const installInfo: InstallInfo | undefined =
|
const installInfo: InstallInfo | undefined =
|
||||||
installUrl && releaseUrl ? { installUrl, releaseUrl } : undefined;
|
installUrl && releaseUrl ? { installUrl, releaseUrl } : undefined;
|
||||||
|
const publishFailed = publishStatus === 'failure';
|
||||||
|
|
||||||
if (installInfo) {
|
if (installInfo) {
|
||||||
console.log(`Install URL: ${installUrl}`);
|
console.log(`Install URL: ${installUrl}`);
|
||||||
console.log(`Release URL: ${releaseUrl}\n`);
|
console.log(`Release URL: ${releaseUrl}\n`);
|
||||||
|
} else if (publishFailed) {
|
||||||
|
console.log('Publish status: FAILED\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
const github = new GitHubAPI(token);
|
const github = new GitHubAPI(token);
|
||||||
@@ -92,7 +96,7 @@ async function main (): Promise<void> {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const comment = generateResultComment(targets, prSha, runId, repository, version, installInfo);
|
const comment = generateResultComment(targets, prSha, runId, repository, version, installInfo, publishFailed);
|
||||||
|
|
||||||
await github.createOrUpdateComment(owner, repo, prNumber, comment, COMMENT_MARKER);
|
await github.createOrUpdateComment(owner, repo, prNumber, comment, COMMENT_MARKER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
import { execSync } from 'node:child_process';
|
import { execSync } from 'node:child_process';
|
||||||
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
|
||||||
import { join, basename } from 'node:path';
|
import { join, basename, resolve } from 'node:path';
|
||||||
import { GitHubAPI, getEnv, setOutput } from './lib/github.ts';
|
import { GitHubAPI, getEnv, setOutput } from './lib/github.ts';
|
||||||
|
|
||||||
interface AssetEntry {
|
interface AssetEntry {
|
||||||
@@ -52,7 +52,7 @@ async function main (): Promise<void> {
|
|||||||
console.log(` SHA: ${shortSha}\n`);
|
console.log(` SHA: ${shortSha}\n`);
|
||||||
|
|
||||||
const github = new GitHubAPI(token);
|
const github = new GitHubAPI(token);
|
||||||
const releaseDir = './release-assets';
|
const releaseDir = resolve('./release-assets'); // 使用绝对路径,避免 zip cwd 切换后相对路径解析错误
|
||||||
mkdirSync(releaseDir, { recursive: true });
|
mkdirSync(releaseDir, { recursive: true });
|
||||||
|
|
||||||
// ---- 打包构建产物 ----
|
// ---- 打包构建产物 ----
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ jobs:
|
|||||||
# PR Release 信息(用于在评论中显示安装命令)
|
# PR Release 信息(用于在评论中显示安装命令)
|
||||||
INSTALL_URL: ${{ needs.publish-pr-release.outputs.install_url || '' }}
|
INSTALL_URL: ${{ needs.publish-pr-release.outputs.install_url || '' }}
|
||||||
RELEASE_URL: ${{ needs.publish-pr-release.outputs.release_url || '' }}
|
RELEASE_URL: ${{ needs.publish-pr-release.outputs.release_url || '' }}
|
||||||
|
PUBLISH_STATUS: ${{ needs.publish-pr-release.outputs.publish_status || '' }}
|
||||||
run: node --experimental-strip-types .github/scripts/pr-build-result.ts
|
run: node --experimental-strip-types .github/scripts/pr-build-result.ts
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -321,6 +322,7 @@ jobs:
|
|||||||
release_url: ${{ steps.publish.outputs.release_url }}
|
release_url: ${{ steps.publish.outputs.release_url }}
|
||||||
release_tag: ${{ steps.publish.outputs.release_tag }}
|
release_tag: ${{ steps.publish.outputs.release_tag }}
|
||||||
install_url: ${{ steps.publish.outputs.install_url }}
|
install_url: ${{ steps.publish.outputs.install_url }}
|
||||||
|
publish_status: ${{ steps.publish.outcome }} # 'success' | 'failure' | 'skipped'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout scripts
|
- name: Checkout scripts
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
|
|||||||
Reference in new issue
Block a user