release.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  21. with:
  22. fetch-depth: 0
  23. - name: Determine Version
  24. run: |
  25. VERSION=$(git describe --tags)
  26. echo "VERSION=$VERSION" >> $GITHUB_ENV
  27. - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
  28. with:
  29. bun-version: latest
  30. - name: Build Frontend
  31. env:
  32. CI: ""
  33. run: |
  34. cd web
  35. bun install
  36. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
  37. cd ..
  38. - name: Set up Go
  39. uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
  40. with:
  41. go-version: '>=1.25.1'
  42. - name: Build Backend (amd64)
  43. run: |
  44. go mod download
  45. go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-$VERSION
  46. - name: Build Backend (arm64)
  47. run: |
  48. sudo apt-get update
  49. DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu
  50. CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-arm64-$VERSION
  51. - name: Generate checksums
  52. run: sha256sum new-api-* > checksums-linux.txt
  53. - name: Release
  54. uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
  55. if: startsWith(github.ref, 'refs/tags/')
  56. with:
  57. files: |
  58. new-api-*
  59. checksums-linux.txt
  60. env:
  61. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  62. macos:
  63. name: macOS Release
  64. runs-on: macos-latest
  65. steps:
  66. - name: Checkout
  67. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  68. with:
  69. fetch-depth: 0
  70. - name: Determine Version
  71. run: |
  72. VERSION=$(git describe --tags)
  73. echo "VERSION=$VERSION" >> $GITHUB_ENV
  74. - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
  75. with:
  76. bun-version: latest
  77. - name: Build Frontend
  78. env:
  79. CI: ""
  80. NODE_OPTIONS: "--max-old-space-size=4096"
  81. run: |
  82. cd web
  83. bun install
  84. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
  85. cd ..
  86. - name: Set up Go
  87. uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
  88. with:
  89. go-version: '>=1.25.1'
  90. - name: Build Backend
  91. run: |
  92. go mod download
  93. go build -ldflags "-X 'new-api/common.Version=$VERSION'" -o new-api-macos-$VERSION
  94. - name: Generate checksums
  95. run: shasum -a 256 new-api-macos-* > checksums-macos.txt
  96. - name: Release
  97. uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
  98. if: startsWith(github.ref, 'refs/tags/')
  99. with:
  100. files: |
  101. new-api-macos-*
  102. checksums-macos.txt
  103. env:
  104. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  105. windows:
  106. name: Windows Release
  107. runs-on: windows-latest
  108. defaults:
  109. run:
  110. shell: bash
  111. steps:
  112. - name: Checkout
  113. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  114. with:
  115. fetch-depth: 0
  116. - name: Determine Version
  117. run: |
  118. VERSION=$(git describe --tags)
  119. echo "VERSION=$VERSION" >> $GITHUB_ENV
  120. - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
  121. with:
  122. bun-version: latest
  123. - name: Build Frontend
  124. env:
  125. CI: ""
  126. run: |
  127. cd web
  128. bun install
  129. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
  130. cd ..
  131. - name: Set up Go
  132. uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
  133. with:
  134. go-version: '>=1.25.1'
  135. - name: Build Backend
  136. run: |
  137. go mod download
  138. go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION'" -o new-api-$VERSION.exe
  139. - name: Generate checksums
  140. run: sha256sum new-api-*.exe > checksums-windows.txt
  141. - name: Release
  142. uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
  143. if: startsWith(github.ref, 'refs/tags/')
  144. with:
  145. files: |
  146. new-api-*.exe
  147. checksums-windows.txt
  148. env:
  149. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}