build.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. name: Build Executables
  2. on:
  3. push:
  4. tags:
  5. - 'v*' # 添加标签触发条件,匹配 v1.0.0 这样的标签
  6. jobs:
  7. build-windows:
  8. runs-on: windows-latest
  9. steps:
  10. - uses: actions/checkout@v2
  11. - name: Set up Python
  12. uses: actions/setup-python@v2
  13. with:
  14. python-version: '3.x'
  15. - name: Install dependencies
  16. run: |
  17. python -m pip install --upgrade pip
  18. pip install pyinstaller
  19. pip install -r requirements.txt
  20. - name: Build EXE
  21. run: |
  22. pyinstaller CursorKeepAlive.spec
  23. - name: Copy and rename env file
  24. run: |
  25. copy .env.example dist\.env
  26. - name: Upload Windows artifact
  27. uses: actions/upload-artifact@v4
  28. with:
  29. name: CursorPro-Windows
  30. path: dist/CursorPro.exe
  31. build-macos-arm64:
  32. runs-on: macos-latest
  33. steps:
  34. - uses: actions/checkout@v2
  35. - name: Set up Python
  36. uses: actions/setup-python@v2
  37. with:
  38. python-version: '3.x'
  39. - name: Install dependencies
  40. run: |
  41. python -m pip install --upgrade pip
  42. pip install pyinstaller
  43. pip install -r requirements.txt
  44. - name: Build MacOS ARM executable
  45. run: |
  46. pyinstaller CursorKeepAlive.spec
  47. - name: Copy and rename env file
  48. run: |
  49. cp .env.example dist/.env
  50. - name: Upload MacOS ARM artifact
  51. uses: actions/upload-artifact@v4
  52. with:
  53. name: CursorPro-MacOS-ARM64
  54. path: dist/CursorPro
  55. build-linux:
  56. runs-on: ubuntu-22.04
  57. steps:
  58. - uses: actions/checkout@v2
  59. - name: Set up Python
  60. uses: actions/setup-python@v2
  61. with:
  62. python-version: '3.x'
  63. - name: Install dependencies
  64. run: |
  65. python -m pip install --upgrade pip
  66. pip install pyinstaller
  67. pip install -r requirements.txt
  68. - name: Build Linux executable
  69. run: |
  70. pyinstaller CursorKeepAlive.spec
  71. - name: Copy and rename env file
  72. run: |
  73. cp .env.example dist/.env
  74. - name: Upload Linux artifact
  75. uses: actions/upload-artifact@v4
  76. with:
  77. name: CursorPro-Linux
  78. path: dist/CursorPro
  79. build-macos-intel:
  80. runs-on: macos-latest
  81. steps:
  82. - uses: actions/checkout@v2
  83. - name: Set up Python
  84. uses: actions/setup-python@v2
  85. with:
  86. python-version: '3.x'
  87. - name: Install dependencies
  88. run: |
  89. arch -x86_64 pip3 install --upgrade pip
  90. arch -x86_64 pip3 install pyinstaller
  91. arch -x86_64 pip3 install -r requirements.txt
  92. - name: Build MacOS Intel executable
  93. env:
  94. TARGET_ARCH: 'x86_64'
  95. run: |
  96. arch -x86_64 python3 -m PyInstaller CursorKeepAlive.spec
  97. - name: Copy and rename env file
  98. run: |
  99. cp .env.example dist/.env
  100. - name: Verify architecture
  101. run: |
  102. file dist/CursorPro | grep "x86_64" || (echo "Wrong architecture" && exit 1)
  103. - name: Upload MacOS Intel artifact
  104. uses: actions/upload-artifact@v4
  105. with:
  106. name: CursorPro-MacOS-Intel
  107. path: dist/CursorPro
  108. create-release:
  109. needs: [build-windows, build-macos-arm64, build-linux, build-macos-intel]
  110. runs-on: ubuntu-22.04
  111. if: startsWith(github.ref, 'refs/tags/')
  112. steps:
  113. - name: Download all artifacts
  114. uses: actions/download-artifact@v4
  115. with:
  116. path: artifacts
  117. - name: Create release archives
  118. run: |
  119. cd artifacts
  120. zip -r CursorPro-Windows.zip CursorPro-Windows/
  121. zip -r CursorPro-MacOS-ARM64.zip CursorPro-MacOS-ARM64/
  122. zip -r CursorPro-Linux.zip CursorPro-Linux/
  123. zip -r CursorPro-MacOS-Intel.zip CursorPro-MacOS-Intel/
  124. - name: Create Release
  125. uses: softprops/action-gh-release@v1
  126. with:
  127. files: |
  128. artifacts/CursorPro-Windows.zip
  129. artifacts/CursorPro-MacOS-ARM64.zip
  130. artifacts/CursorPro-Linux.zip
  131. artifacts/CursorPro-MacOS-Intel.zip
  132. env:
  133. GITHUB_TOKEN: ${{ secrets.TOKEN }}