Skip to content

Bump version from 0.0.1.dev0 to 0.1.0 for release #2

Bump version from 0.0.1.dev0 to 0.1.0 for release

Bump version from 0.0.1.dev0 to 0.1.0 for release #2

name: Build and Release databricks-dspy
on:
push:
tags:
- 'databricks-dspy-v*'
jobs:
extract_tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- name: Extract version from tag
id: extract
run: |
# Extract version from tag like databricks-dspy-v1.0.0 -> 1.0.0
TAG=${GITHUB_REF#refs/tags/databricks-dspy-v}
echo "version=$TAG" >> $GITHUB_OUTPUT
echo "Extracted version: $TAG"
build_and_test:
runs-on: ubuntu-latest
needs: extract_tag
defaults:
run:
working-directory: integrations/dspy
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install .[dev]
- name: Lint with ruff
run: |
ruff check .
ruff format --check .
- name: Run tests
run: |
pytest tests/unit_tests
- name: Validate version matches tag
run: |
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
TAG_VERSION="${{ needs.extract_tag.outputs.version }}"
if [ "$PYPROJECT_VERSION" != "$TAG_VERSION" ]; then
echo "Error: Version in pyproject.toml ($PYPROJECT_VERSION) does not match tag ($TAG_VERSION)"
exit 1
fi
echo "Version validation passed: $PYPROJECT_VERSION"
- name: Build original package for PyPI
run: |
python -m build
# Save original package for PyPI
mkdir -p dist-pypi
cp dist/* dist-pypi/
- name: Build test package for TestPyPI
run: |
# Clean previous build
rm -rf dist/*
# Update package name for TestPyPI
sed -i 's/^name *= *".*"/name = "databricks-dspy-test"/' pyproject.toml
# Add dev suffix with timestamp for unique TestPyPI versions
TIMESTAMP=$(date +%Y%m%d%H%M%S)
sed -i "s/^version *= *\"\(.*\)\"/version = \"\1.dev${TIMESTAMP}\"/" pyproject.toml
echo "Updated version for TestPyPI: $(grep '^version = ' pyproject.toml)"
# Build test package
python -m build
- name: Check packages
run: |
twine check dist/*
twine check dist-pypi/*
- name: Upload TestPyPI artifacts
uses: actions/upload-artifact@v4
with:
name: dist-test-files
path: integrations/dspy/dist/
- name: Upload PyPI artifacts
uses: actions/upload-artifact@v4
with:
name: dist-pypi-files
path: integrations/dspy/dist-pypi/
publish_test_pypi:
runs-on: ubuntu-latest
needs: [extract_tag, build_and_test]
defaults:
run:
working-directory: integrations/dspy
environment:
name: test-pypi
url: https://test.pypi.org/p/databricks-dspy-test
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download TestPyPI artifacts
uses: actions/download-artifact@v4
with:
name: dist-test-files
path: integrations/dspy/dist/
- name: Install twine
run: |
python -m pip install --upgrade pip twine
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: integrations/dspy/dist/
- name: Test installation from TestPyPI
run: |
sleep 30 # Wait for package to be available
# Install the test package with dev version
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
databricks-dspy-test
python -c "import databricks_dspy; print('Package installed successfully from TestPyPI')"
publish_pypi:
runs-on: ubuntu-latest
if: github.repository_owner == 'databricks'
needs: [extract_tag, publish_test_pypi]
defaults:
run:
working-directory: integrations/dspy
environment:
name: pypi
url: https://pypi.org/p/databricks-dspy
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download PyPI artifacts
uses: actions/download-artifact@v4
with:
name: dist-pypi-files
path: integrations/dspy/dist/
- name: Install twine
run: |
python -m pip install --upgrade pip twine
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: integrations/dspy/dist/
- name: Test installation from PyPI
run: |
sleep 60 # Wait for package to be available
pip install databricks-dspy==${{ needs.extract_tag.outputs.version }}
python -c "import databricks_dspy; print('Package installed successfully from PyPI')"