{"id":15871072,"url":"https://github.com/sgreben/versions","last_synced_at":"2025-10-06T04:15:52.224Z","repository":{"id":80989014,"uuid":"135643078","full_name":"sgreben/versions","owner":"sgreben","description":"command-line version operations. single static binary. osx, linux, windows.","archived":false,"fork":false,"pushed_at":"2019-08-09T11:01:49.000Z","size":11888,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-04T11:22:50.512Z","etag":null,"topics":["cli","compare","docker","git","json","mvs","select","semver","solve","sort"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgreben.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-31T22:57:31.000Z","updated_at":"2023-08-24T15:44:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"af68f9df-9bf7-473e-a5c0-430fd6124d73","html_url":"https://github.com/sgreben/versions","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/sgreben/versions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fversions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fversions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fversions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fversions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgreben","download_url":"https://codeload.github.com/sgreben/versions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fversions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278557241,"owners_count":26006295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","compare","docker","git","json","mvs","select","semver","solve","sort"],"created_at":"2024-10-06T00:41:39.007Z","updated_at":"2025-10-06T04:15:52.177Z","avatar_url":"https://github.com/sgreben.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# versions\n\n`versions` is a tool for working with (SemVer) versions on the command-line.\n\nSupported operations:\n\n- Compare versions\n- Sort versions\n- Select versions given a constraint\n- Fetch versions from Git tags\n- Fetch versions from Docker image tags\n- Dependency version selection using [MVS](https://research.swtch.com/vgo-mvs)\n\n## Contents\n\n- [Contents](#contents)\n- [Get it](#get-it)\n- [Use it](#use-it)\n    - [Compare versions](#compare-versions)\n    - [Sort versions](#sort-versions)\n    - [Select versions](#select-versions)\n    - [Solve constraint graphs](#solve-constraint-graphs)\n    - [Fetch versions](#fetch-versions)\n    - [JSON output](#json-output)\n    - [Sort order](#sort-order)\n    - [Shell completion](#shell-completion)\n- [Licensing](#licensing)\n- [Comments](#comments)\n\n## Get it\n\nUsing go get:\n\n```sh\ngo get -u github.com/sgreben/versions/cmd/versions\n```\n\nOr [download the binary](https://github.com/sgreben/versions/releases/latest) from the releases page.\n\n```sh\n# Linux\ncurl -L https://github.com/sgreben/versions/releases/download/1.1.6/versions_1.1.6_linux_x86_64.tar.gz | tar xz\n\n# OS X\ncurl -L https://github.com/sgreben/versions/releases/download/1.1.6/versions_1.1.6_osx_x86_64.tar.gz | tar xz\n\n# Windows\ncurl -LO https://github.com/sgreben/versions/releases/download/1.1.6/versions_1.1.6_windows_x86_64.zip\nunzip versions_1.1.6_windows_x86_64.zip\n```\n\nAlso available as a [docker image](https://quay.io/repository/sergey_grebenshchikov/versions?tab=tags):\n\n```sh\ndocker run quay.io/sergey_grebenshchikov/versions\n```\n\n## Use it\n\n```text\nUsage: versions COMMAND [arg...]\n\ndo things with versions\n\nOptions:\n      --indent   Set the indentation of JSON output (default 0)\n  -q, --quiet    Disable all log output (stderr)\n  -s, --silent   Disable all log output (stderr) and all normal output (stdout)\n\nCommands:\n  sort         Sort versions\n  compare      Compare versions\n  fetch        Fetch versions\n  select       Select versions given constraints\n  complete     Shell completion (zsh, fish, bash)\n  help         Display help for a command\n\nRun 'versions COMMAND --help' for more information on a command.\n```\n\n### Compare versions\n\n```text\nUsage: versions compare [OPTIONS] COMMAND [arg...]\n\nCompare versions\n\nOptions:\n      --fail   Exit with non-zero code if the result is 'false'\n\nCommands:\n  later        Check if a version is strictly later than another version\n  earlier      Check if a version is strictly earlier than another version\n\nRun 'versions compare COMMAND --help' for more information on a command.\n```\n\n#### Output a single boolean indicating whether one version is later than another\n\n```sh\n$ versions compare later 1.0.0 0.1.0\n```\n```json\ntrue\n```\n\n```sh\n$ versions compare later 1.0.0 2.1.0\n```\n```json\nfalse\n```\n\n### Sort versions\n\n```text\nUsage: versions sort [OPTIONS] [VERSIONS...]\n\nSort versions\n\nArguments:\n  VERSIONS       Versions to sort\n\nOptions:\n  -l, --latest   Print only the latest `N` versions (default 0)\n```\n\n#### Print versions in oldest-to-newest order\n\n```sh\n$ versions sort 2.0.0 0.1.0 10.0.0\n```\n```json\n[\"0.1.0\",\"2.0.0\",\"10.0.0\"]\n```\n\n#### Print the latest N versions in oldest-to-newest order\n\n```sh\n$ versions --latest=2 sort 2.0.0 0.1.0 10.0.0\n```\n```json\n[\"2.0.0\",\"10.0.0\"]\n```\n\n### Select versions\n\n```text\nUsage: versions select [OPTIONS] COMMAND [arg...]\n\nSelect versions given constraints\n\nOptions:\n      --from-git      Fetch candidate versions from Git tags\n      --from-docker   Fetch candidate versions from Docker tags\n\nCommands:\n  single              Select a single version\n  all                 Select all matching versions\n  mvs                 Select versions to satisfy a constraint graph using MVS (https://research.swtch.com/vgo-mvs)\n\nRun 'versions select COMMAND --help' for more information on a command.\n```\n\n#### Select the single latest version satisfying the given constraint\n\n```sh\n$ versions select single '2.*.*' 2.0.0 2.0.1 0.1.0 10.0.0\n```\n```json\n\"2.0.1\"\n```\n\n```sh\n$ versions select single '*' 2.0.0 2.0.1 0.1.0 10.0.0\n```\n```json\n\"10.0.0\"\n```\n\n```sh\n$ versions select single '^0.0.1' 2.0.0 2.0.1 0.1.0 10.0.0\n```\n```json\n\"0.1.0\"\n```\n\n#### Select all versions satisfying the given constraint\n\n```sh\n$ versions select all '2.*.*' 2.0.0 2.0.1 0.1.0 10.0.0\n```\n```json\n[\"2.0.0\", \"2.0.1\"]\n```\n\n#### Select the single latest version from Git tags satisfying the given constraint\n\n```sh\n$ versions select --from-git=https://github.com/sgreben/jp single '~1.0.0'\n```\n```json\n\"1.0.1\"\n```\n\n```sh\n$ versions select --from-git=https://github.com/sgreben/jp single '^1.0.0'\n```\n```json\n\"1.1.11\"\n```\n\n#### Select the single latest version from Docker tags satisfying the given constraint\n\n```sh\n$ versions select --from-docker=alpine single '\u003c3.7'\n```\n```json\n\"3.6.0\"\n```\n\n```sh\n$ versions select --from-docker=alpine single '^3.0.0'\n```\n```json\n\"3.7.0\"\n```\n\n### Solve constraint graphs\n\n```text\nUsage: versions select mvs CONSTRAINTS...\n\nSelect versions to satisfy a constraint graph using MVS (https://research.swtch.com/vgo-mvs)\n\nArguments:\n  CONSTRAINTS   constraint graph (JSON structure: {\"my-package\":{\"1.0\": {\"other-package\":\"~0.0.1\"}}})\n```\n\n#### Select a set of versions using MVS\n\n\u003e Minimal version selection **always selects the minimal (oldest) module version** that satisfies the overall requirements of a build.\n\nConsider the three packages `A`, `B`, and `C`, where\n\n- `A` is \"our\" package\n- `B` has versions `1.0.0` and `2.0.0`\n- `C` also has versions `1.0.0` and `2.0.0`\n\n`A` depends on both `B` and `C`, and each version of `B` depends on the same version of `C`.\n\nIf `A` does not explicitly demand `B` version `2.0.0`, MVS will select `1.0.0` for both dependencies.\n\n```sh\n$ versions select mvs '{\n    \"A\": {\"*\": {\"B\":\"\u003e=1.0.0\", \"C\":\"~1.0.0\"}},\n    \"B\": {\n        \"1.0.0\": {\"C\":\"1.*.*\"},\n        \"2.0.0\": {\"C\":\"2.*.*\"}\n    },\n    \"C\": {\n        \"1.0.0\":{},\n        \"2.0.0\":{}\n    }\n}'\n```\n```json\n{\"Selected\":{\"B\":\"1.0.0\",\"C\":\"1.0.0\"},\"Relaxed\":{}}\n```\n\nOn the other hand, if `A` *does* explicitly demand `B \u003e= 2.0.0`, MVS will upgrade `B` to `2.0.0`, but also have to upgrade `C` to `2.0.0` due to `B`'s constraint.\nMVS does not support \"maximum versions\", thus the constraint `C~1.0.0` of `A` must be relaxed to obtain a solution:\n\n```sh\n$ versions select mvs '{\n    \"A\": {\"*\": {\"B\":\"\u003e=2.0.0\", \"C\":\"~1.0.0\"}},\n    \"B\": {\n        \"1.0.0\": {\"C\":\"1.*.*\"},\n        \"2.0.0\": {\"C\":\"2.*.*\"}\n    },\n    \"C\": {\n        \"1.0.0\":{},\n        \"2.0.0\":{}\n    }\n}'\n```\n```json\n{\"Selected\":{\"B\":\"2.0.0\",\"C\":\"2.0.0\"},\"Relaxed\":{\"A\":{\"C\":\"~1.0.0\"}}}\n```\n\nThe constraints can also be provided via multiple JSON arguments:\n\n```sh\nversions select mvs \\\n  '{\"A\": {\"*\": {\"B\":\"\u003e=2.0.0\", \"C\":\"~1.0.0\"}}}' \\\n  '{\"B\": {\"1.0.0\": {\"C\":\"1.*.*\"}, \"2.0.0\": {\"C\":\"2.*.*\"}}}' \\\n  '{\"C\": {\"1.0.0\":{}, \"2.0.0\":{}}}'\n```\n```json\n{\"Selected\":{\"B\":\"2.0.0\",\"C\":\"2.0.0\"},\"Relaxed\":{\"A\":{\"C\":\"~1.0.0\"}}}\n```\n\n### Fetch versions\n\n```text\nUsage: versions fetch [OPTIONS] COMMAND [arg...]\n\nFetch versions\n\nOptions:\n  -l, --latest   Print only the latest `N` versions (default 0)\n\nCommands:\n  git            Fetch versions from Git tags\n  docker         Fetch versions from Docker image tags\n\nRun 'versions fetch COMMAND --help' for more information on a command.\n```\n\n#### Fetch and interpret all SemVer git tags as versions\n\n```sh\n$ versions --indent=2 fetch git https://github.com/sgreben/jp\n```\n```json\n[\n  {\n    \"Version\": \"1.0.0\",\n    \"Source\": {\n      \"Git\": {\n        \"Repository\": {\n          \"URL\": \"https://github.com/sgreben/jp\"\n        },\n        \"Reference\": \"refs/tags/1.0.0\"\n      }\n    }\n  },\n  {\n    \"Version\": \"1.0.1\",\n    \"Source\": {\n      \"Git\": {\n        \"Repository\": {\n          \"URL\": \"https://github.com/sgreben/jp\"\n        },\n        \"Reference\": \"refs/tags/1.0.1\"\n  // ...\n]\n```\n\n#### Fetch and determine the latest version from Git tags\n\n```sh\n$ versions fetch -l 1 git https://github.com/sgreben/jp\n```\n```json\n[{\"Version\":\"1.1.11\",\"Source\":{\"Git\":{\"Repository\":{\"URL\":\"https://github.com/sgreben/jp\"},\"Reference\":\"refs/tags/1.1.11\"}}}]\n```\n\n\n#### Fetch and interpret all Docker image tags as versions\n\n```sh\n$ versions --indent=2 fetch docker alpine\n```\n```json\n[\n  {\n    \"Version\": \"2.6.0\",\n    \"Source\": {\n      \"Docker\": {\n        \"Image\": \"library/alpine:2.6\",\n        \"Tag\": \"2.6\"\n      }\n    }\n  },\n  {\n    \"Version\": \"2.7.0\",\n    \"Source\": {\n      \"Docker\": {\n        \"Image\": \"library/alpine:2.7\",\n        \"Tag\": \"2.7\"\n      }\n    }\n  },\n  // ...\n]\n```\n\n#### Fetch and determine the latest version from Docker image tags\n\n```sh\n$ versions fetch -l 1 docker alpine\n```\n```json\n[{\"Version\":\"3.7.0\",\"Source\":{\"Docker\":{\"Image\":\"library/alpine:3.7\",\"Tag\":\"3.7\"}}}]\n```\n\n### JSON output\n\nThe default output format is JSON, one value per line:\n\n```sh\n$ versions sort 0.10 0.2 1.0 1.1 1.1.1-rc1 1.1.1\n```\n```json\n[\"0.2.0\",\"0.10.0\",\"1.0.0\",\"1.1.0\",\"1.1.1-rc1\",\"1.1.1\"]\n```\n\nTo output multi-line indented JSON, specify a value for the `--indent` option:\n\n\n```sh\n$ versions --indent=2 sort 0.10 0.2 1.0 1.1 1.1.1-rc1 1.1.1\n```\n```json\n[\n  \"0.2.0\",\n  \"0.10.0\",\n  \"1.0.0\",\n  \"1.1.0\",\n  \"1.1.1-rc1\",\n  \"1.1.1\"\n]\n```\n\n### Sort order\n\nAll commands that produce sorted lists of versions produce them in the **oldest-first**, **latest-last** order:\n\n```sh\n$ versions sort 0.0.1 1.0.0\n```\n```json\n[\"0.0.1\",\"1.0.0\"]\n```\n\n### Shell completion\n\nThe tool can install shell (`zsh`, `fish`, `bash`) completion for itself:\n\n```text\nUsage: versions complete COMMAND [arg...]\n\nShell completion (zsh, fish, bash)\n\nCommands:\n  install      Install all completions\n  uninstall    Uninstall all completions\n\nRun 'versions complete COMMAND --help' for more information on a command.\n```\n\n```sh\n$ versions complete install\n$ tail -n1 ~/.zshrc\ncomplete -o nospace -C /go/bin/versions versions\n```\n\n```sh\n$ versions \u003cTAB\u003e\ncompare  fetch    help     select   sort\n```\n```sh\n$ versions select -\u003cTAB\u003e\n--from-docker  --from-git     --help         -h\n```\n\n## Licensing\n\n- Any original code is licensed under the [MIT License](./LICENSE).\n- The included version of [github.com/Masterminds/semver](https://github.com/Masterminds/semver) is licensed under [what looks like the MIT license](https://github.com/Masterminds/semver/blob/c7af12943936e8c39859482e61f0574c2fd7fc75/LICENSE.txt).\n- Included portions of [github.com/kubernetes/client-go](https://github.com/kubernetes/client-go/tree/master/util/jsonpath) are licensed under the Apache License 2.0.\n\n## Comments\n\nFeel free to [leave a comment](https://github.com/sgreben/versions/issues/1) or create an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgreben%2Fversions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgreben%2Fversions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgreben%2Fversions/lists"}