rename #541
Workflow file for this run
This file contains 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: Python Client | |
on: | |
pull_request: | |
paths: | |
- "clients/python/**" | |
branches: | |
- canary | |
push: | |
paths: | |
- "clients/python/.bumpversion.cfg" | |
branches: | |
- canary | |
tags: | |
- "release/py_client/v*.*.*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: | | |
pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
cache: poetry | |
cache-dependency-path: clients/python/poetry.lock | |
- name: Set Poetry environment | |
run: | | |
poetry env use 3.11 | |
working-directory: clients/python | |
- name: Install dependencies | |
run: | | |
poetry install --no-root | |
working-directory: clients/python | |
- name: Lint Python Client | |
run: | | |
poetry run mypy . | |
poetry run ruff check . | |
poetry run ruff format --check . | |
working-directory: clients/python | |
- name: Test Python Client | |
run: | | |
poetry run pytest baml_lib/ baml_core/ | |
working-directory: clients/python | |
- name: Build Python Client | |
run: poetry build | |
working-directory: clients/python | |
- name: Create artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-client | |
path: clients/python/dist | |
pre-release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/canary' | |
environment: nightly | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-client | |
path: clients/python/dist | |
- id: hash | |
run: | | |
VERSION=$(cat clients/python/.bumpversion.cfg | grep "current_version =" | cut -d '=' -f 2 | sed 's/[", ]//g') | |
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+$ ]]; then | |
echo "Version ($VERSION) is not a pre-release build" | |
exit 1 | |
fi | |
echo "version=${VERSION%.dev*}" >> $GITHUB_OUTPUT | |
echo "full_version=$VERSION" >> $GITHUB_OUTPUT | |
echo "tarball_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | |
echo "whl_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION-py3-none-any.whl | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | |
- name: Pre-release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: "unstable/py_client/v${{ steps.hash.outputs.version }}" | |
files: | | |
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}.tar.gz | |
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}-py3-none-any.whl | |
prerelease: true | |
body: | | |
## Hashes | |
Full Build: ${{ steps.hash.outputs.full_version }} | |
Tarball: ${{ steps.hash.outputs.tarball_hash }} | |
Wheel: ${{ steps.hash.outputs.whl_hash }} | |
- name: Mint token | |
id: mint | |
uses: tschm/[email protected] | |
- name: Install Poetry | |
run: | | |
pipx install poetry | |
- name: Publish the package with poetry | |
run: | | |
poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}' | |
working-directory: clients/python | |
release: | |
permissions: | |
contents: write | |
id-token: write | |
runs-on: ubuntu-latest | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/release/') | |
environment: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-client | |
path: clients/python/dist | |
- id: hash | |
run: | | |
VERSION=$(cat clients/python/.bumpversion.cfg | grep "current_version =" | cut -d '=' -f 2 | sed 's/[", ]//g') | |
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Version ($VERSION) is not a release build" | |
exit 1 | |
fi | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "tarball_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | |
echo "whl_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION-py3-none-any.whl | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: "release/py_client/v${{ steps.hash.outputs.version }}" | |
files: | | |
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}.tar.gz | |
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}-py3-none-any.whl | |
prerelease: false | |
body: | | |
## Hashes | |
Tarball: ${{ steps.hash.outputs.tarball_hash }} | |
Wheel: ${{ steps.hash.outputs.whl_hash }} | |
- name: Mint token | |
id: mint | |
uses: tschm/[email protected] | |
- name: Install Poetry | |
run: | | |
pipx install poetry | |
- name: Publish the package with poetry | |
run: | | |
poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}' | |
working-directory: clients/python |