pypi-publish.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. name: Upload LightRAG-hku Package
  2. on:
  3. release:
  4. types: [published]
  5. workflow_dispatch:
  6. permissions:
  7. contents: read
  8. jobs:
  9. release-build:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v6
  13. with:
  14. fetch-depth: 0 # Fetch all history for tags
  15. # Build frontend WebUI
  16. - name: Setup Bun
  17. uses: oven-sh/setup-bun@v2
  18. with:
  19. bun-version: latest
  20. - name: Build Frontend WebUI
  21. run: |
  22. cd lightrag_webui
  23. bun install --frozen-lockfile
  24. bun run build
  25. cd ..
  26. - name: Verify Frontend Build
  27. run: |
  28. if [ ! -f "lightrag/api/webui/index.html" ]; then
  29. echo "❌ Error: Frontend build failed - index.html not found"
  30. exit 1
  31. fi
  32. echo "✅ Frontend build verified"
  33. echo "Frontend files:"
  34. ls -lh lightrag/api/webui/ | head -10
  35. - uses: actions/setup-python@v6
  36. with:
  37. python-version: "3.x"
  38. - name: Resolve release version
  39. id: get_version
  40. run: |
  41. if [ "${{ github.event_name }}" = "release" ] && [ -n "${{ github.event.release.tag_name }}" ]; then
  42. TAG="${{ github.event.release.tag_name }}"
  43. else
  44. TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
  45. fi
  46. if [ -z "$TAG" ]; then
  47. echo "No git tag found for release build"
  48. exit 1
  49. fi
  50. PACKAGE_VERSION="${TAG#v}"
  51. echo "Found tag: $TAG"
  52. echo "Package version: $PACKAGE_VERSION"
  53. echo "version=$TAG" >> $GITHUB_OUTPUT
  54. echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
  55. - name: Update version definitions
  56. run: |
  57. python scripts/release/set_version.py --core-version "${{ steps.get_version.outputs.package_version }}"
  58. grep '__version__ = ' lightrag/_version.py
  59. - name: Build release distributions
  60. run: |
  61. python -m pip install build
  62. python -m build
  63. - name: Upload distributions
  64. uses: actions/upload-artifact@v7
  65. with:
  66. name: release-dists
  67. path: dist/
  68. pypi-publish:
  69. runs-on: ubuntu-latest
  70. needs:
  71. - release-build
  72. permissions:
  73. id-token: write
  74. environment:
  75. name: pypi
  76. steps:
  77. - name: Retrieve release distributions
  78. uses: actions/download-artifact@v8
  79. with:
  80. name: release-dists
  81. path: dist/
  82. - name: Publish release distributions to PyPI
  83. uses: pypa/gh-action-pypi-publish@release/v1
  84. with:
  85. packages-dir: dist/