Deployment #1
Workflow file for this run
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
| # Generated initially using github-actions-wizard (https://github.com/cmdr2/github-actions-wizard) | |
| name: Publish to PyPI | |
| run-name: Deployment | |
| on: | |
| release: | |
| types: | |
| - created | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: |- | |
| python -m pip install --upgrade pip | |
| pip install build wheel pytest toml requests | |
| - name: Check PyPI version | |
| id: check-version | |
| run: |- | |
| TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
| PYPI_VERSION=$(python -c "import requests; r = requests.get('https://pypi.org/pypi/sdkit/json'); print(None if r.status_code == 404 else r.json()['info']['version'])") | |
| echo "Local version: $TOML_VERSION" | |
| echo "PyPI version: $PYPI_VERSION" | |
| if [ "$TOML_VERSION" = "$PYPI_VERSION" ]; then | |
| echo "Versions match. Skipping publish." | |
| echo "publish=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Versions differ. Proceeding with publish." | |
| echo "publish=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build package | |
| if: steps.check-version.outputs.publish == 'true' | |
| run: python -m build | |
| - name: Publish to PyPI | |
| if: steps.check-version.outputs.publish == 'true' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true | |
| permissions: | |
| contents: read | |
| id-token: write |