From 3eaa52c212542e3e28b9ecaedb57fd04df1650e8 Mon Sep 17 00:00:00 2001 From: smail Date: Sun, 18 Oct 2026 14:58:23 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=B8=BAGitHub=E4=B8=8EGitea(PCUX)?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=87=AA=E5=8A=A8=E5=8C=96=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0README=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/release.yml | 128 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 4 +- README.md | 11 +++ README_CN.md | 13 ++++ 4 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 00000000..7067c109 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,128 @@ +name: Build and Release + +on: + workflow_dispatch: + release: + types: [ released,prereleased ] + + +jobs: + build: + needs: security + permissions: + contents: write + strategy: + matrix: + goos: [ windows, linux, darwin ] + goarch: [ amd64, arm64 ] + runs-on: ubuntu-latest + env: + CGO_ENABLED: 0 + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + steps: + - name: Get version + id: get_version + run: | + echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + echo "${GITHUB_REF}" + - name: Checkout + uses: actions/checkout@v6 + - name: Setup Node.js environment + uses: actions/setup-node@v6 + with: + node-version: 24 + - name: Install Dependencies + run: npm install --global yarn@1.22.22 + - name: Setup Go environment + uses: actions/setup-go@v6 + with: + go-version: '1.26.9' + cache-dependency-path: backend/go.sum + - name: Gen output name + run: | + archive_extension="tar.gz" + if [ "${{ matrix.goos }}" = "windows" ]; then archive_extension="zip"; fi + echo "PACKAGENAME=Smail_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV} + echo "ARCHIVENAME=Smail_${{ matrix.goos }}_${{ matrix.goarch }}.$archive_extension" >> ${GITHUB_ENV} + - name: FE Build + run: cd frontend && yarn install --frozen-lockfile && yarn build + - name: BE Build + run: | + mkdir -p out/backend + cd plugins/pmail_telegram_push + npm ci + npm run type-check + cd ../.. + node deploy/build-plugins.mjs --target=${{ matrix.goos }}_${{ matrix.goarch }} + node deploy/bundle-plugins.mjs ${{ matrix.goos }}_${{ matrix.goarch }} + extension="" + if [ "${{ matrix.goos }}" = "windows" ]; then extension=".exe"; fi + platform="${{ matrix.goos }}" + if [ "$platform" = "darwin" ]; then platform="mac"; fi + suffix="${platform}_${{ matrix.goarch }}${extension}" + cd backend + BUILD_FLAGS="-s -w -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.Version=${{ env.VERSION }}' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GoVersion=$(go env GOVERSION)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GitHash=$(git show -s --format=%H)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + go build -tags bundled -trimpath -ldflags "$BUILD_FLAGS" -o ../out/backend/smail_$suffix ./cmd/smail + go build -trimpath -ldflags "$BUILD_FLAGS" -o ../out/backend/smail-admin_$suffix ./cmd/smail-admin + go build -trimpath -ldflags "$BUILD_FLAGS" -o ../out/backend/smail-config_$suffix ./cmd/smail-config + - name: Package release + run: | + SMAIL_VERSION="${{ env.VERSION }}" GIT_HASH="$(git show -s --format=%H)" node deploy/package.mjs ${{ matrix.goos }}_${{ matrix.goarch }} + - name: Upload files to Artifacts + uses: actions/upload-artifact@v6 + with: + name: ${{ env.PACKAGENAME }} + path: out/release/*${{ matrix.goos }}_${{ matrix.goarch }}* + - name: Upload binaries to release + uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: out/release/*${{ matrix.goos }}_${{ matrix.goarch }}* + tag: ${{ github.ref }} + file_glob: true + + security: + permissions: + contents: read + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Setup Go environment + uses: actions/setup-go@v6 + with: + go-version: '1.26.9' + cache-dependency-path: backend/go.sum + - name: Setup Node.js for test runner + uses: actions/setup-node@v6 + with: + node-version: 24 + - name: Prepare frontend and Go embedded assets + run: | + npm install --global yarn@1.22.22 + cd frontend + yarn install --frozen-lockfile + yarn test + yarn build + - name: Verify Go dependencies + run: cd backend && go mod verify + - name: Run Go tests + run: node test/run.mjs backend + - name: Run Go static analysis + run: cd backend && go vet ./... + - name: Run Go race tests + run: node test/run.mjs backend -race ./... + - name: Run Go security analysis + run: | + go install github.com/securego/gosec/v2/cmd/gosec@v2.22.10 + cd backend && gosec ./... + - name: Scan Go vulnerabilities + run: | + go install golang.org/x/vuln/cmd/govulncheck@v1.7.0 + cd backend && govulncheck ./... + - name: Verify frontend dependencies and lint + run: | + cd frontend + yarn audit --groups dependencies + yarn eslint . --ext .vue,.js,.jsx,.cjs,.mjs --ignore-path .gitignore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04b41d5b..7067c109 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,12 +73,12 @@ jobs: uses: actions/upload-artifact@v6 with: name: ${{ env.PACKAGENAME }} - path: out/release/${{ env.ARCHIVENAME }} + path: out/release/*${{ matrix.goos }}_${{ matrix.goarch }}* - name: Upload binaries to release uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: out/release/${{ env.ARCHIVENAME }} + file: out/release/*${{ matrix.goos }}_${{ matrix.goarch }}* tag: ${{ github.ref }} file_glob: true diff --git a/README.md b/README.md index 2bb98d5a..93cece7b 100644 --- a/README.md +++ b/README.md @@ -164,3 +164,14 @@ IMAP端口: 993(SSL) [go to wiki](https://git.pcux.cn/xuans/Smail/wiki/%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%E8%AF%B4%E6%98%8E) + +## Releases & CI/CD Workflows + +The project maintains automated build & release workflows across both repositories: +- **GitHub**: [https://github.com/xuanspark/Smail.git](https://github.com/xuanspark/Smail.git) +- **PCUX Git**: [https://git.pcux.cn/xuans/Smail.git](https://git.pcux.cn/xuans/Smail.git) + +Automated multi-platform release packages (containing full frontend & embedded assets): +- **Linux**: Smail_linux_amd64.tar.gz / Smail_linux_arm64.tar.gz +- **Windows**: Smail_windows_amd64.zip / Smail_windows_arm64.zip +- **macOS**: Smail_darwin_amd64.tar.gz / Smail_darwin_arm64.tar.gz diff --git a/README_CN.md b/README_CN.md index f9bf49fe..8c86724f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -284,3 +284,16 @@ curl --fail --silent --show-error \ ### PMail 原版无法登录的结论 PMail 原版不能作为当前 Smail 的第三方协议登录测试客户端。它的旧登录流程会截断包含 `@` 的登录名,没有 Smail 的协议开关和授权码模型,并且按网页登录密码校验;Smail 则要求“完整邮箱地址 + 对应协议授权码”。因此,把 Smail 的授权码填入 PMail 原版后登录失败属于兼容性限制,不应通过接受短账号名或网页登录密码来规避。 + +## 发布包与持续集成 + +项目同时在以下代码仓库维护并提供自动化编译发布工作流: +- **GitHub**: [https://github.com/xuanspark/Smail.git](https://github.com/xuanspark/Smail.git) +- **PCUX Git**: [https://git.pcux.cn/xuans/Smail.git](https://git.pcux.cn/xuans/Smail.git) + +每次发布(Release)时,工作流将自动并行编译并打包以下全平台架构部署包: +- **Linux**: Smail_linux_amd64.tar.gz / Smail_linux_arm64.tar.gz +- **Windows**: Smail_windows_amd64.zip / Smail_windows_arm64.zip +- **macOS**: Smail_darwin_amd64.tar.gz / Smail_darwin_arm64.tar.gz + +部署包中内置了最新完整编译的前端资源与插件,解压即可运行。