mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 09:38:13 -05:00
✨ v0.15.13 generate release
This commit is contained in:
parent
7a774319dd
commit
dc94259a56
@ -1,11 +1,12 @@
|
|||||||
name: Dashboard image
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: ["Run Tests"]
|
workflows: ["Run Tests"]
|
||||||
branches: [master]
|
|
||||||
types:
|
types:
|
||||||
- completed
|
- completed
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -37,7 +38,7 @@ jobs:
|
|||||||
v: true
|
v: true
|
||||||
x: false
|
x: false
|
||||||
race: false
|
race: false
|
||||||
ldflags: -s -w
|
ldflags: -s -w -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }}
|
||||||
buildmode: default
|
buildmode: default
|
||||||
|
|
||||||
- name: fix dist
|
- name: fix dist
|
||||||
@ -83,9 +84,25 @@ jobs:
|
|||||||
platforms: linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/riscv64 # linux/386,
|
platforms: linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/riscv64 # linux/386,
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
|
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:latest
|
||||||
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
||||||
|
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:latest
|
||||||
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
||||||
|
|
||||||
|
- name: Compress dist files
|
||||||
|
run: |
|
||||||
|
for file in dist/*; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
zip -r "$file.zip" "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
- uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "dist/*.zip"
|
||||||
|
generateReleaseNotes: true
|
||||||
|
|
||||||
- name: Purge jsdelivr cache
|
- name: Purge jsdelivr cache
|
||||||
run: |
|
run: |
|
||||||
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/install.sh
|
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/install.sh
|
@ -15,7 +15,6 @@ RUN export DEBIAN_FRONTEND="noninteractive" && \
|
|||||||
chmod +x /entrypoint.sh
|
chmod +x /entrypoint.sh
|
||||||
|
|
||||||
WORKDIR /dashboard
|
WORKDIR /dashboard
|
||||||
COPY ./resource ./resource
|
|
||||||
COPY dist/dashboard-${TARGETOS}-${TARGETARCH} ./app
|
COPY dist/dashboard-${TARGETOS}-${TARGETARCH} ./app
|
||||||
|
|
||||||
VOLUME ["/dashboard/data"]
|
VOLUME ["/dashboard/data"]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
<img src="https://img.shields.io/github/actions/workflow/status/naiba/nezha/dashboard.yml?label=Dash%20v0.15.13&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
|
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?style=for-the-badge&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
||||||
|
@ -3,6 +3,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -15,20 +16,34 @@ import (
|
|||||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||||
|
|
||||||
"github.com/naiba/nezha/pkg/mygin"
|
"github.com/naiba/nezha/pkg/mygin"
|
||||||
|
"github.com/naiba/nezha/resource"
|
||||||
"github.com/naiba/nezha/service/singleton"
|
"github.com/naiba/nezha/service/singleton"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ServeWeb(port uint) *http.Server {
|
func ServeWeb(port uint) *http.Server {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
tmpl := template.New("").Funcs(funcMap)
|
||||||
|
var err error
|
||||||
|
tmpl, err = tmpl.ParseFS(resource.TemplateFS, "template/**/*.html")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
tmpl, err = tmpl.ParseGlob("resource/template/**/*.html")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
r.SetHTMLTemplate(tmpl)
|
||||||
if singleton.Conf.Debug {
|
if singleton.Conf.Debug {
|
||||||
gin.SetMode(gin.DebugMode)
|
gin.SetMode(gin.DebugMode)
|
||||||
pprof.Register(r)
|
pprof.Register(r)
|
||||||
}
|
}
|
||||||
r.Use(mygin.RecordPath)
|
r.Use(mygin.RecordPath)
|
||||||
r.SetFuncMap(funcMap)
|
staticFs, err := fs.Sub(resource.StaticFS, "static")
|
||||||
r.Static("/static", "resource/static")
|
if err != nil {
|
||||||
r.LoadHTMLGlob("resource/template/**/*.html")
|
panic(err)
|
||||||
|
}
|
||||||
|
r.StaticFS("/static", http.FS(staticFs))
|
||||||
routers(r)
|
routers(r)
|
||||||
|
|
||||||
page404 := func(c *gin.Context) {
|
page404 := func(c *gin.Context) {
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/naiba/nezha/pkg/mygin"
|
"github.com/naiba/nezha/pkg/mygin"
|
||||||
"github.com/naiba/nezha/pkg/utils"
|
"github.com/naiba/nezha/pkg/utils"
|
||||||
"github.com/naiba/nezha/proto"
|
"github.com/naiba/nezha/proto"
|
||||||
|
"github.com/naiba/nezha/resource"
|
||||||
"github.com/naiba/nezha/service/singleton"
|
"github.com/naiba/nezha/service/singleton"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -863,7 +864,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.IsFileExists("resource/template/theme-" + sf.Theme + "/home.html") {
|
if !utils.IsFileExists("resource/template/theme-"+sf.Theme+"/home.html") && !resource.IsTemplateFileExist("template/theme-"+sf.Theme+"/home.html") {
|
||||||
c.JSON(http.StatusOK, model.Response{
|
c.JSON(http.StatusOK, model.Response{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
Message: fmt.Sprintf("前台主题文件异常:%s", sf.Theme),
|
Message: fmt.Sprintf("前台主题文件异常:%s", sf.Theme),
|
||||||
@ -871,7 +872,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.IsFileExists("resource/template/dashboard-" + sf.DashboardTheme + "/setting.html") {
|
if !utils.IsFileExists("resource/template/dashboard-"+sf.DashboardTheme+"/setting.html") && !resource.IsTemplateFileExist("template/dashboard-"+sf.DashboardTheme+"/setting.html") {
|
||||||
c.JSON(http.StatusOK, model.Response{
|
c.JSON(http.StatusOK, model.Response{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
Message: fmt.Sprintf("后台主题文件异常:%s", sf.DashboardTheme),
|
Message: fmt.Sprintf("后台主题文件异常:%s", sf.DashboardTheme),
|
||||||
|
19
resource/resource.go
vendored
Normal file
19
resource/resource.go
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed static
|
||||||
|
var StaticFS embed.FS
|
||||||
|
|
||||||
|
//go:embed template
|
||||||
|
var TemplateFS embed.FS
|
||||||
|
|
||||||
|
//go:embed l10n
|
||||||
|
var I18nFS embed.FS
|
||||||
|
|
||||||
|
func IsTemplateFileExist(name string) bool {
|
||||||
|
_, err := TemplateFS.Open(name)
|
||||||
|
return err == nil
|
||||||
|
}
|
@ -8,6 +8,7 @@ import (
|
|||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
|
|
||||||
"github.com/naiba/nezha/model"
|
"github.com/naiba/nezha/model"
|
||||||
|
"github.com/naiba/nezha/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Localizer *i18n.Localizer
|
var Localizer *i18n.Localizer
|
||||||
@ -20,13 +21,13 @@ func InitLocalizer() {
|
|||||||
log.Println("NEZHA>> language not exists:", Conf.Language)
|
log.Println("NEZHA>> language not exists:", Conf.Language)
|
||||||
Conf.Language = "zh-CN"
|
Conf.Language = "zh-CN"
|
||||||
} else {
|
} else {
|
||||||
_, err := bundle.LoadMessageFile("resource/l10n/" + Conf.Language + ".toml")
|
_, err := bundle.LoadMessageFileFS(resource.I18nFS, "l10n/"+Conf.Language+".toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := bundle.LoadMessageFile("resource/l10n/zh-CN.toml"); err != nil {
|
if _, err := bundle.LoadMessageFileFS(resource.I18nFS, "l10n/zh-CN.toml"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
Localizer = i18n.NewLocalizer(bundle, Conf.Language)
|
Localizer = i18n.NewLocalizer(bundle, Conf.Language)
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/naiba/nezha/pkg/utils"
|
"github.com/naiba/nezha/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "v0.15.13" // !!记得修改 README 中的 badge 版本!!
|
var Version = "debug"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Conf *model.Config
|
Conf *model.Config
|
||||||
|
Loading…
Reference in New Issue
Block a user