how to share set up python environment between jobs
07:01 11 Nov 2025

There's this github workflow to build & release python project:

name: build, test, release

on: push

jobs:
  build:
    name: build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        persist-credentials: false
    - name: set up py
      uses: actions/setup-python@v5
      with:
        python-version: "3.x"
    - name: Test
      run: |
        pip install '.[test-deps]'
        pytest
    - name: install build
      run: >-
        pip install build
    - name: build dist
      run: python -m build
    - name: store dist
      uses: actions/upload-artifact@v4
      with:
        name: python-package-distributions
        path: dist/
  release:
    name: Version & tag the release
    if: ${{ github.ref == 'refs/heads/main' }}
    needs:
    - build
    runs-on: ubuntu-latest

    steps:
    - name: download dist
      uses: actions/download-artifact@v4
      with:
        name: python-package-distributions
        path: dist/
    - name: install zest + release
      run: |
        pip install zest.releaser
        fullrelease

First we have the build job that

  • checks out code
  • sets up py env
  • tests code
  • installs build module
  • builds dist
  • uploads it to artifacts to share between jobs

Second we have a release job that's only to be ran on push to main branch which uses zest.releaser to automatically bump version and cut a tag.

It fails with "CRITICAL: No version control system detected" as it doesn't have the python env setup/tooling steps from build jobs cached.

What's a reasonable way to configure this workfow so steps from build jobs can be cached/reused in the release job?

python continuous-integration github-actions release