release.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. name: Release (Linux, macOS, Windows)
  2. permissions:
  3. contents: write
  4. on:
  5. workflow_dispatch:
  6. inputs:
  7. name:
  8. description: 'reason'
  9. required: false
  10. push:
  11. tags:
  12. - '*'
  13. - '!*-alpha*'
  14. jobs:
  15. linux:
  16. name: Linux Release
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Checkout
  20. uses: actions/checkout@v3
  21. with:
  22. fetch-depth: 0
  23. - uses: oven-sh/setup-bun@v2
  24. with:
  25. bun-version: latest
  26. - name: Build Frontend
  27. env:
  28. CI: ""
  29. run: |
  30. cd web
  31. bun install
  32. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
  33. cd ..
  34. - name: Set up Go
  35. uses: actions/setup-go@v3
  36. with:
  37. go-version: '>=1.25.1'
  38. - name: Build Backend (amd64)
  39. run: |
  40. go mod download
  41. VERSION=$(git describe --tags)
  42. go build -ldflags "-s -w -X 'one-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-$VERSION
  43. - name: Build Backend (arm64)
  44. run: |
  45. sudo apt-get update
  46. DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu
  47. VERSION=$(git describe --tags)
  48. CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'one-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-arm64-$VERSION
  49. - name: Release
  50. uses: softprops/action-gh-release@v2
  51. if: startsWith(github.ref, 'refs/tags/')
  52. with:
  53. files: |
  54. new-api-*
  55. draft: true
  56. generate_release_notes: true
  57. env:
  58. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  59. macos:
  60. name: macOS Release
  61. runs-on: macos-latest
  62. steps:
  63. - name: Checkout
  64. uses: actions/checkout@v3
  65. with:
  66. fetch-depth: 0
  67. - uses: oven-sh/setup-bun@v2
  68. with:
  69. bun-version: latest
  70. - name: Build Frontend
  71. env:
  72. CI: ""
  73. NODE_OPTIONS: "--max-old-space-size=4096"
  74. run: |
  75. cd web
  76. bun install
  77. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
  78. cd ..
  79. - name: Set up Go
  80. uses: actions/setup-go@v3
  81. with:
  82. go-version: '>=1.25.1'
  83. - name: Build Backend
  84. run: |
  85. go mod download
  86. VERSION=$(git describe --tags)
  87. go build -ldflags "-X 'one-api/common.Version=$VERSION'" -o new-api-macos-$VERSION
  88. - name: Release
  89. uses: softprops/action-gh-release@v2
  90. if: startsWith(github.ref, 'refs/tags/')
  91. with:
  92. files: new-api-macos-*
  93. draft: true
  94. generate_release_notes: true
  95. env:
  96. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  97. windows:
  98. name: Windows Release
  99. runs-on: windows-latest
  100. defaults:
  101. run:
  102. shell: bash
  103. steps:
  104. - name: Checkout
  105. uses: actions/checkout@v3
  106. with:
  107. fetch-depth: 0
  108. - uses: oven-sh/setup-bun@v2
  109. with:
  110. bun-version: latest
  111. - name: Build Frontend
  112. env:
  113. CI: ""
  114. run: |
  115. cd web
  116. bun install
  117. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
  118. cd ..
  119. - name: Set up Go
  120. uses: actions/setup-go@v3
  121. with:
  122. go-version: '>=1.25.1'
  123. - name: Build Backend
  124. run: |
  125. go mod download
  126. VERSION=$(git describe --tags)
  127. go build -ldflags "-s -w -X 'one-api/common.Version=$VERSION'" -o new-api-$VERSION.exe
  128. - name: Release
  129. uses: softprops/action-gh-release@v2
  130. if: startsWith(github.ref, 'refs/tags/')
  131. with:
  132. files: new-api-*.exe
  133. draft: true
  134. generate_release_notes: true
  135. env:
  136. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}