build/status: fix version sorting

The removed comment claimed that version strings can be sorted 
lexicographically, but that only works as long as all parts of the 
version are less than 10.

Instead, use the version-aware sorting of git-tag.

Manual testing steps:

git tag metropolis-v0.3.0
git tag metropolis-v0.21.0
git tag metropolis-v0.22.0
./build/print-workspace-status.py
# Expected output contains: metropolis_version v0.22.0
# Cleanup:
git tag -d metropolis-v0.3.0 metropolis-v0.21.0 metropolis-v0.22.0

Change-Id: I7f0f989845e4d9f940bf01bd2cc6a535b4d4a589
Reviewed-on: https://review.monogon.dev/c/monogon/+/2922
Vouch-Run-CI: Serge Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/build/print-workspace-status.py b/build/print-workspace-status.py
index af62079..2838730 100755
--- a/build/print-workspace-status.py
+++ b/build/print-workspace-status.py
@@ -47,7 +47,7 @@
 
 # Git tags pointing at this commit.
 git_tags_b: [bytes] = subprocess.check_output(
-    ["git", "tag", "--points-at", "HEAD"]
+    ["git", "tag", "--sort=-version:refname", "--points-at", "HEAD"]
 ).split(b"\n")
 git_tags: [str] = [t.decode().strip() for t in git_tags_b if t.decode().strip() != ""]
 
@@ -95,19 +95,12 @@
 
 
 for product in ["metropolis", "cloud"]:
-    versions = []
-    # Get exact versions from tags.
+    # Get exact version from tags.
+    version = None
     for tag in git_tags:
         version = parse_tag(tag, product)
-        if version is None:
-            continue
-        versions.append(version)
-    version = None
-    if len(versions) > 0:
-        # Find the highest version and use that. Lexicographic sort is good enough
-        # for the limited subset of semver we support.
-        versions.sort(reverse=True)
-        version = versions[0]
+        if version is not None:
+            break
 
     if version is None:
         # No exact version found. Use latest tag for the given product and
@@ -115,7 +108,7 @@
         # tag.
         for tag in (
             subprocess.check_output(
-                ["git", "tag", "--sort=-refname", "--merged", "HEAD"]
+                ["git", "tag", "--sort=-version:refname", "--merged", "HEAD"]
             )
             .decode()
             .strip()