build.yml 4.1 KB

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