release workflow (leptonai/leptonai)
The release workflow from leptonai/leptonai, explained and optimized by Latchkey.
CI health: D - needs work
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the release workflow from the leptonai/leptonai 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
name: release
on:
push:
branches: ["main"]
pull_request:
paths:
- .github/workflows/release.yaml
branches: ["**"]
workflow_dispatch:
inputs:
publish_pypi:
description: "Whether publish to PyPI"
type: boolean
default: false
is_release:
description: "Is this a release package"
type: boolean
default: false
run_e2e:
description: "Whether run end to end testing"
type: boolean
default: false
jobs:
build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python Environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set up pip
run: |
pip install -U pip setuptools
- name: Build Package
id: build-package
run: |
pip wheel --no-deps .
- name: Upload to Github Artifact
uses: actions/upload-artifact@v4
with:
name: whl-package
path: leptonai*.whl
test-package:
needs: build-package
strategy:
matrix:
include:
- runner: ubuntu-latest
python_version: "3.10"
- runner: macos-latest
python_version: "3.12"
- runner: ubuntu-latest
python_version: "3.13"
runs-on: ${{matrix.runner}}
steps:
- uses: actions/checkout@v3
- name: Set up Python Environment
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python_version }}"
- name: Set up pip
run: |
pip install -U pip setuptools
- uses: actions/download-artifact@v4
with:
name: whl-package
- name: Install Package
run: |
pip install leptonai*.whl
- name: Run Basic Tests
run: |
echo "leptonai package version:"
lep -v
cd ..
echo "leptonai package path:"
python -c "import leptonai; print(leptonai)"
cd -
- name: Run Unit Tests
run: |
whl_file=(leptonai*.whl)
pip install ${whl_file}[test]
cd ..
echo "Run unittests"
pytest -x leptonai
cd -
publish-pypi:
if: inputs.publish_pypi
needs: test-package
runs-on: ubuntu-latest
steps:
- name: Set up Python Environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set up pip
run: |
pip install -U pip setuptools
- name: Install twine
run: |
pip install twine
- uses: actions/download-artifact@v4
with:
name: whl-package
- name: Upload Package to PyPI
run: |
twine upload --verbose --username "${{ secrets.PYPI_UPLOAD_USERNAME }}" --password "${{ secrets.PYPI_UPLOAD_PASSWORD }}" leptonai*.whl
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 on: push: branches: ["main"] pull_request: paths: - .github/workflows/release.yaml branches: ["**"] workflow_dispatch: inputs: publish_pypi: description: "Whether publish to PyPI" type: boolean default: false is_release: description: "Is this a release package" type: boolean default: false run_e2e: description: "Whether run end to end testing" type: boolean default: false concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build-package: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Python Environment uses: actions/setup-python@v4 with: cache: 'pip' python-version: "3.10" - name: Set up pip run: | pip install -U pip setuptools - name: Build Package id: build-package run: | pip wheel --no-deps . - name: Upload to Github Artifact uses: actions/upload-artifact@v4 with: name: whl-package path: leptonai*.whl test-package: timeout-minutes: 30 needs: build-package strategy: matrix: include: - runner: ubuntu-latest python_version: "3.10" - runner: macos-latest python_version: "3.12" - runner: ubuntu-latest python_version: "3.13" runs-on: ${{matrix.runner}} steps: - uses: actions/checkout@v3 - name: Set up Python Environment uses: actions/setup-python@v4 with: cache: 'pip' python-version: "${{ matrix.python_version }}" - name: Set up pip run: | pip install -U pip setuptools - uses: actions/download-artifact@v4 with: name: whl-package - name: Install Package run: | pip install leptonai*.whl - name: Run Basic Tests run: | echo "leptonai package version:" lep -v cd .. echo "leptonai package path:" python -c "import leptonai; print(leptonai)" cd - - name: Run Unit Tests run: | whl_file=(leptonai*.whl) pip install ${whl_file}[test] cd .. echo "Run unittests" pytest -x leptonai cd - publish-pypi: timeout-minutes: 30 if: inputs.publish_pypi needs: test-package runs-on: latchkey-small steps: - name: Set up Python Environment uses: actions/setup-python@v4 with: cache: 'pip' python-version: "3.10" - name: Set up pip run: | pip install -U pip setuptools - name: Install twine run: | pip install twine - uses: actions/download-artifact@v4 with: name: whl-package - name: Upload Package to PyPI run: | twine upload --verbose --username "${{ secrets.PYPI_UPLOAD_USERNAME }}" --password "${{ secrets.PYPI_UPLOAD_PASSWORD }}" leptonai*.whl
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.
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 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.