Set an output in GitHub Actions
Pass a value to a later step by appending name=value to the file in GITHUB_OUTPUT. The old set-output command is deprecated, and multiline values need a delimiter.
One step computes a version and a later step needs it, and the ::set-output command that every old guide shows is retired.
export GITHUB_OUTPUT=$(mktemp)
echo "version=1.4.2" >> "$GITHUB_OUTPUT"
{
echo "notes<<EOF_NOTES"
printf 'first change\nsecond change\n'
echo "EOF_NOTES"
} >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"version=1.4.2
notes<<EOF_NOTES
first change
second change
EOF_NOTESThe runner gives each step the path of a file in GITHUB_OUTPUT, and after the step finishes it reads name=value lines from it, as the workflow commands reference explains. Here a temporary file stands in for the runner's, so the output is exactly what the runner would parse. A later step reads the first value as steps.ID.outputs.version, when the step has id: ID.
A value that spans lines needs the name<<DELIMITER form shown, and the delimiter must not appear in the value. A random delimiter is safer when the value comes from untrusted input. The deprecated ::set-output command is no longer processed, and a step with no id has no outputs that others can name.