gh-versions: 公司前端项目的一个版本回滚工具
oss 项目的一个版本回滚工具
项目主页: https://github.com/aric-go/gh-versions
安装
# 安装
brew install jswork/homebrew/gh-versions
# 查看版本
ghv --versions
其它工具
# aliyun
brew install aliyun
# 配置
aliyun configure set --profile akProfile --mode AK --region cn-beijing --access-key-id ALI_KEY --access-key-secret OSS_SECRET
基本使用
gh-versions on 🌱 main [!] via 🐹 v1.24.1 via 🐠 v20.18.0
$ ghv -h
🏡 Manage oss project versions.
Usage:
gh-versions [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
init Initialize configuration file
list List all versions
refresh Refresh CDN cache for the configured URL
rollback Rollback to a specific version of the application (alias: r, rb)
sync Sync production directory with timestamp and latest version (alias: s)
tag Create a tag for oss production release (alias: t)
Flags:
-h, --help help for gh-versions
Use "gh-versions [command] --help" for more information about a command.
想法
开发这个工具的主要提示词
## gh-versions
1. tag(t): 将 production 目录备份到 s3://web-alo7-com/app/awesome-ci/releases/production-1.0.2-20250306_224132
2. sync(s): 将 releases 目录产生一个 versions.json 到 s3://web-alo7-com/app/awesome-ci/releases/versions.json 里
3. rollback(r):
1. 将最后一个备份恢复到 production 目录
2. 如果带参数 -t 可以找到对应的 tag 版本恢复到 production 目录
3. 如果带 -d 参数,可以找到对应日期的备份恢复到 -d 的目录名(用于一些需要将 production 产生一个新地址给别人用的场景)
4. list(l): 列出所有 tag 版本,如果没有 versions.json,提示用户先执行 sync 命令 -> done
5. init(i): 生成基本的配置文件,需要用户来配置 -> done
## .gh-versions.config.yml
```yml
name: awesome-ci
bucket: web-alo7-com/app/awesome-ci/
limit: 3
```
## version.json
> 这个玩意儿由项目中的 vite-plugin-version 插件生成,生成的版本信息如下:
```json
{
"mode": "production",
"version": "1.0.3",
"githash": "unknown",
"build_time": "2025-03-12T08:41:30.419Z"
}
```
## versions.json
> 由 sync 命令生成,内容如下:
```json
{
"name": "awesome-ci",
"versions": []
}
```



