Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): 跨平台自动构建流水线 #6

Merged
merged 9 commits into from
May 14, 2024
Merged

feat(ci): 跨平台自动构建流水线 #6

merged 9 commits into from
May 14, 2024

Conversation

Candinya
Copy link
Contributor

@Candinya Candinya commented May 13, 2024

改进

  1. 改进了原有的 CI 流程,优化了构建逻辑(不再需要重复安装 msbuild 环境及手动提取 runtime 目录了)
  2. 新增了 macOS 和 Linux 平台下的流水线逻辑(使用默认平台配置,如果有其他平台需求可以在对应 job 的 runtime 里添加)

存在的问题

  1. macOS 环境下没有打包成一个 App ,所以不方便使用。
  2. macOS 和 Linux 环境下构建的结果无法启动运行,报缺 winmm 相关的动态链接库,不确定是 NAudio 的跨平台兼容问题还是 TuneLab.csproj 里提到的 TFM 问题(手上的 mac 试了试修改 TargetFramework , dotnet SDK 默认使用的脚本路径不是 Xcode 的应用路径所以报找不到脚本的错误,不确定应该怎么调整并且不想在 mac 上装 VS 就没有深入研究下去),因此这两个平台只会在一般的流水线里构建出来,但不会在 tag 发布时候引入(什么时候问题解决了就可以删掉被注释掉的那一行来上传这两个平台的构建结果了)。
  3. 为了避免下载 Artifact 的时候被 GitHub 二次压缩,在 Windows 的一般流水线构建是上传的无压缩目录,在打 tag 发布时为了传递构件会使用一个同名的临时 zip ;对 macOS 和 Linux 环境为了避免破坏掉可执行文件的权限所以使用的是 .tar.gz 压缩,下载 Artifact 会被 GitHub 二压一遍成 zip ;能用但有些难看。

注意事项

因为改了构建主逻辑(从 msbuild 改成了 dotnet publish ),所以需要再仔细确认一下 Windows 平台下的构建发布是否依旧功能完备,正常运行。(这边放到 Windows Sandbox 里面装好 dotnet 运行环境后能启动)

补充

虽然现在 macOS 和 Linux 的流水线步骤都是一样的,但未来针对不同的平台可能引入不同的改动(例如 macOS 打包成 App , Linux 打包成 AppImage 这种),所以还是把它们拆开了。

Candinya added 9 commits May 13, 2024 21:55
* feat: add cross-platform ci

* chore: use dotnet instead of msbuild

* feat: use dotnot instead of msbuild for windows

* fix: tidy comments

* feat: build release only

* feat: dotnet publish

* feat: specify runtime

* fix: file permission loss caused by zip archive

so let's use .tar.gz for linux / macos

* fix: upload release artifact run case
to prevent accidentally create incomplete releases
because it's not fully cross-platform for now. We believe in the future.
@LiuYunPlayer
Copy link
Owner

的确现在用到的NAudio库中的某些功能只能在Windows上运行。
re-run的时候prepare release这个任务被跳过了,这是正常的吗?

@Candinya
Copy link
Contributor Author

re-run的时候prepare release这个任务被跳过了,这是正常的吗?

是正常的,这个 prepare release 是在打 tag 时候创建 release draft 使用的,在一般的 commit 构建时候不会运行到它。

@LiuYunPlayer
Copy link
Owner

好的

@LiuYunPlayer LiuYunPlayer merged commit 88f4c9c into LiuYunPlayer:master May 14, 2024
4 checks passed
@LiuYunPlayer
Copy link
Owner

image
似乎今天我从tag创建release draft的时候出错了

@Candinya
Copy link
Contributor Author

似乎今天我从tag创建release draft的时候出错了

看起来像是 softprops/action-gh-release#232 这个问题

或许可以尝试检查一下 Workflow permissions 这个是否为 Read and write permissions?(在 https://github.com/LiuYunPlayer/TuneLab/settings/actions 这里最底下)

如果是正确的话可以尝试将 issue 里面提到的 job 权限配置添加进 Prepare release 里试一试(可以参考 https://github.com/Candinya/TuneLab/commit/c7039248dc480e8ded6e5d445eafda0c14dd8331 这个提交)

@LiuYunPlayer
Copy link
Owner

感谢,我将权限设置改成Read and write后成功了,他好像自动就发布release了(因为我之前就用这个tag手动发过这个release了,所以表现是帮我替换了包文件)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants