From 33d8058d4a011c77abdbc08b2e37c898f878a121 Mon Sep 17 00:00:00 2001 From: Fangyin Cheng Date: Thu, 20 Mar 2025 14:47:28 +0800 Subject: [PATCH] ci(pypi): Build SDK --- .github/workflows/python-publish.yml | 77 +++++++++++++++++----------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index dd68eb879..e48733e42 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -14,7 +14,7 @@ on: workflow_dispatch: inputs: version: - description: 'Package version (e.g. 0.6.3rc2)' + description: 'Package version (e.g. 0.7.0rc0)' required: true type: string permissions: @@ -22,36 +22,53 @@ permissions: jobs: deploy: + name: python runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install wheel setuptools - - - name: Build package using Make - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - DB_GPT_VERSION=${{ inputs.version }} make package - else - make package - fi + - uses: actions/checkout@v4 - - name: Upload wheel as artifact - uses: actions/upload-artifact@v3 - with: - name: dist-packages - path: dist/* - retention-days: 7 + - name: Install uv + uses: astral-sh/setup-uv@v5 - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: ".python-version" + + - name: Update version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + export DB_GPT_VERSION=${{ inputs.version }} make package + echo "Updating version in all files to $DB_GPT_VERSION" + cd scripts + uv run update_version_all.py $DB_GPT_VERSION -y + else + echo "Prepping package for release" + fi + - name: Install the project + run: uv sync --all-extras --dev + + - name: Build package using Make + run: | + make build + ls dist/ + + - name: Upload wheel as artifact + uses: actions/upload-artifact@v3 + with: + name: dist-packages + path: dist/* + retention-days: 7 + + # - name: Publish package to TestPyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # password: ${{ secrets.TEST_PYPI_API_TOKEN }} + # repository-url: https://test.pypi.org/legacy/ + + # - name: Publish package distributions to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # password: ${{ secrets.PYPI_API_TOKEN }} + \ No newline at end of file