From 80b6973991716bd10d7b1c3739cae8a36a837932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 15:57:37 +0800 Subject: [PATCH 1/8] action build --- .github/workflows/docker_build.yml | 44 +++++++++++++++++ .github/workflows/release.yml | 77 +++++++++++++++++------------- 2 files changed, 88 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/docker_build.yml diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml new file mode 100644 index 0000000..f616a1c --- /dev/null +++ b/.github/workflows/docker_build.yml @@ -0,0 +1,44 @@ +name: Docker Image CI + +on: + push: + tags: + - "*" + +env: + REGISTRY: ghcr.io + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Get version + id: get_version + run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> ${GITHUB_ENV} + + - uses: actions/checkout@v3 + + - name: set lower case repository name + run: | + echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV} + env: + REPOSITORY: '${{ github.repository }}' + + - name: Log in to the Container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker images + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.REPOSITORY_LC }}:${{ env.VERSION }} + ${{ env.REGISTRY }}/${{ env.REPOSITORY_LC }}:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f616a1c..337e4c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,44 +1,55 @@ -name: Docker Image CI +name: Build and Release on: - push: - tags: - - "*" - -env: - REGISTRY: ghcr.io + workflow_dispatch: + release: + types: [published] + jobs: - build-and-push-image: - runs-on: ubuntu-latest + build: permissions: - contents: read - packages: write + contents: write + strategy: + matrix: + goos: [windows, linux, darwin] + goarch: [amd64, arm64, 386] + exclude: + - goos: darwin + goarch: 386 + runs-on: ubuntu-latest steps: - name: Get version id: get_version - run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> ${GITHUB_ENV} - - - uses: actions/checkout@v3 - - - name: set lower case repository name + run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Checkout + uses: actions/checkout@v4.0.0 + - name: Setup Node.js environment + uses: actions/setup-node@v3.8.1 + - name: Install Dependencies + run: npm install --global yarn + - name: Setup Go environment + uses: actions/setup-go@v4.1.0 + - name: Gen output name + run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + - name: Rename Windows File + if: matrix.goos == 'windows' + run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} + - name: FE Build + run: cd fe && yarn && yarn build + - name: BE Build run: | - echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV} - env: - REPOSITORY: '${{ github.repository }}' - - - name: Log in to the Container registry - uses: docker/login-action@v2.1.0 + cd server && cp -rf ../fe/dist http_server + CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} 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 ${{ env.FILENAME }} main.go + - name: Upload files to Artifacts + uses: actions/upload-artifact@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker images - uses: docker/build-push-action@v4 + name: ${{ env.FILENAME }} + path: ./output/${{ env.FILENAME }} + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 with: - context: . - push: true - tags: | - ${{ env.REGISTRY }}/${{ env.REPOSITORY_LC }}:${{ env.VERSION }} - ${{ env.REGISTRY }}/${{ env.REPOSITORY_LC }}:latest + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./output/${{ env.FILENAME }} + tag: ${{ github.ref }} + file_glob: true From bb0eefe4e3a6a04690053bc2dd46a1ef7beedd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 16:27:26 +0800 Subject: [PATCH 2/8] fix --- .github/workflows/release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 337e4c3..0b64ab8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,10 @@ jobs: - goos: darwin goarch: 386 runs-on: ubuntu-latest + env: + CGO_ENABLED: 0 + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} steps: - name: Get version id: get_version @@ -40,7 +44,7 @@ jobs: - name: BE Build run: | cd server && cp -rf ../fe/dist http_server - CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} 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 ${{ env.FILENAME }} main.go + 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 ${{ env.FILENAME }} main.go - name: Upload files to Artifacts uses: actions/upload-artifact@v3 with: From 8652242cee5e24325ac20781aff29039eff7228d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 16:31:45 +0800 Subject: [PATCH 3/8] fix --- .github/workflows/docker_build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index f616a1c..a52a97c 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -1,9 +1,9 @@ name: Docker Image CI on: - push: - tags: - - "*" + workflow_dispatch: + release: + types: [published] env: REGISTRY: ghcr.io From 4f25512ba48e5f9b3e4c9ae55c4a416916cf15ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 16:35:09 +0800 Subject: [PATCH 4/8] fix --- .github/workflows/docker_build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index a52a97c..fd9a4fc 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -3,7 +3,7 @@ name: Docker Image CI on: workflow_dispatch: release: - types: [published] + types: [released] env: REGISTRY: ghcr.io diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b64ab8..84f84d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Build and Release on: workflow_dispatch: release: - types: [published] + types: [released] jobs: From 821ed290510da6b1808f6c7f3a043c17671cbf2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 16:37:02 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E7=A7=BB=E9=99=A432=E4=BD=8Dcpu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84f84d7..7443b5a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,10 +13,7 @@ jobs: strategy: matrix: goos: [windows, linux, darwin] - goarch: [amd64, arm64, 386] - exclude: - - goos: darwin - goarch: 386 + goarch: [amd64, arm64] runs-on: ubuntu-latest env: CGO_ENABLED: 0 From 78fd5ede6ce779917d7504f341383cb84d91b843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 16:43:42 +0800 Subject: [PATCH 6/8] fix --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7443b5a..529bdfa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,11 +46,11 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ env.FILENAME }} - path: ./output/${{ env.FILENAME }} + path: ./server/${{ env.FILENAME }} - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./output/${{ env.FILENAME }} + file: ./server/${{ env.FILENAME }} tag: ${{ github.ref }} file_glob: true From 33ca19e9da743c05a111120a9406e1861026f878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 16:53:13 +0800 Subject: [PATCH 7/8] fix --- .github/workflows/release.yml | 4 ++-- server/config/config.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 529bdfa..ed8c363 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,10 +32,10 @@ jobs: - name: Setup Go environment uses: actions/setup-go@v4.1.0 - name: Gen output name - run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + run: echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} - name: Rename Windows File if: matrix.goos == 'windows' - run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} + run: echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV} - name: FE Build run: cd fe && yarn && yarn build - name: BE Build diff --git a/server/config/config.go b/server/config/config.go index 8280b0e..a138681 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -38,7 +38,7 @@ type Config struct { //go:embed tables/* var tableConfig embed.FS -const Version = "2.2.2" +const Version = "2.2.5" const DBTypeMySQL = "mysql" const DBTypeSQLite = "sqlite" From e823ae70280e6fbb694237ac108c56fe069a4f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9C=A8=E7=9A=84=E6=9C=A8=E5=A4=B4?= Date: Tue, 12 Sep 2023 17:37:20 +0800 Subject: [PATCH 8/8] port desc --- README.md | 3 +++ README_CN.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index ad9ce27..3379164 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ Or `docker run -p 25:25 -p 80:80 -p 443:443 -p 465:465 -v $(pwd)/config:/work/config ghcr.io/jinnrry/pmail:latest` +> [!IMPORTANT] +> If your server has a firewall turned on, you need to open ports 25, 80, and 443. + ## 3、Configuration Open `http://127.0.0.1` in your browser or use your server's public IP to visit, then follow the instructions to diff --git a/README_CN.md b/README_CN.md index 8cd65ea..f07564a 100644 --- a/README_CN.md +++ b/README_CN.md @@ -59,6 +59,9 @@ PMail是一个追求极简部署流程、极致资源占用的个人域名邮箱 `docker run -p 25:25 -p 80:80 -p 443:443 -p 465:465 -v $(pwd)/config:/work/config ghcr.io/jinnrry/pmail:latest` +> [!IMPORTANT] +> 如果你服务器开启了防火墙,你需要放行25、80、443这三个端口 + ## 3、配置 浏览器打开 `http://127.0.0.1` 或者是用你服务器公网IP访问,然后按提示配置