Skip to content
Latchkey

Build Wheels & Publish to PyPI workflow (tensorflow/transform)

The Build Wheels & Publish to PyPI workflow from tensorflow/transform, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, 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: tensorflow/transform.github/workflows/wheels.ymlLicense Apache-2.0View source

What it does

This is the Build Wheels & Publish to PyPI workflow from the tensorflow/transform repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

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

The workflow

workflow (.yml)
name: Build Wheels & Publish to PyPI

on:
  pull_request:
  workflow_dispatch:
  release:
    types: [published]

env:
  USE_BAZEL_VERSION: 7.7.0

jobs:
  build-package:
    name: Build sdist
    runs-on: ubuntu-latest
    steps:
    - name: Check out the repo
      uses: actions/checkout@v4

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

    - name: Install python dependencies
      run: |
        sudo apt update
        sudo apt install -y protobuf-compiler
        pip install --upgrade pip setuptools wheel numpy pyarrow build twine
        pip install --no-build-isolation .

    - name: Build sdist and wheel
      run: |
        python -m build --sdist --wheel --no-isolation -o wheelhouse

    - name: List and check sdist
      run: |
        ls -lh wheelhouse/
        twine check wheelhouse/*

    - name: Upload artifacts
      uses: actions/upload-artifact@v4
      with:
        name: sdist
        path: ./wheelhouse/*

  upload_to_pypi:
    name: Upload to PyPI
    runs-on: ubuntu-latest
    if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
    needs: [build-package]
    environment:
      name: pypi
      url: https://pypi.org/p/tensorflow-transform
    permissions:
      id-token: write
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          merge-multiple: true
          path: wheels/

      - name: List the build artifacts
        run: |
          ls -lAs wheels/

      - name: Upload to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1.12
        with:
          password: ${{ secrets.PYPI_API_TOKEN }}
          packages-dir: wheels/
          verify-metadata: false
          verbose: true

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: Build Wheels & Publish to PyPI
 
on:
  pull_request:
  workflow_dispatch:
  release:
    types: [published]
 
env:
  USE_BAZEL_VERSION: 7.7.0
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build-package:
    timeout-minutes: 30
    name: Build sdist
    runs-on: latchkey-small
    steps:
    - name: Check out the repo
      uses: actions/checkout@v4
 
    - name: Set up python
      uses: actions/setup-python@v5
      with:
        cache: 'pip'
        python-version: '3.10'
 
    - name: Install python dependencies
      run: |
        sudo apt update
        sudo apt install -y protobuf-compiler
        pip install --upgrade pip setuptools wheel numpy pyarrow build twine
        pip install --no-build-isolation .
 
    - name: Build sdist and wheel
      run: |
        python -m build --sdist --wheel --no-isolation -o wheelhouse
 
    - name: List and check sdist
      run: |
        ls -lh wheelhouse/
        twine check wheelhouse/*
 
    - name: Upload artifacts
      uses: actions/upload-artifact@v4
      with:
        name: sdist
        path: ./wheelhouse/*
 
  upload_to_pypi:
    timeout-minutes: 30
    name: Upload to PyPI
    runs-on: latchkey-small
    if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
    needs: [build-package]
    environment:
      name: pypi
      url: https://pypi.org/p/tensorflow-transform
    permissions:
      id-token: write
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          merge-multiple: true
          path: wheels/
 
      - name: List the build artifacts
        run: |
          ls -lAs wheels/
 
      - name: Upload to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1.12
        with:
          password: ${{ secrets.PYPI_API_TOKEN }}
          packages-dir: wheels/
          verify-metadata: false
          verbose: true
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

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

Actions used in this workflow