feat: 修复oadin-app启动问题 #432
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build App on Self-Hosted Runners | |
| on: | |
| push: | |
| tags: | |
| - '*' # 仅在版本标签推送时触发 | |
| env: | |
| CI_COMMIT_TAG: "${{ github.ref_name }}" | |
| MAC_FILE_NAME: "oadin-installer-${{ github.ref_name }}.pkg" | |
| WIN_FILE_NAME: "oadin-installer-${{ github.ref_name }}.exe" | |
| NEXUS_HOST_PORT: ${{ secrets.NEXUS_HOST_PORT }} | |
| NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} | |
| NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} | |
| HOOK_BRIDGE_URL: ${{ secrets.HOOK_BRIDGE_URL }} | |
| PROJECT_FLAG: ${{ secrets.PROJECT_FLAG }} | |
| jobs: | |
| build-mac: | |
| name: Build macOS App | |
| runs-on: [ self-hosted, macOS, ARM64 ] # 匹配 aiwenxuedeMac-mini | |
| steps: | |
| - name: Set ENV based on tag | |
| run: | | |
| if [[ "${{ github.ref_name }}" == test* ]]; then | |
| echo "ENV=development" >> $GITHUB_ENV | |
| else | |
| echo "ENV=production" >> $GITHUB_ENV | |
| fi | |
| - name: Run build script on Mac | |
| run: | | |
| echo "$ENV" | |
| echo "========== 🔧 Mac Build Begin ==========" | |
| echo "--------- 🧹 清除旧文件 准备纯净环境 ----------" | |
| cd /Users/dcone/WebstormProjects/oadin/ | |
| git reset --hard | |
| git clean -fd | |
| echo "--------- 🔖 拉取代码准备构建 ----------" | |
| git fetch | |
| echo $CI_COMMIT_TAG ; git checkout $CI_COMMIT_TAG | |
| echo "--------- 🛠️ 制品构建与签名 ----------" | |
| go mod tidy | |
| # 清理可能存在的旧二进制文件和目录 | |
| rm -f oadin oadin-app oadin.pkg | |
| rm -rf pkgroot upload | |
| echo "$ENV active" | |
| echo "=== 构建参数 ===" | |
| echo "CGO_ENABLED=1" | |
| echo "GOOS=darwin" | |
| echo "GOARCH=arm64" | |
| echo "Tags: $ENV" | |
| echo "LDFLAGS: -s -w" | |
| CGO_ENABLED=1 CGO_CFLAGS="-I$PWD\internal\datastore\sqlite\sqlite-vec" GOOS=darwin GOARCH=arm64 go build -o oadin -tags "$ENV" -ldflags="-s -w -X 'oadin/version.OadinSubVersion=$CI_COMMIT_TAG'" cmd/cli/main.go | |
| CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o oadin-app -tags "$ENV" -ldflags="-s -w -X 'oadin/version.OadinSubVersion=$CI_COMMIT_TAG'" trayapp/main.go | |
| echo "=== 二进制分析 ===" | |
| file oadin | |
| echo "符号表大小分析:" | |
| go tool nm -size oadin 2>/dev/null | head -10 || echo "符号表已被strip" | |
| codesign --verbose --force --timestamp --options=runtime --sign "Developer ID Application: Digital China (China) Limited (US7ZG73N89)" oadin | |
| # 签名托盘程序 | |
| codesign --verbose --force --timestamp --options=runtime --sign "Developer ID Application: Digital China (China) Limited (US7ZG73N89)" oadin-app | |
| echo "--------- 📦 创建 .app 应用程序包 ----------" | |
| chmod +x installer/mac/create-app.sh | |
| installer/mac/create-app.sh | |
| # 签名 .app | |
| codesign --verbose --force --timestamp --options=runtime --sign "Developer ID Application: Digital China (China) Limited (US7ZG73N89)" "Oadin.app" | |
| echo "--------- 📦 安装包构建与签名 ----------" | |
| # 确保完全清理 pkgroot 目录 | |
| rm -rf pkgroot | |
| # 使用正确的目录名称,确保一致性 | |
| mkdir -p pkgroot/Oadin | |
| mv Oadin.app pkgroot/Oadin/Oadin.app | |
| chmod +x installer/mac/preinstall | |
| chmod +x installer/mac/postinstall | |
| chmod +x installer/mac/uninstall | |
| # 添加文件大小检查 | |
| echo "=== Mac 二进制文件详细信息 ===" | |
| # echo "二进制文件大小: $(du -h pkgroot/Oadin/oadin | cut -f1)" | |
| # echo "二进制文件大小(字节): $(stat -f%z pkgroot/Oadin/oadin)" | |
| echo "pkgroot目录内容:" | |
| ls -la pkgroot/Oadin/ | |
| # 确保只包含我们想要的文件 | |
| echo "pkgroot目录总大小: $(du -sh pkgroot | cut -f1)" | |
| pkgbuild --identifier com.digitalchina.oadin --version "${CI_COMMIT_TAG}" --install-location /Applications --sign "Developer ID Installer: Digital China (China) Limited (US7ZG73N89)" --root pkgroot/Oadin --scripts ./installer/mac oadin.pkg | |
| echo "安装包大小: $(du -h oadin.pkg | cut -f1)" | |
| echo "--------- 📬 安装包公证 ----------" | |
| xcrun notarytool store-credentials "ci-profile" --apple-id "$APPLE_ID" --team-id "$APPLE_TEAM_ID" --password "$APPLE_APP_SPECIFIC_PASSWORD" | |
| xcrun notarytool submit oadin.pkg --keychain-profile "ci-profile" --wait | |
| echo "--------- 📎 附加公证票据 ----------" | |
| xcrun stapler staple oadin.pkg | |
| echo "--------- 🔎️ 验签 ----------" | |
| spctl --assess --type install --verbose=4 oadin.pkg | |
| echo "--------- 📁 移动到待上传文件夹 ----------" | |
| mkdir -p upload | |
| mv oadin.pkg upload/${MAC_FILE_NAME} | |
| echo "========== 🔧 Mac Build End ==========" | |
| - name: upload nexus | |
| if: startsWith(github.ref_name, 'test') | |
| run: | | |
| echo "========== 🔧 Mac Upload Begin ==========" | |
| echo "-------- 📤 上传到 Nexus 私服 --------" | |
| curl -v -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" --upload-file "/Users/dcone/WebstormProjects/oadin/upload/${MAC_FILE_NAME}" "http://${NEXUS_HOST_PORT}/repository/raw-hosted/intel-ai-pc/oadin/dist/mac/${MAC_FILE_NAME}" | |
| curl -v -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" --upload-file "/Users/dcone/WebstormProjects/oadin/upload/${MAC_FILE_NAME}" "http://${NEXUS_HOST_PORT}/repository/raw-hosted/intel-ai-pc/oadin/dist/mac/oadin-installer-latest.pkg" | |
| echo "========== 🔧 Mac Upload End ==========" | |
| - name: upload oss | |
| if: ${{ !startsWith(github.ref_name, 'test') }} | |
| run: | | |
| echo "========== 🔧 Mac Upload Begin ==========" | |
| echo "-------- 📤 上传到 阿里云 OSS --------" | |
| cd /Users/dcone/WebstormProjects/oadin/upload | |
| ossutil cp "${MAC_FILE_NAME}" "oss://smartvision-aipc/oadin/dist/macos/${MAC_FILE_NAME}" --force | |
| ossutil cp "${MAC_FILE_NAME}" "oss://smartvision-aipc/oadin/dist/macos/oadin-installer-latest.pkg" --force | |
| echo "--------- 🧹 环境清理 ----------" | |
| git reset --hard | |
| git clean -fd | |
| echo "--------- 🗑️ 删除本地tag ----------" | |
| git checkout main | |
| git tag -d $CI_COMMIT_TAG | |
| echo "--------- ♻️ 刷新CND ----------" | |
| aliyun cdn RefreshObjectCaches --ObjectPath "https://oss-aipc.dcclouds.com/oadin/dist/macos/oadin-installer-latest.pkg" --ObjectType File | |
| echo "========== 🔧 Mac Upload End ==========" | |
| build-win: | |
| name: Build Windows App | |
| runs-on: [ self-hosted, Windows, X64 ] # 匹配 WIN-P1B0AOCK993 | |
| steps: | |
| - name: Set ENV based on tag | |
| shell: powershell | |
| run: | | |
| if ("${{ github.ref_name }}" -like "test*") { | |
| "ENV=development" >> $env:GITHUB_ENV | |
| } else { | |
| "ENV=production" >> $env:GITHUB_ENV | |
| } | |
| - name: Run build script on Windows | |
| run: | | |
| echo "========== 🔧 Win Build Begin ==========" | |
| echo "--------- 🧹 清除旧文件 准备纯净环境 ----------" | |
| cd C:\Users\Administrator\WebstormProjects\oadin | |
| git reset --hard | |
| git clean -fd | |
| echo "--------- 🔖 拉取代码准备构建 ----------" | |
| git fetch | |
| echo $env:CI_COMMIT_TAG ; git checkout $env:CI_COMMIT_TAG | |
| echo "--------- 🛠️ 制品构建与签名 ----------" | |
| go env -w GOPROXY=https://goproxy.cn,direct | |
| go mod tidy | |
| # 清理可能存在的旧二进制文件 | |
| Remove-Item -Path "oadin.exe" -Force -ErrorAction SilentlyContinue | |
| Remove-Item -Path "oadin-installer.exe" -Force -ErrorAction SilentlyContinue | |
| $env:CGO_ENABLED= 1 | |
| $env:GOOS= "windows" | |
| $env:GOARCH= "amd64" | |
| $env:CGO_CFLAGS= "-I$PWD\internal\datastore\sqlite\sqlite-vec" | |
| echo "=== 构建参数 ===" | |
| echo "CGO_ENABLED: $($env:CGO_ENABLED)" | |
| echo "GOOS: $($env:GOOS)" | |
| echo "GOARCH: $($env:GOARCH)" | |
| echo "Tags: $($env:ENV)" | |
| echo "LDFLAGS: -s -w" | |
| go build -o oadin.exe -tags "$env:ENV" -ldflags="-s -w -X 'oadin/version.OadinSubVersion=$env:CI_COMMIT_TAG'" cmd/cli/main.go | |
| go build -o oadin-app.exe -tags "$env:ENV" -ldflags="-s -w -X 'oadin/version.OadinSubVersion=$CI_COMMIT_TAG' -H=windowsgui" trayapp/main.go | |
| # 添加详细的文件大小检查 | |
| echo "=== Windows 二进制文件详细信息 ===" | |
| Get-ChildItem -Path "oadin.exe" | Format-Table Name, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}}, Length -AutoSize | |
| echo "二进制文件大小(字节): $((Get-Item 'oadin.exe').Length)" | |
| signtool sign /f C:\Users\Administrator\Desktop\u.cer /tr http://timestamp.digicert.com /td sha256 /fd sha256 /csp "eToken Base Cryptographic Provider" /k "[{{$($WIN_SIGN_PASSWORD)}}]=p11#942acfc7f5754f2e" "oadin.exe" | |
| signtool sign /f C:\Users\Administrator\Desktop\u.cer /tr http://timestamp.digicert.com /td sha256 /fd sha256 /csp "eToken Base Cryptographic Provider" /k "[{{$($WIN_SIGN_PASSWORD)}}]=p11#942acfc7f5754f2e" "oadin-app.exe" | |
| echo "--------- 📦 安装包构建与签名 ----------" | |
| echo "使用CI兼容的64位NSIS脚本..." | |
| makensis.exe -DVERSION=$env:CI_COMMIT_TAG installer\win\oadin-ci.nsi | |
| signtool sign /f C:\Users\Administrator\Desktop\u.cer /tr http://timestamp.digicert.com /td sha256 /fd sha256 /csp "eToken Base Cryptographic Provider" /k "[{{$($WIN_SIGN_PASSWORD)}}]=p11#942acfc7f5754f2e" "oadin-installer.exe" | |
| # 检查安装包大小 | |
| echo "安装包信息:" | |
| Get-ChildItem -Path "oadin-installer.exe" | Format-Table Name, Length -AutoSize | |
| echo "--------- 📁 移动到待上传文件夹 ----------" | |
| New-Item -ItemType Directory -Path "upload" -Force | |
| Move-Item -Path "oadin-installer.exe" -Destination "upload\$($env:WIN_FILE_NAME)" -Force | |
| echo "========== 🔧 Win Build End ==========" | |
| - name: upload nexus | |
| if: startsWith(github.ref_name, 'test') | |
| run: | | |
| echo "========== 🔧 Win Upload Begin ==========" | |
| echo "-------- 📤 上传到 Nexus 私服 --------" | |
| cd C:\Users\Administrator\WebstormProjects\oadin | |
| curl.exe -v -u "$($env:NEXUS_USERNAME):$($env:NEXUS_PASSWORD)" --upload-file "upload/$($env:WIN_FILE_NAME)" "http://$($env:NEXUS_HOST_PORT)/repository/raw-hosted/intel-ai-pc/oadin/dist/win/$($env:WIN_FILE_NAME)" | |
| curl.exe -v -u "$($env:NEXUS_USERNAME):$($env:NEXUS_PASSWORD)" --upload-file "upload/$($env:WIN_FILE_NAME)" "http://$($env:NEXUS_HOST_PORT)/repository/raw-hosted/intel-ai-pc/oadin/dist/win/oadin-installer-latest.exe" | |
| echo "========== 🔧 Win Upload End ==========" | |
| - name: upload oss | |
| if: ${{ !startsWith(github.ref_name, 'test') }} | |
| run: | | |
| echo "========== 🔧 Win Upload Begin ==========" | |
| echo "-------- 📤 上传到 阿里云 OSS --------" | |
| cd C:\Users\Administrator\WebstormProjects\oadin | |
| ossutil cp "upload/$($env:WIN_FILE_NAME)" "oss://smartvision-aipc/oadin/dist/windows/$($env:WIN_FILE_NAME)" --force | |
| ossutil cp "upload/$($env:WIN_FILE_NAME)" "oss://smartvision-aipc/oadin/dist/windows/oadin-installer-latest.exe" --force | |
| echo "--------- 🧹 环境清理 ----------" | |
| git reset --hard | |
| git clean -fd | |
| echo "--------- 🗑️ 删除本地tag ----------" | |
| git checkout main | |
| git tag -d $env:CI_COMMIT_TAG | |
| echo "--------- ♻️ 刷新CDN ----------" | |
| aliyun cdn RefreshObjectCaches --ObjectPath "https://oss-aipc.dcclouds.com/oadin/dist/windows/oadin-installer-latest.exe" --ObjectType File | |
| echo "========== 🔧 Win Upload End ==========" | |
| notify-feishu: | |
| name: Notify Feishu | |
| runs-on: [ self-hosted, macOS, ARM64 ] | |
| needs: | |
| - build-mac | |
| - build-win | |
| steps: | |
| - name: Notify Feishu | |
| run: | | |
| echo "--------- 📬 发布通知 ----------" | |
| cd /Users/dcone/WebstormProjects/oadin | |
| sh scripts/release-notice.sh | |
| echo "--------- 🧹 环境清理 ----------" | |
| cd /Users/dcone/WebstormProjects/oadin | |
| git reset --hard | |
| git clean -fd | |
| echo "--------- 🗑️ 删除本地tag ----------" | |
| git checkout main | |
| git tag -d $CI_COMMIT_TAG |