From 4f150fbf184c721999eed308adab060f96efbb62 Mon Sep 17 00:00:00 2001 From: jinnrry Date: Fri, 1 Mar 2024 21:27:02 +0800 Subject: [PATCH] fix --- .github/workflows/docker_build_pre.yml | 1 + DockerfileGithubAction | 10 +++++----- server/config/config.go | 2 -- server/main.go | 4 ++++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker_build_pre.yml b/.github/workflows/docker_build_pre.yml index da1e6b3..21799d5 100644 --- a/.github/workflows/docker_build_pre.yml +++ b/.github/workflows/docker_build_pre.yml @@ -51,6 +51,7 @@ jobs: - name: Build and push Docker images uses: docker/build-push-action@v4 with: + build-args: VERSION=${{ env.VERSION }} context: . file: ./DockerfileGithubAction platforms: | diff --git a/DockerfileGithubAction b/DockerfileGithubAction index 6a3b5f9..3150d01 100644 --- a/DockerfileGithubAction +++ b/DockerfileGithubAction @@ -1,11 +1,11 @@ FROM golang:alpine as serverbuild - +ARG VERSION WORKDIR /work COPY server . RUN apk update && apk add git -RUN go build -ldflags "-s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)'" -o pmail main.go +RUN go build -ldflags "-s -w -X 'main.version=${VERSION}' -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)'" -o pmail main.go RUN cd /work/hooks/telegram_push && go build -ldflags "-s -w" -o output/telegram_push telegram_push.go RUN cd /work/hooks/web_push && go build -ldflags "-s -w" -o output/web_push web_push.go RUN cd /work/hooks/wechat_push && go build -ldflags "-s -w" -o output/wechat_push wechat_push.go @@ -24,8 +24,8 @@ RUN apk add --no-cache tzdata \ COPY --from=serverbuild /work/pmail . -COPY --from=serverbuild /work/hooks/telegram_push/output/* ./plugin/ -COPY --from=serverbuild /work/hooks/web_push/output/* ./plugin/ -COPY --from=serverbuild /work/hooks/wechat_push/output/* ./plugin/ +COPY --from=serverbuild /work/hooks/telegram_push/output/* ./plugins/ +COPY --from=serverbuild /work/hooks/web_push/output/* ./plugins/ +COPY --from=serverbuild /work/hooks/wechat_push/output/* ./plugins/ CMD /work/pmail diff --git a/server/config/config.go b/server/config/config.go index 704e991..4298441 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -41,8 +41,6 @@ type Config struct { //go:embed tables/* var tableConfig embed.FS -const Version = "2.4.0" - const DBTypeMySQL = "mysql" const DBTypeSQLite = "sqlite" const SSLTypeAuto = "0" //自动生成证书 diff --git a/server/main.go b/server/main.go index 569f7f9..8a2edef 100644 --- a/server/main.go +++ b/server/main.go @@ -74,6 +74,10 @@ func main() { log.SetLevel(log.InfoLevel) } + if version == "" { + version = "2.4.0" + } + log.Infoln("***************************************************") log.Infof("***\tServer Start Success Version:%s\n", version) log.Infof("***\tGit Commit Hash: %s ", gitHash)