Build & Deploy to PyPI #41
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
| name: Build & Deploy to PyPI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: Deployment environment | |
| required: true | |
| type: choice | |
| options: | |
| - test | |
| - production | |
| release: | |
| types: [published] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout 🛒 | |
| uses: actions/checkout@v4 | |
| - name: Install uv 💜 | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Install and run ruff 🐶 | |
| uses: astral-sh/ruff-action@v3 | |
| - name: Set up Python 🐍 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies 📦 | |
| run: | | |
| uv sync --all-groups --frozen | |
| - name: Lint with flake8 ❄️ | |
| run: | | |
| uv run flake8 | |
| - name: Test with pytest ✅ | |
| run: | | |
| uv run pytest tests | |
| - name: Version replacement based on tag ↔️ | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/} | |
| echo "Tag version: $TAG_VERSION" | |
| uv version $TAG_VERSION | |
| - name: Generate HTML documentation 📚 | |
| # TEMPORARILY REMOVED FOR TESTING: if: github.event_name == 'release' || inputs.environment == 'production' | |
| run: | | |
| uv sync --all-groups --frozen | |
| uv pip install -e . | |
| uv run pdoc --html -f -o ./docs keboola.component | |
| mv ./docs/keboola/component/* docs | |
| rm -r ./docs/keboola | |
| - name: Build package 📦 | |
| run: | | |
| uv build | |
| - name: Publish to PyPI 🚀 | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ inputs.environment == 'test' && secrets.UV_PUBLISH_TOKEN_TEST_PYPI || secrets.UV_PUBLISH_TOKEN }} | |
| run: | | |
| uv publish ${{ inputs.environment == 'test' && '--index testpypi' || '' }} | |
| - name: Commit documentation 📝 | |
| # TEMPORARILY REMOVED FOR TESTING: if: github.event_name == 'release' || inputs.environment == 'production' | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/} | |
| # THE FIX: Switch to test-docs-fix before committing (testing the checkout logic) | |
| git fetch origin test-docs-fix | |
| git checkout test-docs-fix | |
| git config --global user.name 'KCF' | |
| git config --global user.email 'kcf@users.noreply.github.com' | |
| git add docs | |
| git commit -m "docs: update for release $TAG_VERSION 📚" || echo "No changes to commit" | |
| git push origin test-docs-fix |