Skip to content
Latchkey

Upload Python Package workflow (ekzhu/datasketch)

The Upload Python Package workflow from ekzhu/datasketch, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: ekzhu/datasketch.github/workflows/pypi.ymlLicense MITView source

What it does

This is the Upload Python Package workflow from the ekzhu/datasketch repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
  workflow_dispatch:
    inputs:
      ref:
        description: "Tag to deploy"
        required: true

permissions:
  contents: read
  id-token: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: package

    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ github.event.inputs.ref }}
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.10"
          enable-cache: true

      - name: Build package
        run: uv build

      - name: Publish package to PyPI
        uses: pypa/gh-action-pypi-publish@v1.14.0

      - name: Minimize uv cache
        run: uv cache prune --ci

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
 
name: Upload Python Package
 
on:
  workflow_dispatch:
    inputs:
      ref:
        description: "Tag to deploy"
        required: true
 
permissions:
  contents: read
  id-token: write
 
jobs:
  deploy:
    timeout-minutes: 30
    runs-on: latchkey-small
    environment: package
 
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ github.event.inputs.ref }}
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.10"
          enable-cache: true
 
      - name: Build package
        run: uv build
 
      - name: Publish package to PyPI
        uses: pypa/gh-action-pypi-publish@v1.14.0
 
      - name: Minimize uv cache
        run: uv cache prune --ci
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow