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. - name: Determine Version
  24. run: |
  25. VERSION=$(git describe --tags)
  26. echo "VERSION=$VERSION" >> $GITHUB_ENV
  27. - uses: oven-sh/setup-bun@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@v3
  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: Release
  52. uses: softprops/action-gh-release@v2
  53. if: startsWith(github.ref, 'refs/tags/')
  54. with:
  55. files: |
  56. new-api-*
  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. - name: Determine Version
  68. run: |
  69. VERSION=$(git describe --tags)
  70. echo "VERSION=$VERSION" >> $GITHUB_ENV
  71. - uses: oven-sh/setup-bun@v2
  72. with:
  73. bun-version: latest
  74. - name: Build Frontend
  75. env:
  76. CI: ""
  77. NODE_OPTIONS: "--max-old-space-size=4096"
  78. run: |
  79. cd web
  80. bun install
  81. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
  82. cd ..
  83. - name: Set up Go
  84. uses: actions/setup-go@v3
  85. with:
  86. go-version: '>=1.25.1'
  87. - name: Build Backend
  88. run: |
  89. go mod download
  90. go build -ldflags "-X 'new-api/common.Version=$VERSION'" -o new-api-macos-$VERSION
  91. - name: Release
  92. uses: softprops/action-gh-release@v2
  93. if: startsWith(github.ref, 'refs/tags/')
  94. with:
  95. files: new-api-macos-*
  96. env:
  97. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  98. windows:
  99. name: Windows Release
  100. runs-on: windows-latest
  101. defaults:
  102. run:
  103. shell: bash
  104. steps:
  105. - name: Checkout
  106. uses: actions/checkout@v3
  107. with:
  108. fetch-depth: 0
  109. - name: Determine Version
  110. run: |
  111. VERSION=$(git describe --tags)
  112. echo "VERSION=$VERSION" >> $GITHUB_ENV
  113. - uses: oven-sh/setup-bun@v2
  114. with:
  115. bun-version: latest
  116. - name: Build Frontend
  117. env:
  118. CI: ""
  119. run: |
  120. cd web
  121. bun install
  122. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
  123. cd ..
  124. - name: Set up Go
  125. uses: actions/setup-go@v3
  126. with:
  127. go-version: '>=1.25.1'
  128. - name: Build Backend
  129. run: |
  130. go mod download
  131. go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION'" -o new-api-$VERSION.exe
  132. - name: Release
  133. uses: softprops/action-gh-release@v2
  134. if: startsWith(github.ref, 'refs/tags/')
  135. with:
  136. files: new-api-*.exe
  137. env:
  138. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}