build.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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: |
  31. dist/CursorPro.exe
  32. dist/.env
  33. build-macos-arm64:
  34. runs-on: macos-latest
  35. steps:
  36. - uses: actions/checkout@v2
  37. - name: Set up Python
  38. uses: actions/setup-python@v2
  39. with:
  40. python-version: '3.x'
  41. - name: Install dependencies
  42. run: |
  43. python -m pip install --upgrade pip
  44. pip install pyinstaller
  45. pip install -r requirements.txt
  46. - name: Build MacOS ARM executable
  47. run: |
  48. pyinstaller CursorKeepAlive.spec
  49. - name: Copy and rename env file
  50. run: |
  51. cp .env.example dist/.env
  52. - name: Upload MacOS ARM artifact
  53. uses: actions/upload-artifact@v4
  54. with:
  55. name: CursorPro-MacOS-ARM64
  56. path: |
  57. dist/CursorPro
  58. dist/.env
  59. build-linux:
  60. runs-on: ubuntu-22.04
  61. steps:
  62. - uses: actions/checkout@v2
  63. - name: Set up Python
  64. uses: actions/setup-python@v2
  65. with:
  66. python-version: '3.x'
  67. - name: Install dependencies
  68. run: |
  69. python -m pip install --upgrade pip
  70. pip install pyinstaller
  71. pip install -r requirements.txt
  72. - name: Build Linux executable
  73. run: |
  74. pyinstaller CursorKeepAlive.spec
  75. - name: Copy and rename env file
  76. run: |
  77. cp .env.example dist/.env
  78. - name: Upload Linux artifact
  79. uses: actions/upload-artifact@v4
  80. with:
  81. name: CursorPro-Linux
  82. path: |
  83. dist/CursorPro
  84. dist/.env
  85. build-macos-intel:
  86. runs-on: macos-latest
  87. steps:
  88. - uses: actions/checkout@v2
  89. - name: Set up Python
  90. uses: actions/setup-python@v2
  91. with:
  92. python-version: '3.x'
  93. - name: Install dependencies
  94. run: |
  95. arch -x86_64 pip3 install --upgrade pip
  96. arch -x86_64 pip3 install pyinstaller
  97. arch -x86_64 pip3 install -r requirements.txt
  98. - name: Build MacOS Intel executable
  99. env:
  100. TARGET_ARCH: 'x86_64'
  101. run: |
  102. arch -x86_64 python3 -m PyInstaller CursorKeepAlive.spec
  103. - name: Copy and rename env file
  104. run: |
  105. cp .env.example dist/.env
  106. - name: Verify architecture
  107. run: |
  108. file dist/CursorPro | grep "x86_64" || (echo "Wrong architecture" && exit 1)
  109. - name: Upload MacOS Intel artifact
  110. uses: actions/upload-artifact@v4
  111. with:
  112. name: CursorPro-MacOS-Intel
  113. path: |
  114. dist/CursorPro
  115. dist/.env
  116. create-release:
  117. needs: [build-windows, build-macos-arm64, build-linux, build-macos-intel]
  118. runs-on: ubuntu-22.04
  119. if: startsWith(github.ref, 'refs/tags/')
  120. steps:
  121. - name: Download all artifacts
  122. uses: actions/download-artifact@v4
  123. with:
  124. path: artifacts
  125. - name: Create release archives
  126. run: |
  127. cd artifacts
  128. zip -r CursorPro-Windows.zip CursorPro-Windows/
  129. zip -r CursorPro-MacOS-ARM64.zip CursorPro-MacOS-ARM64/
  130. zip -r CursorPro-Linux.zip CursorPro-Linux/
  131. zip -r CursorPro-MacOS-Intel.zip CursorPro-MacOS-Intel/
  132. - name: Create Release
  133. uses: softprops/action-gh-release@v1
  134. with:
  135. files: |
  136. artifacts/CursorPro-Windows.zip
  137. artifacts/CursorPro-MacOS-ARM64.zip
  138. artifacts/CursorPro-Linux.zip
  139. artifacts/CursorPro-MacOS-Intel.zip
  140. env:
  141. GITHUB_TOKEN: ${{ secrets.TOKEN }}