release.yml 3.7 KB

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