公司动态

幽冥大陆(155)github打包任务和发布IDE —东方仙盟

📅 2026/8/7 17:27:21
幽冥大陆(155)github打包任务和发布IDE —东方仙盟
queryBuildWorkflow查询build-apk.yml打包流水线运行记录自动标记构建是否报错createReleaseTag打包完成后一键创建 Release 发布绑定对应打包 commit上传描述、版本标签 完全沿用原文fetch、统一返回code/msg/data结构兼容 ACE 编辑器、仙盟跨域破劫逻辑。完整扩展 JS 代码直接追加到原有 GitHubXianMeng 类内javascript运行// 接上文 class GitHubXianMeng 内部原有lanJiShu、tengXieFa之后新增 /** * 【打包观天术】查询build-apk.yml自动化打包流水线运行记录识别打包报错 * param {string} workflowFile 流水线yml文件名 默认build-apk.yml * param {number} limit 查询最近多少条打包记录 默认3 * returns {PromiseObject} 打包运行列表、状态、是否失败标记 */ async queryBuildWorkflow(workflowFile build-apk.yml, limit 3) { try { // 接口指定workflow的运行记录 const apiUrl ${this.apiBase}/actions/workflows/${encodeURIComponent(workflowFile)}/runs?per_page${limit}; const res await fetch(apiUrl, { method: GET, headers: this.headers, mode: cors }); if (!res.ok) throw new Error(流水线查询劫云阻拦状态码${res.status}); const rawData await res.json(); const runList rawData.workflow_runs || []; // 格式化打包记录增加失败标记 const buildRecords runList.map(item { const isFail [failure, timed_out].includes(item.conclusion); return { runId: item.id, buildUrl: item.html_url, status: item.status, // queued排队/in_progress构建中/completed完成 result: item.conclusion, // success成功/failure失败/timed_out超时/cancelled取消 isBuildError: isFail, createTime: item.created_at, commitSha: item.head_sha, // 打包对应代码提交哈希用于后续发Release branch: item.head_branch }; }); return { code: 200, msg: 打包流水线记录查询成功, data: buildRecords }; } catch (err) { return { code: -1, msg: 打包观天术失败${err.message}请开启跨域破劫符, data: [] }; } } /** * 【道印发布术】打包完成后创建GitHub Release版本发布绑定打包commit * param {string} tagName 版本标签 v1.2.0 * param {string} title 发布标题 * param {string} desc 发布详情支持markdown * param {string} targetSha 打包流水线返回的commitSha必须传入绑定本次打包代码 * param {boolean} isDraft 是否草稿 true草稿不对外可见 false正式发布 * param {boolean} isPre 是否预发布版本 * returns {PromiseObject} Release发布结果 */ async createReleaseTag(tagName, title, desc, targetSha, isDraft false, isPre false) { if (!tagName || !targetSha) { return { code: -2, msg: 版本标签tagName、打包commitSha不能为空, data: null }; } try { const releaseApi ${this.apiBase}/releases; const postBody JSON.stringify({ tag_name: tagName, name: title, body: desc, target_commitish: targetSha, // 绑定打包流水线对应的代码提交 draft: isDraft, prerelease: isPre }); const res await fetch(releaseApi, { method: POST, headers: this.headers, mode: cors, body: postBody }); const result await res.json(); if (!res.ok) throw new Error(result.message || Release发布接口返回异常); return { code: 200, msg: 版本${tagName}发布成功Release地址${result.html_url}, data: result }; } catch (err) { return { code: -1, msg: 道印发布术失败${err.message}, data: null }; } }仙盟完整调用演练前端 IDE 页面使用示例javascript运行// 1. 初始化仙盟GitHub实例 const xianMeng new GitHubXianMeng(你的PAT通行令牌); // 2. 第一步查询最近3次APK打包流水线任务 xianMeng.queryBuildWorkflow(build-apk.yml, 3).then(async buildRes { console.log(打包任务列表, buildRes); if (buildRes.code ! 200) return alert(buildRes.msg); const buildList buildRes.data; // 筛选最近一次成功打包记录 const successBuild buildList.find(item item.result success); if (!successBuild) return alert(暂无成功的打包记录无法发布Release); // 3. 第二步基于成功打包的commit创建正式Release发布 const releaseRes await xianMeng.createReleaseTag( v2.1.0, // 版本道印标签 幽冥大陆自动化打包v2.1正式版, // 发布标题 ## 更新日志 1. 修复打包编译报错问题 2. 优化APK体积 3. 适配仙盟创梦IDE前端对接 打包流水线ID${successBuild.runId}, // 发布详情 successBuild.commitSha, // 绑定本次打包代码哈希 false, // 非草稿 false // 非预发布 ); console.log(发布结果, releaseRes); if (releaseRes.code 200) { alert(版本发布完成访问地址${releaseRes.data.html_url}); } else { alert(发布失败 releaseRes.msg); } });配套 PHP 后端中转代理解决浏览器跨域劫云对应你之前 PHP 封装类如果你不想前端直接暴露 PAT、不想装 CORS 插件使用之前未来之窗_FASG_星蕴隐道_开发_github类做中转接口前端请求 PHP由 PHP 携带令牌调用 GitHubphp运行?php // api-github-build.php 打包发布中转接口 require_once 你的GitHub封装类文件.php; $token 你的仓库PAT; $github new 未来之窗_FASG_星蕴隐道_开发_github($token); $act $_GET[act] ?? ; header(Content-Type:application/json;charsetutf-8); // 查询打包流水线 if($act getBuild){ $yml $_GET[yml] ?? build-apk.yml; $limit intval($_GET[limit] ?? 3); $ret $github-listWorkflowRuns($yml, $limit); echo json_encode($ret,JSON_UNESCAPED_UNICODE); exit; } // 创建Release发布 if($act createRelease){ $input json_decode(file_get_contents(php://input),true); $tag $input[tag] ?? ; $title $input[title] ?? ; $desc $input[desc] ?? ; $sha $input[sha] ?? ; // 调用新增listReleases基础上扩展createRelease方法如需我补全PHP发布Release函数 echo json_encode([code-1,messagePHP发布Release函数可按需扩展],JSON_UNESCAPED_UNICODE); exit; } echo json_encode([code-2,message无效操作act],JSON_UNESCAPED_UNICODE); ?心法功能说明打包观天术queryBuildWorkflow自动拉取build-apk.yml所有打包运行记录 内置isBuildError布尔字段前端直接判断是否编译失败 返回打包对应的commitSha作为 Release 发布绑定依据道印发布术createReleaseTag强制绑定打包流水线产出的 commit 哈希确保发布包对应本次打包代码 支持草稿 / 预发布 / 正式三种发布模式 body 支持 Markdown 格式可写入打包日志、更新内容人人皆为创造者共创方能共成长每个人都是使用者也是创造者是数字世界的消费者更是价值的生产者与分享者。在智能时代的浪潮里单打独斗的发展模式早已落幕唯有开放连接、创意共创、利益共享才能让个体价值汇聚成生态合力让技术与创意双向奔赴实现平台与伙伴的快速成长、共赢致远。原创永久分成共赴星辰大海原创创意共创、永久收益分成是东方仙盟始终坚守的核心理念。我们坚信每一份原创智慧都值得被尊重与回馈以永久分成锚定共创初心让创意者长期享有价值红利携手万千伙伴向着科技星辰大海笃定前行拥抱硅基 生命与数字智能交融的未来共筑跨越时代的数字文明共同体。东方仙盟拥抱知识开源共筑数字新生态在全球化与数字化浪潮中东方仙盟始终秉持开放协作、知识共享的理念积极拥抱开源技术与开放标准。我们相信唯有打破技术壁垒、汇聚全球智慧才能真正推动行业的可持续发展。开源赋能中小商户通过将前端异常检测、跨系统数据互联等核心能力开源化东方仙盟为全球中小商户提供了低成本、高可靠的技术解决方案让更多商家能够平等享受数字转型的红利。共建行业标准我们积极参与国际技术社区与全球开发者、合作伙伴共同制定开放协议 与技术规范推动跨境零售、文旅、餐饮等多业态的系统互联互通构建更加公平、高效的数字生态。知识普惠共促发展通过开源社区 、技术文档与培训体系东方仙盟致力于将前沿技术转化为可落地的行业实践赋能全球合作伙伴共同培育创新人才推动数字经济 的普惠式增长阿雪技术观在科技发展浪潮中我们不妨积极投身技术共享。不满足于做受益者更要主动担当贡献者 。无论是分享代码、撰写技术博客还是参与开源项目 维护改进每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地我们携手在此探索硅基 生命为科技进步添砖加瓦。Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Dont just be the one reaping all the benefits; step up and be a contributor too. Whether youre tossing out your code snippets , hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. Were gonna team up and explore the whole silicon - based life thing, and in the process, well be fueling the growth of technology