Skip to content

Publish SDK to PyPI

Publish SDK to PyPI #1

Workflow file for this run

name: Publish SDK to PyPI
permissions:
contents: write
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 0.1.0, 0.2.0)'
required: true
type: string
release_notes:
description: 'Release notes'
required: false
type: string
default: 'Bug fixes and improvements'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install -e ".[dev]"
- name: Update version in setup.py
run: |
sed -i "s/version=\".*\"/version=\"${{ inputs.version }}\"/" setup.py
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \".*\"/version = \"${{ inputs.version }}\"/" pyproject.toml
- name: Run tests
run: |
# Run mypy
mypy dataspace_sdk/ --ignore-missing-imports --config-file=/dev/null
# Run pytest
pytest tests/test_auth.py tests/test_base.py tests/test_client.py tests/test_datasets.py tests/test_aimodels.py tests/test_usecases.py tests/test_exceptions.py -v -p no:django -o addopts= --override-ini=django_find_project=false --noconftest --cov=dataspace_sdk --cov-report=term-missing
- name: Build package
run: |
python -m build
- name: Check package
run: |
twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
- name: Commit version changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add setup.py pyproject.toml
git commit -m "Bump version to ${{ inputs.version }}" || echo "No changes to commit"
git push || echo "No changes to push"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
release_name: SDK v${{ inputs.version }}
body: ${{ inputs.release_notes }}
draft: false
prerelease: false