diff --git a/.github/workflows/docker_build_pre.yml b/.github/workflows/docker_build_pre.yml index da1e6b38..21799d59 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/.github/workflows/release.yml b/.github/workflows/release.yml index 7d01f4f7..320e6dfe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,22 +3,22 @@ name: Build and Release on: workflow_dispatch: release: - types: [released,prereleased] + types: [ released,prereleased ] + - jobs: build: permissions: contents: write strategy: matrix: - goos: [windows, linux, darwin] - goarch: [amd64, arm64] + goos: [ windows, linux, darwin ] + goarch: [ amd64, arm64 ] runs-on: ubuntu-latest - env: - CGO_ENABLED: 0 - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} + env: + CGO_ENABLED: 0 + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} steps: - name: Get version id: get_version @@ -37,43 +37,46 @@ jobs: check-latest: true - name: Gen output name run: | - echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} - echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} - echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} - echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + echo "ZIPNAME=${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} - name: Rename Windows File if: matrix.goos == 'windows' run: | - echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} - echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} - echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} - echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} + echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} + echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} + echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} + echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} - name: FE Build run: cd fe && yarn && yarn build - name: BE Build run: | - cd server && cp -rf ../fe/dist http_server - go build -ldflags "-s -w -X 'main.version=${{ env.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 ${{ env.FILENAME }} main.go - go build -ldflags "-s -w" -o ${{ env.TGFILENAME }} hooks/telegram_push/telegram_push.go - go build -ldflags "-s -w" -o ${{ env.WEBFILENAME }} hooks/web_push/web_push.go - go build -ldflags "-s -w" -o ${{ env.WCFILENAME }} hooks/wechat_push/wechat_push.go + cd server && cp -rf ../fe/dist http_server + go build -ldflags "-s -w -X 'main.version=${{ env.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 ${{ env.FILENAME }} main.go + go build -ldflags "-s -w" -o ${{ env.TGFILENAME }} hooks/telegram_push/telegram_push.go + go build -ldflags "-s -w" -o ${{ env.WEBFILENAME }} hooks/web_push/web_push.go + go build -ldflags "-s -w" -o ${{ env.WCFILENAME }} hooks/wechat_push/wechat_push.go + ls -alh + - name: Zip + run: | + cd ./server + mkdir plugins + mv ${{ env.TGFILENAME }} plugins/ + mv ${{ env.WEBFILENAME }} plugins/ + mv ${{ env.WCFILENAME }} plugins/ + zip -r ${{ env.ZIPNAME }}.zip ${{ env.FILENAME }} plugins + ls - name: Upload files to Artifacts uses: actions/upload-artifact@v3 with: - name: ${{ env.FILENAME }} - path: | - ./server/${{ env.FILENAME }} - ./server/${{ env.TGFILENAME }} - ./server/${{ env.WEBFILENAME }} - ./server/${{ env.WCFILENAME }} + name: ${{ env.ZIPNAME }} + path: server/${{ env.ZIPNAME }}.zip - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: | - ./server/${{ env.FILENAME }} - ./server/${{ env.TGFILENAME }} - ./server/${{ env.WEBFILENAME }} - ./server/${{ env.WCFILENAME }} + file: server/${{ env.ZIPNAME }}.zip tag: ${{ github.ref }} - file_glob: true + file_glob: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 508ec75e..57259fe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,10 +14,10 @@ COPY server . COPY --from=febuild /work/dist /work/http_server/dist RUN apk update && apk add git -RUN go build -ldflags "-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 main.go -RUN cd /work/hooks/web_push && go build -ldflags "-s -W" -o output/web_push main.go -RUN cd /work/hooks/wechat_push && go build -ldflags "-s -W" -o output/wechat_push main.go +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 cd /work/hooks/telegram_push && go build -ldflags "-s -w" -o output/telegram_push main.go +RUN cd /work/hooks/web_push && go build -ldflags "-s -w" -o output/web_push main.go +RUN cd /work/hooks/wechat_push && go build -ldflags "-s -w" -o output/wechat_push main.go FROM alpine diff --git a/DockerfileGithubAction b/DockerfileGithubAction index 3562eecc..3150d014 100644 --- a/DockerfileGithubAction +++ b/DockerfileGithubAction @@ -1,14 +1,14 @@ 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 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 +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 FROM alpine @@ -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 704e9916..42984411 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/hooks/base.go b/server/hooks/base.go index 2aa68e21..08dd6268 100644 --- a/server/hooks/base.go +++ b/server/hooks/base.go @@ -142,7 +142,7 @@ func Init() { pluginNo := 1 filepath.Walk(root, func(path string, info os.FileInfo, err error) error { - if info != nil && !info.IsDir() && !strings.Contains(info.Name(), ".") { + if info != nil && !info.IsDir() && (!strings.Contains(info.Name(), ".") || strings.Contains(info.Name(), ".exe")) { socketPath := fmt.Sprintf("%s/%d.socket", root, pluginNo) diff --git a/server/main.go b/server/main.go index 569f7f90..8a2edefe 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)