ci: 为GitHub与Gitea(PCUX)创建自动化编译发布工作流并更新README文档
This commit is contained in:
parent
78fa1cd796
commit
3eaa52c212
128
.gitea/workflows/release.yml
Normal file
128
.gitea/workflows/release.yml
Normal file
@ -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
|
||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -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
|
||||
|
||||
|
||||
11
README.md
11
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
|
||||
|
||||
13
README_CN.md
13
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
|
||||
|
||||
部署包中内置了最新完整编译的前端资源与插件,解压即可运行。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user