build.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. name: Build Executables
  2. on:
  3. push:
  4. branches: [ "main", "master" ] # 只在主分支推送时触发
  5. tags:
  6. - 'v*' # 添加标签触发条件,匹配 v1.0.0 这样的标签
  7. jobs:
  8. build-windows:
  9. runs-on: windows-latest
  10. steps:
  11. - uses: actions/checkout@v2
  12. - name: Set up Python
  13. uses: actions/setup-python@v2
  14. with:
  15. python-version: '3.x'
  16. - name: Install dependencies
  17. run: |
  18. python -m pip install --upgrade pip
  19. pip install pyinstaller
  20. pip install -r requirements.txt
  21. - name: Build EXE
  22. run: |
  23. pyinstaller CursorKeepAlive.spec
  24. - name: Upload Windows artifact
  25. uses: actions/upload-artifact@v4
  26. with:
  27. name: CursorPro-Windows
  28. path: dist/CursorPro.exe
  29. build-macos-arm64:
  30. runs-on: macos-latest
  31. steps:
  32. - uses: actions/checkout@v2
  33. - name: Set up Python
  34. uses: actions/setup-python@v2
  35. with:
  36. python-version: '3.x'
  37. - name: Install dependencies
  38. run: |
  39. python -m pip install --upgrade pip
  40. pip install pyinstaller
  41. pip install -r requirements.txt
  42. - name: Build MacOS ARM executable
  43. run: |
  44. pyinstaller CursorKeepAlive.spec
  45. - name: Upload MacOS ARM artifact
  46. uses: actions/upload-artifact@v4
  47. with:
  48. name: CursorPro-MacOS-ARM64
  49. path: dist/CursorPro
  50. build-linux:
  51. runs-on: ubuntu-latest
  52. steps:
  53. - uses: actions/checkout@v2
  54. - name: Set up Python
  55. uses: actions/setup-python@v2
  56. with:
  57. python-version: '3.x'
  58. - name: Install dependencies
  59. run: |
  60. python -m pip install --upgrade pip
  61. pip install pyinstaller
  62. pip install -r requirements.txt
  63. - name: Build Linux executable
  64. run: |
  65. pyinstaller CursorKeepAlive.spec
  66. - name: Upload Linux artifact
  67. uses: actions/upload-artifact@v4
  68. with:
  69. name: CursorPro-Linux
  70. path: dist/CursorPro
  71. create-release:
  72. needs: [build-windows, build-macos-arm64, build-linux] # 等待其他构建任务完成
  73. runs-on: ubuntu-latest
  74. # 只在推送标签时创建发布
  75. if: startsWith(github.ref, 'refs/tags/')
  76. steps:
  77. - name: Create Release
  78. id: create_release
  79. uses: actions/create-release@v1
  80. env:
  81. GITHUB_TOKEN: ${{ secrets.TOKEN }}
  82. with:
  83. tag_name: ${{ github.ref }}
  84. release_name: Release ${{ github.ref }}
  85. draft: false
  86. prerelease: false
  87. - name: Download all artifacts
  88. uses: actions/download-artifact@v4
  89. - name: Upload Release Assets
  90. uses: softprops/action-gh-release@v1
  91. with:
  92. files: |
  93. CursorPro-Windows/CursorPro.exe
  94. CursorPro-MacOS-ARM64/CursorPro
  95. CursorPro-Linux/CursorPro
  96. env:
  97. GITHUB_TOKEN: ${{ secrets.TOKEN }}