build.yml 4.3 KB

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