electron-build.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Build Electron App
  2. on:
  3. push:
  4. tags:
  5. - '*' # 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. os: [windows-latest]
  13. runs-on: ${{ matrix.os }}
  14. defaults:
  15. run:
  16. shell: bash
  17. steps:
  18. - name: Checkout code
  19. uses: actions/checkout@v4
  20. with:
  21. fetch-depth: 0
  22. - name: Setup Bun
  23. uses: oven-sh/setup-bun@v2
  24. with:
  25. bun-version: latest
  26. - name: Setup Node.js
  27. uses: actions/setup-node@v4
  28. with:
  29. node-version: '20'
  30. - name: Setup Go
  31. uses: actions/setup-go@v5
  32. with:
  33. go-version: '>=1.18.0'
  34. - name: Build frontend
  35. env:
  36. CI: ""
  37. NODE_OPTIONS: "--max-old-space-size=4096"
  38. run: |
  39. cd web
  40. bun install
  41. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
  42. cd ..
  43. # - name: Build Go binary (macos/Linux)
  44. # if: runner.os != 'Windows'
  45. # run: |
  46. # go mod download
  47. # go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o new-api
  48. - name: Build Go binary (Windows)
  49. if: runner.os == 'Windows'
  50. run: |
  51. go mod download
  52. go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)'" -o new-api.exe
  53. - name: Update Electron version
  54. run: |
  55. cd electron
  56. VERSION=$(git describe --tags)
  57. VERSION=${VERSION#v} # Remove 'v' prefix if present
  58. npm version $VERSION --no-git-tag-version --allow-same-version
  59. - name: Install Electron dependencies
  60. run: |
  61. cd electron
  62. npm install
  63. # - name: Build Electron app (macOS)
  64. # if: runner.os == 'macOS'
  65. # run: |
  66. # cd electron
  67. # npm run build:mac
  68. # env:
  69. # CSC_IDENTITY_AUTO_DISCOVERY: false # Skip code signing
  70. - name: Build Electron app (Windows)
  71. if: runner.os == 'Windows'
  72. run: |
  73. cd electron
  74. npm run build:win
  75. # - name: Upload artifacts (macOS)
  76. # if: runner.os == 'macOS'
  77. # uses: actions/upload-artifact@v4
  78. # with:
  79. # name: macos-build
  80. # path: |
  81. # electron/dist/*.dmg
  82. # electron/dist/*.zip
  83. - name: Upload artifacts (Windows)
  84. if: runner.os == 'Windows'
  85. uses: actions/upload-artifact@v4
  86. with:
  87. name: windows-build
  88. path: |
  89. electron/dist/*.exe
  90. release:
  91. needs: build
  92. runs-on: ubuntu-latest
  93. if: startsWith(github.ref, 'refs/tags/')
  94. steps:
  95. - name: Download all artifacts
  96. uses: actions/download-artifact@v4
  97. - name: Create Release
  98. uses: softprops/action-gh-release@v2
  99. with:
  100. files: |
  101. # macos-build/*
  102. windows-build/*
  103. draft: false
  104. prerelease: false
  105. env:
  106. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}