Skip to content

Commit d889c2d

Browse files
committed
feat: 从 Git tag 获取版本号,更新构建脚本和配置文件
1 parent c276029 commit d889c2d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

.cnb.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ v1.0.*:
2424
- name: create release
2525
type: git:release
2626
options:
27-
title: release
2827
description: ${LATEST_CHANGE_LOG}
2928
- name: build
3029
script:

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
# 版本号
4-
VERSION="1.0.0"
3+
# 从 Git tag 获取版本号
4+
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
55

66
# 创建构建目录
77
mkdir -p build

internal/config/config.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package config
33
import (
44
"fmt"
55
"os"
6+
"os/exec"
7+
"strings"
68
)
79

810
type Config struct {
@@ -13,6 +15,16 @@ type Config struct {
1315
Token string
1416
}
1517

18+
// getVersion 从 Git tag 获取版本号
19+
func getVersion() string {
20+
cmd := exec.Command("git", "describe", "--tags", "--abbrev=0")
21+
output, err := cmd.Output()
22+
if err != nil {
23+
return "unknown"
24+
}
25+
return strings.TrimSpace(strings.TrimPrefix(string(output), "v"))
26+
}
27+
1628
func NewConfig() (*Config, error) {
1729
token := os.Getenv("ALAPI_TOKEN")
1830
if token == "" {
@@ -27,7 +39,7 @@ func NewConfig() (*Config, error) {
2739

2840
return &Config{
2941
ServerName: "ALAPI MCP Server",
30-
Version: "1.0.0",
42+
Version: getVersion(),
3143
OpenAPIURL: openAPIURL,
3244
BaseURL: "https://v3.alapi.cn",
3345
Token: token,

0 commit comments

Comments
 (0)