Skip to content

Commit b9135ec

Browse files
xrgzsSuyunmeng
authored andcommitted
feat(setting): add site version information (#859)
* feat(setting): add site version information * feat(conf): update conf.WebVersion to rolling * fix(static): update condition to check conf.Version instead of conf.WebVersion * fix(build.sh): use rolling release for web frontend in dev and beta builds * chore(build.sh): update GitAuthor to The OpenList Projects Contributors * fix(static): update condition to check conf.WebVersion
1 parent 101c7ed commit b9135ec

File tree

6 files changed

+26
-33
lines changed

6 files changed

+26
-33
lines changed

.github/workflows/beta_release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ jobs:
105105
musl-base-url: "https://github.com/OpenListTeam/musl-compilers/releases/latest/download/"
106106
x-flags: |
107107
github.com/OpenListTeam/OpenList/v4/internal/conf.BuiltAt=$built_at
108-
github.com/OpenListTeam/OpenList/v4/internal/conf.GitAuthor=OpenList
108+
github.com/OpenListTeam/OpenList/v4/internal/conf.GitAuthor=The OpenList Projects Contributors <[email protected]>
109109
github.com/OpenListTeam/OpenList/v4/internal/conf.GitCommit=$git_commit
110110
github.com/OpenListTeam/OpenList/v4/internal/conf.Version=$tag
111-
github.com/OpenListTeam/OpenList/v4/internal/conf.WebVersion=dev
111+
github.com/OpenListTeam/OpenList/v4/internal/conf.WebVersion=rolling
112112
113113
- name: Compress
114114
run: |

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ jobs:
4949
out-dir: build
5050
x-flags: |
5151
github.com/OpenListTeam/OpenList/v4/internal/conf.BuiltAt=$built_at
52-
github.com/OpenListTeam/OpenList/v4/internal/conf.GitAuthor=OpenList
52+
github.com/OpenListTeam/OpenList/v4/internal/conf.GitAuthor=The OpenList Projects Contributors <[email protected]>
5353
github.com/OpenListTeam/OpenList/v4/internal/conf.GitCommit=$git_commit
5454
github.com/OpenListTeam/OpenList/v4/internal/conf.Version=$tag
55-
github.com/OpenListTeam/OpenList/v4/internal/conf.WebVersion=dev
55+
github.com/OpenListTeam/OpenList/v4/internal/conf.WebVersion=rolling
5656
output: openlist$ext
5757

5858
- name: Upload artifact

build.sh

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fi
1717

1818
if [ "$1" = "dev" ]; then
1919
version="dev"
20-
webVersion="dev"
20+
webVersion="rolling"
2121
elif [ "$1" = "beta" ]; then
2222
version="beta"
23-
webVersion="dev"
23+
webVersion="rolling"
2424
else
2525
git tag -d beta || true
2626
# Always true if there's no tag
@@ -45,26 +45,17 @@ ldflags="\
4545
-X 'github.com/OpenListTeam/OpenList/v4/internal/conf.WebVersion=$webVersion' \
4646
"
4747

48-
FetchWebDev() {
49-
pre_release_tag=$(eval "curl -fsSL --max-time 2 $githubAuthArgs https://api.github.com/repos/OpenListTeam/OpenList-Frontend/releases" | jq -r 'map(select(.prerelease)) | first | .tag_name')
50-
if [ -z "$pre_release_tag" ] || [ "$pre_release_tag" == "null" ]; then
51-
# fall back to latest release
52-
pre_release_json=$(eval "curl -fsSL --max-time 2 $githubAuthArgs -H \"Accept: application/vnd.github.v3+json\" \"https://api.github.com/repos/OpenListTeam/OpenList-Frontend/releases/latest\"")
53-
else
54-
pre_release_json=$(eval "curl -fsSL --max-time 2 $githubAuthArgs -H \"Accept: application/vnd.github.v3+json\" \"https://api.github.com/repos/OpenListTeam/OpenList-Frontend/releases/tags/$pre_release_tag\"")
55-
fi
48+
FetchWebRolling() {
49+
pre_release_json=$(eval "curl -fsSL --max-time 2 $githubAuthArgs -H \"Accept: application/vnd.github.v3+json\" \"https://api.github.com/repos/OpenListTeam/OpenList-Frontend/releases/tags/rolling\"")
5650
pre_release_assets=$(echo "$pre_release_json" | jq -r '.assets[].browser_download_url')
5751

58-
if [ "$useLite" = true ]; then
59-
pre_release_tar_url=$(echo "$pre_release_assets" | grep "openlist-frontend-dist-lite" | grep "\.tar\.gz$")
60-
else
61-
pre_release_tar_url=$(echo "$pre_release_assets" | grep "openlist-frontend-dist" | grep -v "lite" | grep "\.tar\.gz$")
62-
fi
63-
64-
curl -fsSL "$pre_release_tar_url" -o web-dist-dev.tar.gz
52+
# There is no lite for rolling
53+
pre_release_tar_url=$(echo "$pre_release_assets" | grep "openlist-frontend-dist" | grep -v "lite" | grep "\.tar\.gz$")
54+
55+
curl -fsSL "$pre_release_tar_url" -o dist.tar.gz
6556
rm -rf public/dist && mkdir -p public/dist
66-
tar -zxvf web-dist-dev.tar.gz -C public/dist
67-
rm -rf web-dist-dev.tar.gz
57+
tar -zxvf dist.tar.gz -C public/dist
58+
rm -rf dist.tar.gz
6859
}
6960

7061
FetchWebRelease() {
@@ -590,7 +581,7 @@ for arg in "$@"; do
590581
done
591582

592583
if [ "$buildType" = "dev" ]; then
593-
FetchWebDev
584+
FetchWebRolling
594585
if [ "$dockerType" = "docker" ]; then
595586
BuildDocker
596587
elif [ "$dockerType" = "docker-multiplatform" ]; then
@@ -602,7 +593,7 @@ if [ "$buildType" = "dev" ]; then
602593
fi
603594
elif [ "$buildType" = "release" -o "$buildType" = "beta" ]; then
604595
if [ "$buildType" = "beta" ]; then
605-
FetchWebDev
596+
FetchWebRolling
606597
else
607598
FetchWebRelease
608599
fi

internal/bootstrap/data/setting.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package data
22

33
import (
4+
"fmt"
45
"sort"
56
"strconv"
67

@@ -92,9 +93,10 @@ func InitialSettings() []model.SettingItem {
9293
} else {
9394
token = random.Token()
9495
}
96+
siteVersion := fmt.Sprintf("%s (Commit: %s) - Frontend: %s - Build at: %s", conf.Version, conf.GitCommit, conf.WebVersion, conf.BuiltAt)
9597
initialSettingItems := []model.SettingItem{
9698
// site settings
97-
{Key: conf.VERSION, Value: conf.Version, Type: conf.TypeString, Group: model.SITE, Flag: model.READONLY},
99+
{Key: conf.VERSION, Value: siteVersion, Type: conf.TypeString, Group: model.SITE, Flag: model.READONLY},
98100
//{Key: conf.ApiUrl, Value: "", Type: conf.TypeString, Group: model.SITE},
99101
//{Key: conf.BasePath, Value: "", Type: conf.TypeString, Group: model.SITE},
100102
{Key: conf.SiteTitle, Value: "OpenList", Type: conf.TypeString, Group: model.SITE},

internal/conf/var.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import (
66
)
77

88
var (
9-
BuiltAt string
10-
GitAuthor string
11-
GitCommit string
9+
BuiltAt string = "unknown"
10+
GitAuthor string = "unknown"
11+
GitCommit string = "unknown"
1212
Version string = "dev"
13-
WebVersion string
13+
WebVersion string = "rolling"
1414
)
1515

1616
var (

server/static/static.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ func replaceStrings(content string, replacements map[string]string) string {
4343

4444
func initIndex(siteConfig SiteConfig) {
4545
utils.Log.Debug("Initializing index.html...")
46-
// dist_dir is empty and cdn is not empty add web_version is empty or beta or dev
47-
if conf.Conf.DistDir == "" && conf.Conf.Cdn != "" && (conf.WebVersion == "" || conf.WebVersion == "beta" || conf.WebVersion == "dev") {
48-
utils.Log.Infof("Fetching index.html from CDN: %s/index.html...", conf.Conf.Cdn)
46+
// dist_dir is empty and cdn is not empty, and web_version is empty or beta or dev or rolling
47+
if conf.Conf.DistDir == "" && conf.Conf.Cdn != "" && (conf.WebVersion == "" || conf.WebVersion == "beta" || conf.WebVersion == "dev" || conf.WebVersion == "rolling") {
48+
utils.Log.Infof("Fetching index.html from CDN: %s/index.html...", siteConfig.Cdn)
4949
resp, err := base.RestyClient.R().
5050
SetHeader("Accept", "text/html").
5151
Get(fmt.Sprintf("%s/index.html", siteConfig.Cdn))

0 commit comments

Comments
 (0)