【教程记录】使用GitHub Action 自动构建 RustDesk 客户端
<i class="pstatus"> 本帖最后由 rainerosion 于 2025-3-4 10:36 编辑 </i><br /><br />
<strong>前言</strong><br />
<br />
前几天有人问我新版本的Rustdesk如何自己构建,于是我写了这篇文章。如何利用Github Actions 实现自动构建内置你服务器和key的Rustdesk客户端。<br />
<br />
<strong>1. 准备工作</strong><br />
<br />
在开始之前,请确保你已经安装了 Git,并且拥有一个 GitHub 账户。建议你对 Git 的基本使用有一定了解,以便顺利完成后续操作。<br />
<br />
<strong>2. Fork Rustdesk仓库</strong><br />
<br />
1. rustdesk/hbb_common<br />
2. rustdesk/rustdesk<br />
<br />
<strong>2.1 拉取 Fork 后的代码</strong><br />
<br /><div class="quote"><blockquote>请注意,替换仓库地址为你fork后的仓库地址,而不是直接复制我下面的命令</blockquote></div><div class="blockcode"><div id="code_mQw"><ol><li><br /><li># 可选:如果需要使用代理<br /><li># git config --global http.proxy http://127.0.0.1:10808<br /><li># git config --global https.proxy http://127.0.0.1:10808<br /><li># 拉取仓库代码到本地 请替换为你fork后的仓库地址<br /><li>git clone https://github.com/irains/hbb_common.git<br /><li>git clone https://github.com/irains/rustdesk.git<br /><li></ol></div><em onclick="copycode($('code_mQw'));">复制代码</em></div><br />
<br />
<img id="aimg_KVYf5" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303165759904_d4d24b69d511a.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>3. 修改 hbb_common代码</strong><br />
<br />
打开 `hbb_common` 仓库下的 `src/config.rs`文件,修改 <font color="red">101-102 行</font> 的默认服务器和密钥为你自己的服务器和密钥。<br />
<br />
<img id="aimg_KCPHs" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303170450035_73f9b792d0a41.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>3.1 推送修改后的代码</strong><br />
<br /><div class="blockcode"><div id="code_thn"><ol><li><br /><li># 将修改的代码添加到暂存区<br /><li>git add .<br /><li># 将代码提交到本地仓库<br /><li>git commit -m "修改默认的服务器和 key"<br /><li># 将本地仓库代码推送到远程仓库 如果你没有登录过GitHub会要求你登录github<br /><li>git push<br /><li></ol></div><em onclick="copycode($('code_thn'));">复制代码</em></div><br />
<br />
<img id="aimg_pK2ie" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303171409855_a8fdaa7314c8d.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>3.2 查看最新提交的 commit ID</strong><br />
<br /><div class="blockcode"><div id="code_ULY"><ol><li><br /><li>git log --oneline<br /><li></ol></div><em onclick="copycode($('code_ULY'));">复制代码</em></div><br />
<div class="quote"><blockquote>我这里提交后的commit id是b8d80ca,可用于后续验证rustdesk服务器和key是否修改成功</blockquote></div><br />
<br />
<img id="aimg_Y6dOZ" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303172347046_e85909b9e0f0c.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>4. 修改 rustdesk 仓库代码</strong><br />
<br />
我们切换到克隆下来的rustdesk代码目录下,按照下面的方式修改子模块地址并更新。<br />
<br />
<strong>4.1 更新 `.gitmodules`</strong><br />
<br />
打开并编辑 `.gitmodules` 文件,将 `url` 替换为你Fork后的 `hbb_common` 仓库地址。<br />
<br /><div class="quote"><blockquote>比如我fork后的仓库地址是`https://github.com/irains/hbb_common`则将 `https://github.com/rustdesk/hbb_common`地址换为前面这个地址即可,记住是hbb_common的地址,而不是rustdesk仓库的地址</blockquote></div><br />
<br />
<img id="aimg_y18HB" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303172942511_1740134ee8a88.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>4.2 更新子模块</strong><br />
<br />
将上面修改好的代码保存,执行下面的命令更新子模块到最新的commit id<br />
<br /><div class="blockcode"><div id="code_vKn"><ol><li><br /><li>git submodule sync<br /><li>git submodule update --remote<br /><li></ol></div><em onclick="copycode($('code_vKn'));">复制代码</em></div><br />
<br />
<img id="aimg_ITsgp" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303173801265_ad7b30677b7e1.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>4.3 提交并推送代码</strong><br />
<br /><div class="blockcode"><div id="code_ps4"><ol><li><br /><li>git add .<br /><li>git commit -m "修改子模块仓库地址"<br /><li>git push<br /><li></ol></div><em onclick="copycode($('code_ps4'));">复制代码</em></div><br />
<br />
<img id="aimg_fWEDw" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303173951608_5d264728be44a.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>4.4 确认 Commit ID 更新</strong><br />
<br />
代码推送完毕后,进入你Fork 后的 `rustdesk` 仓库的 `libs` 目录下,查看 `hbb_common` 后面的 commit id,确保它是3.2提到的`b8d80ca`(这个值每个人的是不同的),否则请回到上面的步骤重新检查是否遗漏了某个操作。<br />
<br />
<img id="aimg_p2x1A" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303174211089_7ab6b229e8b57.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<img id="aimg_ta44J" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303174342359_e057661c7974c.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>5. 触发 GitHub Action 构建</strong><br />
<br />
<strong>5.1 创建 Tag</strong><br />
<br />
在本地 `rustdesk` 仓库中创建一个新 tag,例如 `1.3.9`,请使用 <font color="red">固定格式</font> (如 `1.3.9` 或 `v1.3.9`),以便于自动匹配构建规则。<br />
<br /><div class="blockcode"><div id="code_yu9"><ol><li><br /><li>git tag -a 1.3.9 -m "修改内置服务器和 key"<br /><li></ol></div><em onclick="copycode($('code_yu9'));">复制代码</em></div><br />
<br />
<img id="aimg_aZwe8" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303175213093_c7bcbaeaff911.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>5.2 触发 GitHub Actions 构建</strong><br />
<br />
在 `rustdesk` 仓库中,进入 `Actions` 页面,点击下面图中的按钮启用自动构建。启用后回到本地rustdesk代码中使用下面的命令将tag推送到Github后将自动开始构建。<br />
<br /><div class="blockcode"><div id="code_nh2"><ol><li><br /><li>git push --tags<br /><li></ol></div><em onclick="copycode($('code_nh2'));">复制代码</em></div><br />
<br />
<img id="aimg_HR3Zs" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303174711633_825769b199fdd.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<strong>5.3 下载构建好的客户端</strong><br />
<br />
Tag推送完毕后会出现下面的构建进度。<br />
<br />
<img id="aimg_G5ZuR" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303175425229_f4b66330f19bc.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
等待 Action 执行完成后(时间比较长,一个半小时左右才能全部构建完成),进入 `Releases` 页面,即可下载构建好的客户端并使用。<br />
<br />
<img id="aimg_bl8fs" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303175612473_de1364ca71505.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
<br />
<img id="aimg_R8X68" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://pic2.ziyuan.wang/user/rainerosion/2025/03/image-20250303185727688_63e8e7567c2c3.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" /><br />
支持技术贴,是不是可以直接在网页操作 <div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16261316&ptid=1393190" target="_blank"><font color="#999999">空谷幽兰 发表于 2025-3-4 10:40</font></a></font><br />
支持技术贴,是不是可以直接在网页操作</blockquote></div><br />
submodule的更新可能不行。 厉害了,可惜还是太复杂,需要操作GIT,<br />
<br />
我觉得更简单的是FORK后直接在网页或者什么dev里修改,但不知道效果有什么不同。<br />
<br />
另外,我这边修改后,别人更新了我这边怎么同步更新,还是不太懂。 实际测试 hbb_common的url更新不起作用,还是以前的commit id,不知道怎么回事? <div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16261442&ptid=1393190" target="_blank"><font color="#999999">niudun1643 发表于 2025-3-4 11:22</font></a></font><br />
实际测试 hbb_common的url更新不起作用,还是以前的commit id,不知道怎么回事? ...</blockquote></div><br />
<br />
教程都是我一步一步操作过的肯定没问题,是不是遗漏了哪一步。<br />
hbb_common代码push上去了吗<br />
然后改好.gitsubmodule里面的hbb_common地址以后执行下面的命令,还要提交rustdesk代码那个commit id指向才会变<br />
git submodule sync<br />
git submodule update --remote <div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16261525&ptid=1393190" target="_blank"><font color="#999999">rainerosion 发表于 2025-3-4 11:47</font></a></font><br />
教程都是我一步一步操作过的肯定没问题,是不是遗漏了哪一步。<br />
hbb_common代码push上去了吗<br />
然后改好.git ...</blockquote></div><br />
都试过了,还是不行,不知道是为什么,我现在发现hbb_common中的src下面的config中的中继服务器的地址和一个key竟然是一个别人的地址和key,绝对不是我的,也不是官方的,真实神奇。 <div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16261626&ptid=1393190" target="_blank"><font color="#999999">niudun1643 发表于 2025-3-4 12:43</font></a></font><br />
都试过了,还是不行,不知道是为什么,我现在发现hbb_common中的src下面的config中的中继服务器的地址和 ...</blockquote></div><br />
你不会搞错成我上面的地址了吧。。。。 <div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16261644&ptid=1393190" target="_blank"><font color="#999999">rainerosion 发表于 2025-3-4 12:49</font></a></font><br />
你不会搞错成我上面的地址了吧。。。。</blockquote></div><br />
有可能,但是还是不知道为什么,会搞成你的地址,你是19小时以前创建过吗? <div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16261653&ptid=1393190" target="_blank"><font color="#999999">niudun1643 发表于 2025-3-4 12:55</font></a></font><br />
有可能,但是还是不知道为什么,会搞成你的地址,你是19小时以前创建过吗? ...</blockquote></div><br />
我再试一次试试1111
页:
[1]
2