build.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. if: startsWith(github.ref, 'refs/tags/')
  75. steps:
  76. - name: Download all artifacts
  77. uses: actions/download-artifact@v4
  78. with:
  79. path: artifacts
  80. - name: Display structure of downloaded files
  81. run: ls -R artifacts
  82. - name: Create Release
  83. uses: softprops/action-gh-release@v1
  84. with:
  85. files: |
  86. artifacts/CursorPro-Windows/CursorPro.exe
  87. artifacts/CursorPro-MacOS-ARM64/CursorPro
  88. artifacts/CursorPro-Linux/CursorPro
  89. env:
  90. GITHUB_TOKEN: ${{ secrets.TOKEN }}