feat(settings): link version to GitHub release page instead of commit

This commit is contained in:
Gigi
2025-10-16 20:57:57 +02:00
parent 3fff9455a1
commit 1029b6be0c
2 changed files with 13 additions and 19 deletions

View File

@@ -169,19 +169,13 @@ const Settings: React.FC<SettingsProps> = ({ settings, onSave, onClose, relayPoo
<RelaySettings relayStatuses={relayStatuses} onClose={onClose} />
</div>
<div className="text-xs opacity-60 mt-4 px-4 pb-3 select-text">
<span>Version {typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'}</span>
{typeof __GIT_COMMIT__ !== 'undefined' && __GIT_COMMIT__ ? (
<span>
{' '}·
{typeof __GIT_COMMIT_URL__ !== 'undefined' && __GIT_COMMIT_URL__ ? (
<a href={__GIT_COMMIT_URL__} target="_blank" rel="noopener noreferrer">
<code>{__GIT_COMMIT__.slice(0, 7)}</code>
</a>
) : (
<code>{__GIT_COMMIT__.slice(0, 7)}</code>
)}
</span>
) : null}
{typeof __GIT_COMMIT_URL__ !== 'undefined' && __GIT_COMMIT_URL__ ? (
<a href={__GIT_COMMIT_URL__} target="_blank" rel="noopener noreferrer">
Version {typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'}
</a>
) : (
<span>Version {typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'}</span>
)}
</div>
</div>
)

View File

@@ -36,13 +36,13 @@ const { commit, branch } = getGitMetadata()
const version = getPackageVersion()
const buildTime = new Date().toISOString()
function getCommitUrl(commit: string): string {
if (!commit) return ''
function getReleaseUrl(version: string): string {
if (!version) return ''
const provider = process.env.VERCEL_GIT_PROVIDER || ''
const owner = process.env.VERCEL_GIT_REPO_OWNER || ''
const slug = process.env.VERCEL_GIT_REPO_SLUG || ''
if (provider.toLowerCase() === 'github' && owner && slug) {
return `https://github.com/${owner}/${slug}/commit/${commit}`
return `https://github.com/${owner}/${slug}/releases/tag/v${version}`
}
try {
const remote = execSync('git config --get remote.origin.url', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
@@ -52,7 +52,7 @@ function getCommitUrl(commit: string): string {
? `https://github.com/${remote.split(':')[1]}`
: remote
const cleaned = https.replace(/\.git$/, '')
return `${cleaned}/commit/${commit}`
return `${cleaned}/releases/tag/v${version}`
}
} catch {
// ignore
@@ -60,7 +60,7 @@ function getCommitUrl(commit: string): string {
return ''
}
const commitUrl = getCommitUrl(commit)
const releaseUrl = getReleaseUrl(version)
export default defineConfig({
define: {
@@ -68,7 +68,7 @@ export default defineConfig({
__GIT_COMMIT__: JSON.stringify(commit),
__GIT_BRANCH__: JSON.stringify(branch),
__BUILD_TIME__: JSON.stringify(buildTime),
__GIT_COMMIT_URL__: JSON.stringify(commitUrl)
__GIT_COMMIT_URL__: JSON.stringify(releaseUrl)
},
plugins: [
react(),