diff --git a/download-latest-firmware-build.py b/download-latest-firmware-build.py
index 9e1f6b1a12bf669b0e3c97bd405efe8365a6e0f7..952bbedb4f49836d767d2ba9d00384fad6c733ca 100755
--- a/download-latest-firmware-build.py
+++ b/download-latest-firmware-build.py
@@ -25,10 +25,10 @@ ap.add_argument("--branch", help="Download only builds of this branch")
 args = ap.parse_args()
 
 def find_version_from_archive(archive_file_list):
+    version_regex = re.compile(r'gluon-ffs-(((experimental|[0-9]+\.[0-9])+[+][0-9]{4}-[0-9]{2}-[0-9]{2})-g\.[a-f0-9]+-s\.[a-f0-9]+)-')
     for file in archive_file_list:
         if file.filename.startswith("gluon/output/images"):
             filename = os.path.basename(file.filename)
-            version_regex = re.compile(r'gluon-ffs-(((experimental|[0-9]+\.[0-9])+[+][0-9]{4}-[0-9]{2}-[0-9]{2})-g\.[a-f0-9]+-s\.[a-f0-9]+-)')
             version_matches = version_regex.match(filename)
             if version_matches:
                 version = version_matches.group(1)