Shipfox
How-to GuidesAuthor Workflows

Pass a Computed Version to a Later Job

Publish a version from one job and use it in a later release-preview job.

Use this guide when one job computes a small value that another isolated job needs. The workflow derives a version from Git and prints it in a later job.

Before you begin

You need a project that can sync workflows and an online runner with the ubuntu-latest label. The repository must contain at least one Git commit.

Add the workflow

Create .shipfox/workflows/release-version.yml. This is a complete workflow:

# yaml-language-server: $schema=https://www.shipfox.io/docs/workflow.schema.json
name: Preview a release version
runner: ubuntu-latest

triggers:
  manual:
    source: manual
    event: fire

jobs:
  package:
    outputs:
      version: ${{ steps.read_version.outputs.version }}
    steps:
      - key: read_version
        run: echo "version=$(git describe --tags --always)" >> "$SHIPFOX_OUTPUT"
        outputs:
          version: string

  preview:
    needs: package
    steps:
      - run: |
          printf 'Release version: %s\n' "${{ jobs.package.outputs.version }}"

The read_version step declares and writes version. The package job publishes it. The preview job declares the dependency, reads the job output, and places it in the command.

A job output mapped from one expression preserves an inferred non-string source type. This lets a later job read a field from a structured JSON output:

# yaml-language-server: $schema=https://www.shipfox.io/docs/workflow.schema.json
jobs:
  review:
    outputs:
      findings: ${{ steps.inspect.outputs.findings }}
    steps:
      - key: inspect
        run: printf 'findings=%s\n' '[{"severity":"high"}]' >> "$SHIPFOX_OUTPUT"
        outputs:
          findings:
            type: json
            schema:
              type: array
              items:
                type: object
                additionalProperties: false
                required:
                  - severity
                properties:
                  severity:
                    type: string

  summarize:
    needs: review
    steps:
      - run: printf 'Severity: %s\n' "${{ jobs.review.outputs.findings[0].severity }}"

Mixed templates such as Finding: ${{ steps.inspect.outputs.findings }} remain strings. Sources without an inferred type also resolve to strings. See Job outputs for size limits.

Commit and push the file to the project's default branch. Wait for Preview a release version to sync.

Verify the value

Start the workflow from the Workflows tab.

  1. Open package and confirm that its outputs include version.
  2. Open preview and confirm that the printed version matches the package output.
  3. Confirm that preview ran in a separate job execution and did not rely on files from package.

Use Step outputs for declaration types and encoding. Use structured agent outputs when an agent, rather than a command, must produce the value.

Was this page helpful?
Edit this page on GitHub

On this page