Release workflow (phonopy/phonopy)
The Release workflow from phonopy/phonopy, explained and optimized by Latchkey.
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.
What it does
This is the Release workflow from the phonopy/phonopy repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Release
# Build sdist + binary wheels and publish in one shot.
#
# - Push a tag "v*" (e.g. v4.1.0) -> publish to PyPI.
# - Run manually (workflow_dispatch) -> publish to TestPyPI.
#
# Publishing uses PyPI Trusted Publishing (OIDC); no API token secret is
# needed. The phonopy project must register this workflow as a trusted
# publisher on PyPI and TestPyPI, and the "pypi" / "testpypi" GitHub
# environments must exist.
on:
push:
tags: ["v*"]
workflow_dispatch:
jobs:
build_wheels:
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- windows-latest
- windows-11-arm
steps:
- uses: actions/checkout@v5
with:
# Full history + tags so setuptools_scm derives the version
# from the pushed "v*" tag instead of a dev/dirty fallback.
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==3.3.0
- name: Build wheels on ubuntu
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: "cp39-* pp* *_i686 *musllinux*"
CIBW_BUILD_VERBOSITY: 1
- name: Build wheels on macos
if: ${{ startsWith(matrix.os, 'macos') }}
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: "cp39-* pp*"
CIBW_BUILD_VERBOSITY: 1
- name: Build wheels on windows
if: ${{ startsWith(matrix.os, 'windows') }}
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: "cp39-* cp310-win_arm64 cp*-win32 pp*"
CIBW_BUILD_VERBOSITY: 1
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Build sdist
run: |
python -m pip install build
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: ./dist/*.tar.gz
publish_testpypi:
name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch'
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/phonopy
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v5
with:
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist
skip-existing: true
publish_pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/phonopy
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v5
with:
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
skip-existing: 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: Release # Build sdist + binary wheels and publish in one shot. # # - Push a tag "v*" (e.g. v4.1.0) -> publish to PyPI. # - Run manually (workflow_dispatch) -> publish to TestPyPI. # # Publishing uses PyPI Trusted Publishing (OIDC); no API token secret is # needed. The phonopy project must register this workflow as a trusted # publisher on PyPI and TestPyPI, and the "pypi" / "testpypi" GitHub # environments must exist. on: push: tags: ["v*"] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build_wheels: timeout-minutes: 30 name: Wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: - ubuntu-latest - ubuntu-24.04-arm - macos-latest - windows-latest - windows-11-arm steps: - uses: actions/checkout@v5 with: # Full history + tags so setuptools_scm derives the version # from the pushed "v*" tag instead of a dev/dirty fallback. fetch-depth: 0 - uses: actions/setup-python@v6 with: cache: 'pip' python-version: "3.13" - name: Install cibuildwheel run: python -m pip install cibuildwheel==3.3.0 - name: Build wheels on ubuntu if: ${{ startsWith(matrix.os, 'ubuntu') }} run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_SKIP: "cp39-* pp* *_i686 *musllinux*" CIBW_BUILD_VERBOSITY: 1 - name: Build wheels on macos if: ${{ startsWith(matrix.os, 'macos') }} run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_SKIP: "cp39-* pp*" CIBW_BUILD_VERBOSITY: 1 - name: Build wheels on windows if: ${{ startsWith(matrix.os, 'windows') }} run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_SKIP: "cp39-* cp310-win_arm64 cp*-win32 pp*" CIBW_BUILD_VERBOSITY: 1 - uses: actions/upload-artifact@v4 with: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl build_sdist: timeout-minutes: 30 name: Source distribution runs-on: latchkey-small steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - uses: actions/setup-python@v6 with: cache: 'pip' python-version: "3.13" - name: Build sdist run: | python -m pip install build python -m build --sdist - uses: actions/upload-artifact@v4 with: name: sdist path: ./dist/*.tar.gz publish_testpypi: timeout-minutes: 30 name: Publish to TestPyPI if: github.event_name == 'workflow_dispatch' needs: [build_wheels, build_sdist] runs-on: latchkey-small environment: name: testpypi url: https://test.pypi.org/p/phonopy permissions: id-token: write steps: - uses: actions/download-artifact@v5 with: path: dist merge-multiple: true - uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ packages-dir: dist skip-existing: true publish_pypi: timeout-minutes: 30 name: Publish to PyPI if: startsWith(github.ref, 'refs/tags/v') needs: [build_wheels, build_sdist] runs-on: latchkey-small environment: name: pypi url: https://pypi.org/p/phonopy permissions: id-token: write steps: - uses: actions/download-artifact@v5 with: path: dist merge-multiple: true - uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist skip-existing: true
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
This workflow runs 4 jobs (8 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.