feat: 添加版本号显示和自动构建/删除 Docker 镜像功能

- 添加前端版本号显示(桌面端和移动端)
- 实现 GitHub Actions 自动构建和推送 Docker 镜像
- 实现删除 release 时自动删除对应 Docker 镜像
- 支持版本号格式:v数字.数字.数字 或 v数字.数字.数字-后缀
- 添加版本号管理文档
- 更新 Dockerfile 和部署脚本支持版本号构建参数
This commit is contained in:
WrBug
2025-12-07 16:46:18 +08:00
parent 07d1b50b9b
commit b069e54b89
10 changed files with 499 additions and 9 deletions
+7
View File
@@ -45,3 +45,10 @@ export {
hasToken
} from './auth'
// 统一导出 version 相关工具函数
export {
getVersionInfo,
getVersionText,
getGitHubTagUrl
} from './version'
+52
View File
@@ -0,0 +1,52 @@
/**
* 版本号配置
* 在构建时通过环境变量注入
*/
export interface VersionInfo {
version: string
gitTag: string
githubRepoUrl: string
}
/**
* 获取版本信息
* 从 window.__VERSION__ 或环境变量中读取
*/
export const getVersionInfo = (): VersionInfo => {
// 优先从 window.__VERSION__ 读取(构建时注入)
const windowVersion = window.__VERSION__
if (windowVersion) {
return {
version: windowVersion.version || 'dev',
gitTag: windowVersion.gitTag || '',
githubRepoUrl: windowVersion.githubRepoUrl || 'https://github.com/WrBug/PolyHermes'
}
}
// 从环境变量读取(开发环境)
return {
version: import.meta.env.VITE_APP_VERSION || 'dev',
gitTag: import.meta.env.VITE_APP_GIT_TAG || '',
githubRepoUrl: import.meta.env.VITE_APP_GITHUB_REPO_URL || 'https://github.com/WrBug/PolyHermes'
}
}
/**
* 获取版本号显示文本
*/
export const getVersionText = (): string => {
const info = getVersionInfo()
return info.version
}
/**
* 获取 GitHub tag 页面 URL
*/
export const getGitHubTagUrl = (): string => {
const info = getVersionInfo()
if (info.gitTag) {
return `${info.githubRepoUrl}/releases/tag/${info.gitTag}`
}
return info.githubRepoUrl
}