GitHub Actions Workflow Visualizer

Understand, optimize, and collaborate on your CI/CD pipelines

Total Duration
~3 minutes
Jobs
2
Steps
12
Triggers
2

Triggers

Tag Push

Tags matching v*.*.*

Release

When a release is published

Environments

pypi

Secrets

PYPI_API_TOKEN
Used

Test & Build

ubuntu-latest ~2m
Required
Checkout code actions/checkout@v4
Completed in 1.2s
Set up Python 3.9 actions/setup-python@v5
Completed in 2.8s
Cache pip actions/cache@v3
Cache hit in 1.5s
Install dependencies
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
Completed in 12.4s
Run pytest
pytest --maxfail=1 --disable-warnings -q
Completed in 45.2s
12 passed 0 skipped
Build distributions
python -m pip install --upgrade build
python -m build --sdist --wheel
Completed in 18.7s
sdist wheel
Upload build artifacts actions/upload-artifact@v4
Completed in 3.5s
dist

Publish to PyPI

ubuntu-latest ~1m
Dependent PyPI
Download build artifacts actions/download-artifact@v4
Completed in 0.8s
dist
Publish with twine (tags)
python -m pip install --upgrade twine
python -m twine upload dist/*
Variables:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
Completed in 15.3s
Uploaded 2 files
Publish with pypa/gh-action-pypi-publish pypa/gh-action-pypi-publish@release/v1
Condition not met (release not published)
When release is published
Cleanup
rm -rf dist build *.egg-info
Completed in 0.4s

Workflow YAML

name: Publish Python Package

on:
  push:
    tags:
      - 'v*.*.*'
  release:
    types: [published]

permissions:
  contents: read
  id-token: write

jobs:
  test-and-build:
    name: Test & Build
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Python 3.9
        uses: actions/setup-python@v5
        with:
          python-version: '3.9'

      - name: Cache pip
        uses: actions/cache@v3
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: ${{ runner.os }}-pip-

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

      - name: Run pytest
        run: pytest --maxfail=1 --disable-warnings -q

      - name: Build distributions
        run: |
          python -m pip install --upgrade build
          python -m build --sdist --wheel

      - name: Upload build artifacts
        uses: actions/upload-artifact@v4
        with:
          name: dist
          path: dist/

  publish-to-pypi:
    name: Publish to PyPI
    needs: test-and-build
    runs-on: ubuntu-latest
    environment:
      name: pypi

    steps:
      - name: Download build artifacts
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist/

      - name: Publish with twine
        if: startsWith(github.ref, 'refs/tags/')
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
        run: python -m pip install --upgrade twine \
             && python -m twine upload dist/*

      - name: Publish with pypa/gh-action-pypi-publish
        if: github.event_name == 'release'
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist/

      - name: Cleanup
        if: always()
        run: rm -rf dist build *.egg-info

Execution Timeline

Workflow triggered
Tag push: v1.2.3
2 minutes ago
Test & Build job started
ubuntu-latest
1 minute ago
Test & Build job completed
Success
30 seconds ago
Publish to PyPI job started
ubuntu-latest
25 seconds ago
Publish to PyPI job completed
Success
10 seconds ago

Optimization Tips

Cache Node Modules

Consider caching node_modules to speed up npm/yarn installs.

Parallelize Tests

Use pytest-xdist to run tests in parallel and reduce execution time.

Matrix Strategy

Test against multiple Python versions using a matrix strategy.

Made with DeepSite LogoDeepSite - 🧬 Remix