本文档说明如何将 CodeMetrics 项目发布到 GitHub 并让全球开发者使用。
在发布之前,确认以下内容:
- ✅ 代码已完成并测试
- ✅ 文档完整(README、CONTRIBUTING 等)
- ✅ Git 仓库已初始化
- ✅ 项目结构已优化
- ✅ LICENSE 文件已添加
- ✅ .gitignore 已配置
- ✅ GitHub Actions 工作流已设置
- ✅ 所有更改已提交
访问 https://github.com 并登录你的账号
-
点击右上角的
+→New repository -
填写仓库信息:
- Repository name:
CodeMetrics - Description:
📊 A powerful code metrics and analysis tool with COCOMO estimation, health analysis, and multi-format reports - Visibility:
Public(让全球开发者可见) ⚠️ 不要 勾选以下选项:- Add a README file
- Add .gitignore
- Choose a license
因为我们已经有这些文件了
- Repository name:
-
点击
Create repository
在本地项目目录执行:
cd /home/zhangbh/cursor-tools/CodeMetrics
# 添加远程仓库(替换 TbusOS 为你的 GitHub 用户名)
git remote add origin https://github.com/TbusOS/CodeMetrics.git
# 查看远程仓库
git remote -v
# 推送代码到 GitHub
git branch -M master
git push -u origin master提示: 首次推送可能需要输入 GitHub 用户名和密码(或 Personal Access Token)
cd /home/zhangbh/cursor-tools/CodeMetrics
# 创建带注释的标签
git tag -a v1.1.0 -m "Release v1.1.0 - First public release
✨ Features:
- Directory tree visualization
- Code metrics analysis for 50+ languages
- COCOMO cost estimation
- Health analysis
- Multi-format output (Terminal/JSON/Markdown/HTML)
- Zero dependencies
"
# 推送标签到 GitHub
git push origin v1.1.0方式一:自动(通过 GitHub Actions)
- 推送标签后,GitHub Actions 会自动创建 Release
方式二:手动创建
- 访问
https://github.com/TbusOS/CodeMetrics/releases - 点击
Create a new release - 选择标签
v1.1.0 - 填写 Release 信息:
- Release title:
CodeMetrics v1.1.0 - First Public Release - Description: 复制
docs/RELEASE_NOTES.md的内容
- Release title:
- 附加文件(可选):
codemetrics.pyconfig.json
- 点击
Publish release
- 访问你的仓库主页
- 点击右上角的
⚙️ Settings - 在 General 设置中:
- Description:
📊 A powerful code metrics and analysis tool with COCOMO estimation, health analysis, and multi-format reports - Website: 如果有的话
- Topics: 添加标签
code-metrics, code-analysis, cocomo, python, cli-tool, developer-tools, code-quality, software-metrics, static-analysis
- Description:
- ✅ Enable Issues
- ✅ Enable Discussions (可选,用于社区交流)
创建一个 1200x630 的图片作为分享时的预览图
编辑 README.md,替换占位符:
cd /home/zhangbh/cursor-tools/CodeMetrics
# 使用你的 GitHub 用户名替换 TbusOS
sed -i 's/TbusOS/你的用户名/g' README.md
git add README.md
git commit -m "docs: 更新 README 中的 GitHub 链接"
git push origin master分享到:
- Reddit (r/programming, r/Python)
- Hacker News
- 微信公众号
- 知乎
- V2EX
- CSDN
介绍:
- 为什么创建这个工具
- 主要功能和特点
- 使用示例
- 与其他工具的对比
- 及时回复用户问题
- 标记 Issues(bug/enhancement/question)
- 关闭已解决的 Issues
- 感谢贡献者
- 代码审查
- 测试后合并
当有重要更新时:
# 更新 CHANGELOG.md
vim CHANGELOG.md
# 提交更改
git add .
git commit -m "chore: prepare for v1.2.0"
git push
# 创建新标签
git tag -a v1.2.0 -m "Release v1.2.0"
git push origin v1.2.0# 克隆仓库
git clone https://github.com/TbusOS/CodeMetrics.git
# 添加远程仓库
git remote add origin https://github.com/TbusOS/CodeMetrics.git
# 推送代码
git push -u origin master
# 创建标签
git tag -a v1.1.0 -m "Release v1.1.0"
git push origin v1.1.0
# 查看状态
git status
git log --oneline
# 更新远程仓库
git pull origin master
git push origin master发布完成后,确认:
- 仓库在 GitHub 上可见
- README 正确显示
- 所有文件都已上传
- Release 已创建
- GitHub Actions 正常运行
- Issues 和 PR 模板可用
- Topics 标签已添加
- LICENSE 正确显示
恭喜!你的项目现在已经:
- ✨ 在 GitHub 上公开
- 🌍 全球开发者可以访问
- 📦 可以通过 git clone 安装
- 🤝 接受社区贡献
- 📈 开始收集 ⭐ Stars
下一步:
- 分享到社交媒体
- 邀请朋友试用
- 收集反馈
- 持续改进
- GitHub Docs - Creating a Repository
- GitHub Docs - Managing Releases
- Semantic Versioning
- Keep a Changelog
- Awesome README
祝你的开源项目成功! 🚀✨