Skip to content
Latchkey

libs - Release Publish to pypi workflow (michaelfeil/infinity)

The libs - Release Publish to pypi workflow from michaelfeil/infinity, 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: michaelfeil/infinity.github/workflows/pypi_release.yamlLicense MITView source

What it does

This is the libs - Release Publish to pypi workflow from the michaelfeil/infinity 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)
---
name: libs - Release Publish to pypi

on:
  release:
    types: [published]

env:
  POETRY_VERSION: "1.8.4"

jobs:
  publish-to-pypi:
    strategy:
      matrix:
        package:
          - workdir: "libs/infinity_emb"
          - workdir: "libs/client_infinity/infinity_client"
    defaults:
      run:
        working-directory: ${{ matrix.package.workdir }}
    runs-on: ubuntu-latest
    environment:
      name: publish
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
        uses: "./.github/actions/poetry_setup"
        with:
          python-version: "3.10"
          poetry-version: ${{ env.POETRY_VERSION }}
          working-directory: ${{ matrix.package.workdir }}
          cache-key: release

      - name: Copy readme
        if: matrix.package.workdir == 'libs/infinity_emb'
        id: readme-copy
        run: |
          cp ../../README.md .

      - name: Build project for distribution
        run: poetry build

      - name: Check Version
        id: check-version
        run: |
          echo version=$(poetry version --short) >> $GITHUB_OUTPUT

      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: ${{ matrix.package.workdir }}/dist/
          verbose: true
          print-hash: true
    
  modal-deploy:
    needs: publish-to-pypi
    uses: ./.github/workflows/release_modal_com.yaml
    secrets: inherit

The same workflow, on Latchkey

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

---
name: libs - Release Publish to pypi
 
on:
  release:
    types: [published]
 
env:
  POETRY_VERSION: "1.8.4"
 
jobs:
  publish-to-pypi:
    timeout-minutes: 30
    strategy:
      matrix:
        package:
          - workdir: "libs/infinity_emb"
          - workdir: "libs/client_infinity/infinity_client"
    defaults:
      run:
        working-directory: ${{ matrix.package.workdir }}
    runs-on: latchkey-small
    environment:
      name: publish
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
 
      - name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
        uses: "./.github/actions/poetry_setup"
        with:
          python-version: "3.10"
          poetry-version: ${{ env.POETRY_VERSION }}
          working-directory: ${{ matrix.package.workdir }}
          cache-key: release
 
      - name: Copy readme
        if: matrix.package.workdir == 'libs/infinity_emb'
        id: readme-copy
        run: |
          cp ../../README.md .
 
      - name: Build project for distribution
        run: poetry build
 
      - name: Check Version
        id: check-version
        run: |
          echo version=$(poetry version --short) >> $GITHUB_OUTPUT
 
      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: ${{ matrix.package.workdir }}/dist/
          verbose: true
          print-hash: true
    
  modal-deploy:
    timeout-minutes: 30
    needs: publish-to-pypi
    uses: ./.github/workflows/release_modal_com.yaml
    secrets: inherit
 

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.

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

Actions used in this workflow