smlx/go-cli-github

GitHub: smlx/go-cli-github

一个预配置了深度 GitHub 集成和完整工程化流程的 Go CLI 项目模板,帮助开发者快速启动符合最佳实践的新项目。

Stars: 1 | Forks: 0

# Go CLI GitHub [![Go Reference](https://pkg.go.dev/badge/github.com/smlx/go-cli-github.svg)](https://pkg.go.dev/github.com/smlx/go-cli-github) [![Release](https://static.pigsec.cn/wp-content/uploads/repos/cas/64/64f96943e530c079a780e46d8bc3fe41af837c35cadbc388133edba520d84ff9.svg)](https://github.com/smlx/go-cli-github/actions/workflows/release.yaml) [![Go Report Card](https://goreportcard.com/badge/github.com/smlx/go-cli-github)](https://goreportcard.com/report/github.com/smlx/go-cli-github) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/smlx/go-cli-github/badge)](https://securityscorecards.dev/viewer/?uri=github.com/smlx/go-cli-github) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8168/badge)](https://www.bestpractices.dev/projects/8168) 本仓库是一个 Go CLI 工具或服务的模板。 它在安全和发布工程方面有相当强的主见,但希望能往好的方向发展。 它预配置了与 GitHub 特定功能的集成,例如 [Dependabot 安全工具](https://docs.github.com/en/code-security/dependabot)、[CodeQL](https://codeql.github.com/) 和[分支保护](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches)。 它还会使用 [GitHub Actions](https://docs.github.com/en/actions) 自动构建和测试你的代码。 ## 功能特性 * 使用 [GoReleaser](https://goreleaser.com/) 在合并到 `main` 分支时自动构建并创建 GitHub Releases 和容器镜像。 * 使用 [Conventional Commits Versioner](https://github.com/smlx/ccv) 自动对每个版本进行版本控制。 * 对你的 commit message、Go 代码、GitHub Actions 和 Dockerfile 进行 lint 检查。 * 使用 `go test` 测试 Pull Requests。 * 从 Pull Requests 构建容器镜像,并将其推送到 GitHub container registry 以进行手动测试和审查。 * 使用 [CodeQL](https://codeql.github.com/) 和 [Go Report Card](https://goreportcard.com/) 进行静态代码分析。 * 使用 [GitHub coverage API](https://docs.github.com/en/code-security/how-tos/maintain-quality-code/set-up-code-coverage) 进行覆盖率分析。 * 使用 [OpenSSF](https://securityscorecards.dev) 进行安全分析。 * 使用 [artifact attestations](https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds) 对签名的二进制文件和容器发布产物进行校验。 * 为发布产物和容器镜像生成 SBOM,并将镜像的 SBOM 推送到 container registry。 ## 如何使用 首先设置 GitHub 仓库 1. 创建一个新的空 GitHub 仓库。 然后推送一些代码到 main 分支: 1. 安装 [gonew](https://go.dev/blog/gonew) 并运行以下命令,将最后一个参数替换为你的新模块名称: gonew github.com/smlx/go-cli-github@main github.com/smlx/newproject 2. 创建 git 仓库并推送到 `main`(这将成为默认分支): cd newproject git init . git branch -M main git remote add origin git@github.com:smlx/newproject.git git add . git commit -am 'chore: create repository from template' git push -u origin main 然后针对你的仓库自定义代码: 1. 检出一个新分支来设置仓库 `git checkout -b setup main` 2. 为你的项目更新代码: * 将 `cmd/go-cli-github` 重命名为 `cmd/$YOUR_COMMAND` * 更新 `.github/workflows/build.yaml`,将 `go-cli-github` 替换为 `$YOUR_COMMAND`。 * 更新 `.goreleaser.yaml` 以构建 `cmd/$YOUR_COMMAND` * 更新 `README.md` 顶部的链接 * 更新 `SECURITY.md` 中的联系邮箱 * 如果你[不在启用了代码质量功能的企业账户中](https://github.com/orgs/community/discussions/194833#discussioncomment-17174472),请删除 coverage 工作流(`.github/workflows/coverage.yaml`) 3. 提交并推送: git add . git commit -am 'chore: update template for new project' git push -u origin setup 4. 开启一个 PR,等待所有检查通过变绿,然后合并该 PR。 配置仓库: 1. 进入仓库 Settings > General: 1. Releases * 开启 release immutability 2. Features * 禁用 wiki 和 projects(除非你打算使用它们!) 3. Pull Requests * 仅允许 Pull Requests 使用 merge commits * 允许 auto-merge * 自动删除 head branches 2. 进入仓库 Settings > Advanced Security,并确保以下选项已启用: * Private vulnerability reporting * Dependabot * Dependabot alerts * Dependabot malware alerts * Dependabot security updates * Grouped security updates * Dependabot on Actions runners * Code Scanning * CodeQL analysis > Set up > Default * Secret Protection * Push protection 3. 进入仓库 Settings > Rules > Rulesets,并导入 `protect-default-branch.json` ruleset。 大功告成。 ## 如何贡献 欢迎提交 Issues。 也欢迎提交 PR,但请记住这是一个非常有主见的模板,因此并非所有的更改都会被接受。 PR 还需要确保测试覆盖率保持在较高水平,并遵循最佳实践。
标签:CLI, EVTX分析, GitHub集成, Go, Ruby工具, WiFi技术, 安全专业人员, 日志审计, 请求拦截, 项目模板