release.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - 'v*'
  6. jobs:
  7. release:
  8. strategy:
  9. fail-fast: false
  10. matrix:
  11. include:
  12. - os: windows-latest
  13. platform: win
  14. - os: macos-latest
  15. platform: mac
  16. - os: ubuntu-latest
  17. platform: linux
  18. runs-on: ${{ matrix.os }}
  19. steps:
  20. - name: Checkout code
  21. uses: actions/checkout@v4
  22. - name: Setup Node.js
  23. uses: actions/setup-node@v4
  24. with:
  25. node-version: '20'
  26. cache: 'npm'
  27. - name: Extract version from tag
  28. id: version
  29. shell: bash
  30. run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
  31. - name: Update package.json version
  32. shell: bash
  33. run: |
  34. npm pkg set version=${{ steps.version.outputs.VERSION }}
  35. - name: Install dependencies
  36. run: npm ci
  37. - name: Type check
  38. run: npm run typecheck
  39. - name: Build frontend
  40. run: npx vite build
  41. - name: Package application
  42. run: npx electron-builder --${{ matrix.platform }}
  43. env:
  44. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  45. - name: Build portable version with launcher (Windows only)
  46. if: matrix.platform == 'win'
  47. shell: pwsh
  48. run: |
  49. # Build launcher
  50. npx pkg launcher/launcher.js --target node18-win-x64 --output release/launcher.exe
  51. # Find portable exe
  52. $portableExe = Get-ChildItem -Path release -Filter "*portable*.exe" | Select-Object -First 1
  53. if (-not $portableExe) {
  54. Write-Error "Portable exe not found"
  55. exit 1
  56. }
  57. $version = "${{ steps.version.outputs.VERSION }}"
  58. $portableDirName = "Claude-AI-Installer-$version-portable"
  59. $portableDir = "release/$portableDirName"
  60. # Create directory structure
  61. New-Item -ItemType Directory -Force -Path "$portableDir/app"
  62. New-Item -ItemType Directory -Force -Path "$portableDir/update"
  63. # Copy files
  64. Copy-Item "release/launcher.exe" "$portableDir/Claude-AI-Installer.exe"
  65. Copy-Item $portableExe.FullName "$portableDir/app/Claude-AI-Installer-$version.exe"
  66. # Create README
  67. @"
  68. Claude AI Installer - Portable 版本
  69. 使用方法:
  70. 1. 双击 Claude-AI-Installer.exe 启动程序
  71. 2. 程序会自动检查更新
  72. 3. 更新下载后,重启程序即可完成更新
  73. 目录说明:
  74. - Claude-AI-Installer.exe: 启动器
  75. - app/: 主程序目录
  76. - update/: 更新文件临时目录
  77. 版本: $version
  78. "@ | Out-File -FilePath "$portableDir/README.txt" -Encoding UTF8
  79. # Create ZIP
  80. Compress-Archive -Path "$portableDir/*" -DestinationPath "release/$portableDirName.zip" -Force
  81. - name: Upload release assets
  82. uses: softprops/action-gh-release@v2
  83. with:
  84. files: |
  85. release/*.exe
  86. release/*.dmg
  87. release/*.zip
  88. release/*.AppImage
  89. release/*.deb
  90. release/*.rpm
  91. release/*.yml
  92. release/*.yaml
  93. draft: false
  94. prerelease: false
  95. env:
  96. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}