Files
base-golang/README.md
T

33 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Golang公共包
* pb协议文件生成命令
`protoc --proto_path=pkg/websocket/codec/protobuf/protocol --go_out=pkg/websocket/codec/protobuf/protocol --go_opt=paths=source_relative base.proto`
## 自动更新依赖并发布版本
仓库包含 `.gitea/workflows/dependency-release.yml`。启用 Gitea Actions 后,它会在每周日 03:17 UTC(北京时间 11:17)运行,也可以在 Actions 页面手动运行:
1. 使用 `go get -u ./...``go mod tidy` 更新依赖。
2. 执行 `go test ./...`,测试失败时不会提交或发布。
3. 有依赖变更时提交 `go.mod``go.sum`,创建下一个 `vMAJOR.MINOR.PATCH` 补丁版本标签,并创建 Gitea Release。
### 树莓派上的 Runner 配置
在树莓派上安装并注册 Gitea `act_runner`,注册标签中包含 `self-hosted`,并确保 Runner 环境有 Git、Go、Node.js、`curl`。工作流使用 `runs-on: self-hosted`,因此不会依赖 GitHub-hosted Runner。
在仓库的 **Settings -> Secrets -> Actions** 中新增:
- `GITEA_TOKEN`:一个能读写仓库内容、创建标签和 Release 的 Gitea Personal Access Token。
如果默认分支启用了保护规则,还需要允许该 Token 所属账号直接推送。
首次使用时建议先在仓库中手动创建一个 `v0.1.0` 以后的 SemVer 标签;如果没有任何 `vMAJOR.MINOR.PATCH` 标签,工作流会从 `v0.1.0` 开始。
```text
1. 安装并注册 act_runner,标签包含 self-hosted
2. Runner 安装 Git、Go、Node.js、curl
3. 添加 SecretGITEA_TOKEN
4. Token 允许读写仓库、创建标签和 Release
5. 若默认分支受保护,允许该 Token 所属账号推送
```