From 7e3cef30dc6a5140e6ee33eaceedcf54aa9ec4e9 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Sat, 9 May 2026 14:53:42 +0800 Subject: [PATCH] =?UTF-8?q?docs(deploy):=20=E6=B7=BB=E5=8A=A0=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E7=9A=84=E9=83=A8=E7=BD=B2=E6=96=87=E6=A1=A3=E5=92=8C?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 compose.production.yaml 和 compose.production.server.yaml 部署配置 - 添加 nginx.dev.xuqinmin.com.conf 和 nginx.sentry.xuqinmin.com.conf 反向代理配置 - 创建详细的部署指南文档 deploy/README.md,涵盖架构设计和部署步骤 - 添加前端访问文档 web/README.md,包含线上地址和接口说明 - 补充平台文档总览 README.md,整合各模块文档入口 - 配置多服务容器化部署,包括 tenant-service、im-service、push-service 等 - 设置外部数据库和 Redis 连接配置,确保服务间正确通信 - 配置 WebSocket 和 API 路由转发规则,支持实时通信和版本更新服务 --- Jenkinsfile | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2e1a9a3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,128 @@ +pipeline { + agent any + + parameters { + string(name: 'BRANCH', defaultValue: 'main', description: 'Git 分支名') + string(name: 'VERSION', defaultValue: '', description: '发布版本号(留空自动递增)') + booleanParam(name: 'RUN_TESTS', defaultValue: true, description: '是否运行单元测试') + booleanParam(name: 'PUBLISH_SPM', defaultValue: true, description: '发布 SPM 版本(打 Git Tag)') + booleanParam(name: 'PUBLISH_PODS', defaultValue: false, description: '发布到 CocoaPods 私有 Spec Repo') + } + + environment { + GIT_URL = 'https://xuqinmin.com/xuqinmin12/XuqmGroup-iOSSDK.git' + SPEC_REPO = 'https://xuqinmin.com/xuqinmin12/xuqm-specs.git' + } + + options { + timeout(time: 30, unit: 'MINUTES') + buildDiscarder(logRotator(numToKeepStr: '20')) + disableConcurrentBuilds() + } + + stages { + stage('Checkout') { + steps { + checkout scm + script { + env.GIT_COMMIT_SHORT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + if (params.VERSION?.trim()) { + env.PUBLISH_VERSION = params.VERSION.trim() + sh "sed -i '' 's/s.version.*= .*/s.version = \"${env.PUBLISH_VERSION}\"/' XuqmSDK.podspec" + } else { + env.PUBLISH_VERSION = sh(script: 'grep "s.version" XuqmSDK.podspec | head -1 | sed "s/.*= *\\"\\(.*\\)\\".*/\\1/"', returnStdout: true).trim() + } + } + } + } + + stage('Build Info') { + steps { + script { + echo "🚀 构建分支: ${params.BRANCH}" + echo "🏷️ 发布版本: ${env.PUBLISH_VERSION}" + echo "🔨 Git Commit: ${env.GIT_COMMIT_SHORT}" + echo "⚠️ 注意:此任务应在 Jenkins2 (https://xuqinmin12.eicp.vip/) 上执行" + } + } + } + + stage('Swift Build') { + steps { + sh 'swift build' + } + } + + stage('Unit Tests') { + when { expression { return params.RUN_TESTS } } + steps { + sh 'swift test 2>&1 | tee test-results.txt' + } + post { + always { + archiveArtifacts artifacts: 'test-results.txt', allowEmptyArchive: true + } + } + } + + stage('Pod Spec Lint') { + when { expression { return params.PUBLISH_PODS } } + steps { + sh 'pod spec lint XuqmSDK.podspec --allow-warnings' + } + } + + stage('Publish SPM (Git Tag)') { + when { + allOf { + branch 'main' + expression { return params.PUBLISH_SPM } + } + } + steps { + withCredentials([usernamePassword(credentialsId: 'gitlab-credentials', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) { + sh """ + git config user.email "jenkins@xuqm.com" + git config user.name "Jenkins CI" + git add XuqmSDK.podspec || true + git diff --cached --quiet || git commit -m "ci: bump version to ${env.PUBLISH_VERSION}" + git tag -f "${env.PUBLISH_VERSION}" + git push https://${GIT_USER}:${GIT_PASS}@xuqinmin.com/xuqinmin12/XuqmGroup-iOSSDK.git HEAD:main --tags + """ + } + } + } + + stage('Publish CocoaPods') { + when { + allOf { + branch 'main' + expression { return params.PUBLISH_PODS } + } + } + steps { + sh """ + pod repo add xuqm-specs ${SPEC_REPO} 2>/dev/null || true + pod repo push xuqm-specs XuqmSDK.podspec --allow-warnings + """ + } + } + } + + post { + success { + script { + echo "✅ iOS SDK v${env.PUBLISH_VERSION} 构建成功 (Commit: ${env.GIT_COMMIT_SHORT})" + if (params.PUBLISH_SPM) { + echo "📦 SPM 版本已发布: ${env.PUBLISH_VERSION}" + } + if (params.PUBLISH_PODS) { + echo "📦 CocoaPods 版本已发布到私有 Spec Repo" + } + } + } + failure { + echo "❌ iOS SDK 构建失败,请检查日志" + } + } +}