feat: assign a version number at compile time

pull/204/head
1379 2 years ago committed by 1379Monitor
parent 81892922b6
commit 38feae6043

@ -54,6 +54,7 @@ jobs:
- name: Show workflow information
run: |
echo "GOOS: $GOOS, GOARCH: $GOARCH"
echo "BUILD_TIME=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
- name: Build
uses: crazy-max/ghaction-xgo@v2
@ -66,7 +67,7 @@ jobs:
v: true
x: false
race: false
ldflags: -s -w
ldflags: -s -w -X 'github.com/go-sonic/sonic/consts.SonicVersion=${{github.ref_name}}' -X 'github.com/go-sonic/sonic/consts.BuildCommit=${{github.sha}}' -X 'github.com/go-sonic/sonic/consts.BuildTime=${{env.BUILD_TIME}}'
buildmode: default
trimpath: true

@ -19,7 +19,6 @@ const (
)
const (
SonicVersion = "1.0.0"
SonicBackupPrefix = "sonic-backup-"
SonicDataExportPrefix = "sonic-data-export-"
SonicBackupMarkdownPrefix = "sonic-backup-markdown-"
@ -40,7 +39,10 @@ const (
ThemeCustomPostPrefix = "post_"
)
// StartTime 系统启动时间
var StartTime time.Time
var DatabaseVersion string
var (
StartTime time.Time = time.Now()
DatabaseVersion string
SonicVersion = "v1.0.0"
BuildTime string
BuildCommit string
)

@ -3,7 +3,6 @@ package listener
import (
"context"
"fmt"
"time"
"go.uber.org/zap"
"gorm.io/gorm"
@ -37,7 +36,6 @@ func (s *StartListener) HandleEvent(ctx context.Context, startEvent event.Event)
if _, ok := startEvent.(*event.StartEvent); !ok {
return nil
}
consts.StartTime = time.Now()
err := s.createOptions()
if err != nil {

@ -8,7 +8,6 @@ import (
"math/rand"
"os"
"path/filepath"
"runtime"
"time"
uuid2 "github.com/google/uuid"
@ -184,7 +183,7 @@ func (a *adminServiceImpl) RefreshToken(ctx context.Context, refreshToken string
func (a *adminServiceImpl) GetEnvironments(ctx context.Context) *dto.EnvironmentDTO {
environments := &dto.EnvironmentDTO{
Database: string(dal.DBType) + " " + consts.DatabaseVersion,
Version: runtime.Version(),
Version: consts.SonicVersion,
StartTime: consts.StartTime.UnixMilli(),
Mode: util.IfElse(a.Config.Sonic.Mode == "", "production", a.Config.Sonic.Mode).(string),
}

Loading…
Cancel
Save