Interview Prep/GitHub Actions/Contexts, Expressions, Env & Outputs

How do you compare semantic versions or do arithmetic in expressions?

AdvancedConceptContexts, Expressions, Env & Outputs
Answer

You do not: expressions have no arithmetic or version comparison functions, and numeric comparison of '1.10' vs '1.9' gives the wrong answer. Do it in a step with real tools and expose the result as an output:

if [ "$(printf '%s\n' "$CURRENT" "$NEW" | sort -V | tail -1)" = "$NEW" ]; then
  echo "is_newer=true" >> "$GITHUB_OUTPUT"
fi

Keep expressions to routing logic; put computation in scripts that you can test locally.

All GitHub Actions questions Roadmap: GitHub Actions

More on Contexts, Expressions, Env & Outputs