electron-build.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. name: Build Electron App
  2. on:
  3. push:
  4. tags:
  5. - '*' # Triggers on version tags like v1.0.0
  6. - '!*-*' # Ignore pre-release tags like v1.0.0-beta
  7. - '!*-alpha*' # Ignore alpha tags like v1.0.0-alpha
  8. workflow_dispatch: # Allows manual triggering
  9. jobs:
  10. build:
  11. strategy:
  12. matrix:
  13. # os: [macos-latest, windows-latest]
  14. os: [windows-latest]
  15. runs-on: ${{ matrix.os }}
  16. defaults:
  17. run:
  18. shell: bash
  19. steps:
  20. - name: Checkout code
  21. uses: actions/checkout@v4
  22. with:
  23. fetch-depth: 0
  24. - name: Setup Bun
  25. uses: oven-sh/setup-bun@v2
  26. with:
  27. bun-version: latest
  28. - name: Setup Node.js
  29. uses: actions/setup-node@v4
  30. with:
  31. node-version: '20'
  32. - name: Setup Go
  33. uses: actions/setup-go@v5
  34. with:
  35. go-version: '>=1.25.1'
  36. - name: Build frontend
  37. env:
  38. CI: ""
  39. NODE_OPTIONS: "--max-old-space-size=4096"
  40. run: |
  41. cd web
  42. bun install
  43. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
  44. cd ..
  45. # - name: Build Go binary (macos/Linux)
  46. # if: runner.os != 'Windows'
  47. # run: |
  48. # go mod download
  49. # go build -ldflags "-s -w -X 'new-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o new-api
  50. - name: Build Go binary (Windows)
  51. if: runner.os == 'Windows'
  52. run: |
  53. go mod download
  54. go build -ldflags "-s -w -X 'new-api/common.Version=$(git describe --tags)'" -o new-api.exe
  55. - name: Update Electron version
  56. run: |
  57. cd electron
  58. VERSION=$(git describe --tags)
  59. VERSION=${VERSION#v} # Remove 'v' prefix if present
  60. # Convert to valid semver: take first 3 components and convert rest to prerelease format
  61. # e.g., 0.9.3-patch.1 -> 0.9.3-patch.1
  62. if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$ ]]; then
  63. MAJOR=${BASH_REMATCH[1]}
  64. MINOR=${BASH_REMATCH[2]}
  65. PATCH=${BASH_REMATCH[3]}
  66. REST=${BASH_REMATCH[4]}
  67. VERSION="$MAJOR.$MINOR.$PATCH"
  68. # If there's extra content, append it without adding -dev
  69. if [[ -n "$REST" ]]; then
  70. VERSION="$VERSION$REST"
  71. fi
  72. fi
  73. npm version $VERSION --no-git-tag-version --allow-same-version
  74. - name: Install Electron dependencies
  75. run: |
  76. cd electron
  77. npm install
  78. # - name: Build Electron app (macOS)
  79. # if: runner.os == 'macOS'
  80. # run: |
  81. # cd electron
  82. # npm run build:mac
  83. # env:
  84. # CSC_IDENTITY_AUTO_DISCOVERY: false # Skip code signing
  85. - name: Build Electron app (Windows)
  86. if: runner.os == 'Windows'
  87. run: |
  88. cd electron
  89. npm run build:win
  90. # - name: Upload artifacts (macOS)
  91. # if: runner.os == 'macOS'
  92. # uses: actions/upload-artifact@v4
  93. # with:
  94. # name: macos-build
  95. # path: |
  96. # electron/dist/*.dmg
  97. # electron/dist/*.zip
  98. - name: Upload artifacts (Windows)
  99. if: runner.os == 'Windows'
  100. uses: actions/upload-artifact@v4
  101. with:
  102. name: windows-build
  103. path: |
  104. electron/dist/*.exe
  105. release:
  106. needs: build
  107. runs-on: ubuntu-latest
  108. if: startsWith(github.ref, 'refs/tags/')
  109. permissions:
  110. contents: write
  111. steps:
  112. - name: Download all artifacts
  113. uses: actions/download-artifact@v4
  114. - name: Upload to Release
  115. uses: softprops/action-gh-release@v2
  116. with:
  117. files: |
  118. windows-build/*
  119. env:
  120. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}