electron-build.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. name: Build Electron App
  2. on:
  3. push:
  4. tags:
  5. - 'v*.*.*' # Triggers on version tags like v1.0.0
  6. workflow_dispatch: # Allows manual triggering
  7. jobs:
  8. build:
  9. strategy:
  10. matrix:
  11. os: [macos-latest, windows-latest]
  12. runs-on: ${{ matrix.os }}
  13. steps:
  14. - name: Checkout code
  15. uses: actions/checkout@v4
  16. - name: Setup Node.js
  17. uses: actions/setup-node@v4
  18. with:
  19. node-version: '20'
  20. - name: Setup Go
  21. uses: actions/setup-go@v5
  22. with:
  23. go-version: '1.21'
  24. - name: Build frontend
  25. run: |
  26. cd web
  27. npm install --legacy-peer-deps
  28. npm run build
  29. env:
  30. DISABLE_ESLINT_PLUGIN: 'true'
  31. NODE_OPTIONS: '--max_old_space_size=4096'
  32. - name: Build Go binary (macos/Linux)
  33. if: runner.os != 'Windows'
  34. run: |
  35. go build -ldflags="-s -w" -o new-api
  36. - name: Build Go binary (Windows)
  37. if: runner.os == 'Windows'
  38. run: |
  39. go build -ldflags="-s -w" -o new-api.exe
  40. - name: Install Electron dependencies
  41. run: |
  42. cd electron
  43. npm install
  44. - name: Build Electron app (macOS)
  45. if: runner.os == 'macOS'
  46. run: |
  47. cd electron
  48. npm run build:mac
  49. env:
  50. CSC_IDENTITY_AUTO_DISCOVERY: false # Skip code signing
  51. - name: Build Electron app (Windows)
  52. if: runner.os == 'Windows'
  53. run: |
  54. cd electron
  55. npm run build:win
  56. - name: Upload artifacts (macOS)
  57. if: runner.os == 'macOS'
  58. uses: actions/upload-artifact@v4
  59. with:
  60. name: macos-build
  61. path: |
  62. electron/dist/*.dmg
  63. electron/dist/*.zip
  64. - name: Upload artifacts (Windows)
  65. if: runner.os == 'Windows'
  66. uses: actions/upload-artifact@v4
  67. with:
  68. name: windows-build
  69. path: |
  70. electron/dist/*.exe
  71. release:
  72. needs: build
  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. - name: Create Release
  79. uses: softprops/action-gh-release@v1
  80. with:
  81. files: |
  82. macos-build/*
  83. windows-build/*
  84. draft: false
  85. prerelease: false
  86. env:
  87. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}