Skip to content
Latchkey

Release workflow (learning-at-home/hivemind)

The Release workflow from learning-at-home/hivemind, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, 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: learning-at-home/hivemind.github/workflows/release.ymlLicense MITView source

What it does

This is the Release workflow from the learning-at-home/hivemind 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: Release

on:
  release:
    types: [ published ]

jobs:
  build-wheels:
    name: Build wheels for ${{ matrix.platform }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platform: [ linux-amd64, linux-arm64, darwin-amd64, darwin-arm64 ]
    steps:
      - uses: actions/checkout@v4

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

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: Key-v1-3.11-build

      - name: Install build dependencies
        run: |
          python -m pip install --upgrade pip build wheel

      - name: Build wheel for ${{ matrix.platform }}
        env:
          HIVEMIND_TARGET_PLATFORM: ${{ matrix.platform }}
        run: |
          python -m build --wheel

      - name: Retag wheel with platform-specific tag
        run: |
          case "${{ matrix.platform }}" in
            linux-amd64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=manylinux2014_x86_64 --remove dist/*.whl
              ;;
            linux-arm64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=manylinux2014_aarch64 --remove dist/*.whl
              ;;
            darwin-amd64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=macosx_10_9_x86_64 --remove dist/*.whl
              ;;
            darwin-arm64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=macosx_11_0_arm64 --remove dist/*.whl
              ;;
          esac

      - name: Verify wheel contents
        run: |
          python -m zipfile -l dist/*.whl | grep "hivemind_cli/p2pd"
          python -m wheel unpack dist/*.whl
          BINARY_PATH=$(echo hivemind-*/hivemind/hivemind_cli/p2pd)
          FILE_OUTPUT=$(file "$BINARY_PATH")
          echo "Binary info: $FILE_OUTPUT"

          case "${{ matrix.platform }}" in
            linux-amd64)
              echo "$FILE_OUTPUT" | grep -q "ELF 64-bit.*x86-64"
              ;;
            linux-arm64)
              echo "$FILE_OUTPUT" | grep -q "ELF 64-bit.*aarch64"
              ;;
            darwin-amd64)
              echo "$FILE_OUTPUT" | grep -q "Mach-O.*x86_64"
              ;;
            darwin-arm64)
              echo "$FILE_OUTPUT" | grep -q "Mach-O.*arm64"
              ;;
          esac
          echo "Verified: p2pd binary format matches ${{ matrix.platform }}"

      - name: Upload wheel artifacts
        uses: actions/upload-artifact@v4
        with:
          name: wheel-${{ matrix.platform }}
          path: dist/*.whl
          retention-days: 1

  build-sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: Key-v1-3.11-build

      - name: Install build dependencies
        run: |
          python -m pip install --upgrade pip build

      - name: Build source distribution
        run: |
          python -m build --sdist

      - name: Verify sdist contents
        run: |
          if tar -tzf dist/*.tar.gz | grep -q "hivemind_cli/p2pd"; then
            echo "Error: p2pd binary found in sdist"
            exit 1
          fi
          echo "p2pd binary not included in source distribution"

      - name: Upload sdist artifacts
        uses: actions/upload-artifact@v4
        with:
          name: sdist
          path: dist/*.tar.gz
          retention-days: 1

  publish:
    name: Publish to PyPI
    needs: [ build-wheels, build-sdist ]
    runs-on: ubuntu-latest
    permissions:
      id-token: write # Required for PyPI trusted publishing
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          pattern: "*"
          path: dist/
          merge-multiple: true

      - name: List distribution files
        run: |
          ls -la dist/
          echo "Total files: $(ls dist/ | wc -l)"

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist/
          verbose: true
          print-hash: 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
 
on:
  release:
    types: [ published ]
 
jobs:
  build-wheels:
    timeout-minutes: 30
    name: Build wheels for ${{ matrix.platform }}
    runs-on: latchkey-small
    strategy:
      matrix:
        platform: [ linux-amd64, linux-arm64, darwin-amd64, darwin-arm64 ]
    steps:
      - uses: actions/checkout@v4
 
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: '3.11'
 
      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: Key-v1-3.11-build
 
      - name: Install build dependencies
        run: |
          python -m pip install --upgrade pip build wheel
 
      - name: Build wheel for ${{ matrix.platform }}
        env:
          HIVEMIND_TARGET_PLATFORM: ${{ matrix.platform }}
        run: |
          python -m build --wheel
 
      - name: Retag wheel with platform-specific tag
        run: |
          case "${{ matrix.platform }}" in
            linux-amd64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=manylinux2014_x86_64 --remove dist/*.whl
              ;;
            linux-arm64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=manylinux2014_aarch64 --remove dist/*.whl
              ;;
            darwin-amd64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=macosx_10_9_x86_64 --remove dist/*.whl
              ;;
            darwin-arm64)
              wheel tags --python-tag=py3 --abi-tag=none --platform-tag=macosx_11_0_arm64 --remove dist/*.whl
              ;;
          esac
 
      - name: Verify wheel contents
        run: |
          python -m zipfile -l dist/*.whl | grep "hivemind_cli/p2pd"
          python -m wheel unpack dist/*.whl
          BINARY_PATH=$(echo hivemind-*/hivemind/hivemind_cli/p2pd)
          FILE_OUTPUT=$(file "$BINARY_PATH")
          echo "Binary info: $FILE_OUTPUT"
 
          case "${{ matrix.platform }}" in
            linux-amd64)
              echo "$FILE_OUTPUT" | grep -q "ELF 64-bit.*x86-64"
              ;;
            linux-arm64)
              echo "$FILE_OUTPUT" | grep -q "ELF 64-bit.*aarch64"
              ;;
            darwin-amd64)
              echo "$FILE_OUTPUT" | grep -q "Mach-O.*x86_64"
              ;;
            darwin-arm64)
              echo "$FILE_OUTPUT" | grep -q "Mach-O.*arm64"
              ;;
          esac
          echo "Verified: p2pd binary format matches ${{ matrix.platform }}"
 
      - name: Upload wheel artifacts
        uses: actions/upload-artifact@v4
        with:
          name: wheel-${{ matrix.platform }}
          path: dist/*.whl
          retention-days: 1
 
  build-sdist:
    timeout-minutes: 30
    name: Build source distribution
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
 
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: '3.11'
 
      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: Key-v1-3.11-build
 
      - name: Install build dependencies
        run: |
          python -m pip install --upgrade pip build
 
      - name: Build source distribution
        run: |
          python -m build --sdist
 
      - name: Verify sdist contents
        run: |
          if tar -tzf dist/*.tar.gz | grep -q "hivemind_cli/p2pd"; then
            echo "Error: p2pd binary found in sdist"
            exit 1
          fi
          echo "p2pd binary not included in source distribution"
 
      - name: Upload sdist artifacts
        uses: actions/upload-artifact@v4
        with:
          name: sdist
          path: dist/*.tar.gz
          retention-days: 1
 
  publish:
    timeout-minutes: 30
    name: Publish to PyPI
    needs: [ build-wheels, build-sdist ]
    runs-on: latchkey-small
    permissions:
      id-token: write # Required for PyPI trusted publishing
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          pattern: "*"
          path: dist/
          merge-multiple: true
 
      - name: List distribution files
        run: |
          ls -la dist/
          echo "Total files: $(ls dist/ | wc -l)"
 
      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist/
          verbose: true
          print-hash: 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 3 jobs (6 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