Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
12 changes: 7 additions & 5 deletions consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const (
)

const (
SonicVersion = "1.0.0"
SonicBackupPrefix = "sonic-backup-"
SonicDataExportPrefix = "sonic-data-export-"
SonicBackupMarkdownPrefix = "sonic-backup-markdown-"
Expand All @@ -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
)
2 changes: 0 additions & 2 deletions event/listener/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package listener
import (
"context"
"fmt"
"time"

"go.uber.org/zap"
"gorm.io/gorm"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions service/impl/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"math/rand"
"os"
"path/filepath"
"runtime"
"time"

uuid2 "github.com/google/uuid"
Expand Down Expand Up @@ -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),
}
Expand Down