linux-release.yml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. name: Linux Release
  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. release:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@v3
  20. with:
  21. fetch-depth: 0
  22. - uses: oven-sh/setup-bun@v2
  23. with:
  24. bun-version: latest
  25. - name: Build Frontend
  26. env:
  27. CI: ""
  28. run: |
  29. cd web
  30. bun install
  31. DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
  32. cd ..
  33. - name: Set up Go
  34. uses: actions/setup-go@v3
  35. with:
  36. go-version: '>=1.18.0'
  37. - name: Build Backend (amd64)
  38. run: |
  39. go mod download
  40. VERSION=$(git describe --tags)
  41. go build -ldflags "-s -w -X 'one-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-$VERSION
  42. - name: Build Backend (arm64)
  43. run: |
  44. sudo apt-get update
  45. DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu
  46. VERSION=$(git describe --tags)
  47. 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
  48. - name: Release
  49. uses: softprops/action-gh-release@v2
  50. if: startsWith(github.ref, 'refs/tags/')
  51. with:
  52. files: |
  53. new-api-*
  54. draft: true
  55. generate_release_notes: true
  56. env:
  57. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}