|
| 1 | +name: Publish SDK to PyPI |
| 2 | +permissions: |
| 3 | + contents: write |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Version number (e.g., 0.1.0, 0.2.0)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + release_notes: |
| 13 | + description: 'Release notes' |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + default: 'Bug fixes and improvements' |
| 17 | + |
| 18 | +jobs: |
| 19 | + publish: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@v4 |
| 29 | + with: |
| 30 | + python-version: '3.11' |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install build twine |
| 36 | + pip install -e ".[dev]" |
| 37 | +
|
| 38 | + - name: Update version in setup.py |
| 39 | + run: | |
| 40 | + sed -i "s/version=\".*\"/version=\"${{ inputs.version }}\"/" setup.py |
| 41 | +
|
| 42 | + - name: Update version in pyproject.toml |
| 43 | + run: | |
| 44 | + sed -i "s/version = \".*\"/version = \"${{ inputs.version }}\"/" pyproject.toml |
| 45 | +
|
| 46 | + - name: Run tests |
| 47 | + run: | |
| 48 | + # Run mypy |
| 49 | + mypy dataspace_sdk/ --ignore-missing-imports --config-file=/dev/null |
| 50 | + # Run pytest |
| 51 | + 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 |
| 52 | +
|
| 53 | + - name: Build package |
| 54 | + run: | |
| 55 | + python -m build |
| 56 | +
|
| 57 | + - name: Check package |
| 58 | + run: | |
| 59 | + twine check dist/* |
| 60 | +
|
| 61 | + - name: Publish to PyPI |
| 62 | + env: |
| 63 | + TWINE_USERNAME: __token__ |
| 64 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 65 | + run: | |
| 66 | + twine upload dist/* |
| 67 | +
|
| 68 | + - name: Commit version changes |
| 69 | + run: | |
| 70 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 71 | + git config --local user.name "github-actions[bot]" |
| 72 | + git add setup.py pyproject.toml |
| 73 | + git commit -m "Bump version to ${{ inputs.version }}" || echo "No changes to commit" |
| 74 | + git push || echo "No changes to push" |
| 75 | +
|
| 76 | + - name: Create GitHub Release |
| 77 | + uses: actions/create-release@v1 |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + with: |
| 81 | + tag_name: v${{ inputs.version }} |
| 82 | + release_name: SDK v${{ inputs.version }} |
| 83 | + body: ${{ inputs.release_notes }} |
| 84 | + draft: false |
| 85 | + prerelease: false |
0 commit comments