Semver icon

Semver

Semantic Versioning utilities for version management

Overview

The node provides semantic versioning (semver) utilities focused on sorting arrays of version strings. Specifically, the "Sorting" resource with the "Sort" operation sorts a list of version numbers in ascending order, while the "Reverse Sort" operation sorts them in descending order. This is useful when managing software versions, dependencies, or release pipelines where you need to organize versions chronologically or by precedence.

Practical examples:

  • Sorting a list of software package versions to find the earliest or latest release.
  • Organizing build artifacts by version number before deployment.
  • Preparing version lists for display or further processing in CI/CD workflows.

Properties

Name Meaning
Versions Comma-separated list of version strings to sort, e.g., 1.2.3,1.2.4,1.3.0
Options Collection of optional flags affecting parsing and sorting behavior:
- Loose: Whether to use loose parsing for version strings (boolean)
- Include Prerelease: Whether to include prerelease versions in range matching (boolean)
- RTL (Right to Left): Not applicable for sorting resource; shown only for coercion

Output

The output JSON contains the following structure:

{
  "operation": "sort" | "rsort",
  "versions": [ "1.2.3", "1.2.4", "1.3.0" ],
  "result": [ "sorted version array" ]
}
  • operation: Indicates whether the versions were sorted ascending (sort) or descending (rsort).
  • versions: The original input array of version strings.
  • result: The sorted array of version strings according to semantic versioning rules.

No binary data output is produced by this node.

Dependencies

  • Uses the external semver library for all version parsing and sorting logic.
  • No external API keys or services are required.
  • No special n8n environment variables or credentials needed.

Troubleshooting

  • Common issues:

    • Inputting invalid or malformed version strings may cause errors or unexpected results.
    • Empty or missing "Versions" property will result in an empty output array.
    • Using loose parsing incorrectly might lead to unexpected sorting if versions do not strictly follow semver.
  • Error messages:

    • Errors thrown by the underlying semver library (e.g., invalid version format) will be surfaced as error messages.
    • To handle errors gracefully, enable "Continue On Fail" in the node settings.

Links and References

Discussion