cd-langchain #112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: cd-langchain | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'packages/uipath_langchain_client/src/uipath_langchain_client/__version__.py' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build package | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| contents: read | |
| id-token: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 2 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.9.27" | |
| enable-cache: true | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Wait for uipath-llm-client publish | |
| if: github.event_name == 'push' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Check if the core package version was also modified in this push | |
| if ! git diff HEAD~1 --name-only | grep -q '^src/uipath/llm_client/__version__.py$'; then | |
| echo "Core package version unchanged — no need to wait." | |
| exit 0 | |
| fi | |
| CORE_VERSION=$(grep '^__version__' src/uipath/llm_client/__version__.py | sed -n 's/.*"\([^"]*\)".*/\1/p') | |
| echo "Core package version also changed ($CORE_VERSION) — waiting for 'cd' workflow to succeed..." | |
| # Poll the cd workflow for up to 15 minutes | |
| for i in $(seq 1 30); do | |
| STATUS=$(gh run list --workflow=cd.yml --branch=main --commit=${{ github.sha }} --json status,conclusion --jq '.[0] | .status + ":" + .conclusion') | |
| echo " Attempt $i/30 — cd workflow: $STATUS" | |
| case "$STATUS" in | |
| completed:success) | |
| echo "cd workflow succeeded — verifying uv can resolve uipath-llm-client==$CORE_VERSION from PyPI..." | |
| # Use uv itself as the readiness check (not curl). The setup-uv action | |
| # restores uv's metadata cache across job runs, so the simple-index entry | |
| # for uipath-llm-client may be stale (without the new version). Polling | |
| # pypi.org/simple/ with curl proves only that PyPI knows about the version, | |
| # not that uv will see it. --refresh-package invalidates uv's cache for | |
| # this specific project and forces a fresh fetch each attempt. Retry rides | |
| # out PyPI CDN propagation across Fastly edges (a fresh publish can be | |
| # visible on one edge but stale on another for tens of seconds). | |
| for j in $(seq 1 40); do | |
| if uv pip install --dry-run --system --no-deps \ | |
| --refresh-package uipath-llm-client \ | |
| "uipath-llm-client==$CORE_VERSION" >/dev/null 2>&1; then | |
| echo "uv can resolve uipath-llm-client==$CORE_VERSION from PyPI." | |
| exit 0 | |
| fi | |
| echo " Not yet resolvable by uv, retrying in 15s ($j/40)..." | |
| sleep 15 | |
| done | |
| echo "::error::uipath-llm-client==$CORE_VERSION never became resolvable on PyPI (10 min)" | |
| exit 1 | |
| ;; | |
| completed:*) | |
| echo "::error::cd workflow finished with: $STATUS" | |
| exit 1 | |
| ;; | |
| esac | |
| sleep 30 | |
| done | |
| echo "::error::Timed out waiting for cd workflow (15 min)" | |
| exit 1 | |
| - name: "Install dependencies" | |
| run: uv sync --dev --all-extras --locked | |
| - name: Build package | |
| run: uv build --package uipath-langchain-client | |
| - name: Smoke test (wheel with all extras) | |
| run: | | |
| WHEEL=$(ls dist/*.whl) | |
| uv run --isolated --no-project --refresh-package uipath-llm-client \ | |
| --with "${WHEEL}[all]" tests/langchain/smoke_test.py | |
| - name: Smoke test (source distribution with all extras) | |
| run: | | |
| SDIST=$(ls dist/*.tar.gz) | |
| uv run --isolated --no-project --refresh-package uipath-llm-client \ | |
| --with "${SDIST}[all]" tests/langchain/smoke_test.py | |
| - name: Publish package | |
| run: uv publish | |
| release: | |
| name: Create GitHub release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=$(grep '^__version__' packages/uipath_langchain_client/src/uipath_langchain_client/__version__.py | sed -n 's/.*"\([^"]*\)".*/\1/p') | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Extract changelog section | |
| run: | | |
| python3 -c " | |
| import re | |
| version = '''${{ steps.version.outputs.version }}''' | |
| with open('packages/uipath_langchain_client/CHANGELOG.md') as f: | |
| content = f.read() | |
| pattern = r'(## \[' + re.escape(version) + r'\][^\n]*\n)(.*?)(?=\n## \[|\Z)' | |
| match = re.search(pattern, content, re.DOTALL) | |
| notes = match.group(0).strip() if match else ('Release ' + version) | |
| with open('release_notes.md', 'w') as f: | |
| f.write(notes) | |
| " | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: langchain-v${{ steps.version.outputs.version }} | |
| name: UiPath LangChain Client [langchain-v${{ steps.version.outputs.version }}] | |
| body_path: release_notes.md | |
| skip_if_tag_exists: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |