jinnrry 2 лет назад
Родитель
Сommit
4f150fbf18
4 измененных файлов с 10 добавлено и 7 удалено
  1. 1 0
      .github/workflows/docker_build_pre.yml
  2. 5 5
      DockerfileGithubAction
  3. 0 2
      server/config/config.go
  4. 4 0
      server/main.go

+ 1 - 0
.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: |

+ 5 - 5
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

+ 0 - 2
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" //自动生成证书

+ 4 - 0
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)