From 3334131fbb56ee5d1e4cfe5da9ff477b09c698f0 Mon Sep 17 00:00:00 2001
From: Logan <logan.markewich@live.com>
Date: Thu, 29 Feb 2024 15:32:12 -0600
Subject: [PATCH] subpackage publish action (#11514)

add action and test file
---
 .github/workflows/publish_sub_package.yml     | 43 +++++++++++++++++++
 .../llama-index-llms-openai/pyproject.toml    |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 .github/workflows/publish_sub_package.yml

diff --git a/.github/workflows/publish_sub_package.yml b/.github/workflows/publish_sub_package.yml
new file mode 100644
index 0000000000..a24bea816b
--- /dev/null
+++ b/.github/workflows/publish_sub_package.yml
@@ -0,0 +1,43 @@
+name: Publish Sub-Package to PyPI if Needed
+
+on:
+  push:
+    branches:
+      - main
+  pull_request:
+
+env:
+  POETRY_VERSION: "1.6.1"
+  PYTHON_VERSION: "3.10"
+
+jobs:
+  publish_subpackage_if_needed:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+      - name: Set up python ${{ env.PYTHON_VERSION }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ env.PYTHON_VERSION }}
+      - name: Install Poetry
+        uses: snok/install-poetry@v1
+        with:
+          version: ${{ env.POETRY_VERSION }}
+      - name: Get changed pyproject files
+        id: changed-files
+        run: |
+          echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -v llama-index-core | grep llama-index | grep pyproject | xargs)" >> $GITHUB_OUTPUT
+      - name: Publish changed packages
+        env:
+          PYPI_TOKEN: ${{ secrets.LLAMA_INDEX_PYPI_TOKEN }}
+        run: |
+          for file in ${{ steps.changed-files.outputs.changed_files }}; do
+              cd `echo $file | sed 's/\/pyproject.toml//g'`
+              poetry lock
+              poetry shell
+              poetry install
+              poetry config pypi-token.pypi $PYPI_TOKEN
+              poetry publish --build
+          done
diff --git a/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml
index 1319956ecd..ab1e6f78ea 100644
--- a/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml
+++ b/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml
@@ -29,7 +29,7 @@ exclude = ["**/BUILD"]
 license = "MIT"
 name = "llama-index-llms-openai"
 readme = "README.md"
-version = "0.1.6"
+version = "0.1.7"
 
 [tool.poetry.dependencies]
 python = ">=3.8.1,<4.0"
-- 
GitLab