Skip to content

Commit 634cb45

Browse files
committed
Bump bundled Syncthing to v1.30.0
1 parent 7788940 commit 634cb45

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

cmd/update-release/update-release.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,76 @@
3131
if 'tag_name' not in data:
3232
raise ValueError("tag_name not present in latest_url")
3333

34+
import urllib.request
35+
import json
36+
import semver
37+
38+
def get_latest_v1_tag_name(repo_owner, repo_name, allow_prerelease: bool = False):
39+
"""
40+
Fetches the latest v1 release tag_name from a GitHub repository's releases.
41+
42+
Args:
43+
repo_owner (str): The owner of the GitHub repository (e.g., 'syncthing').
44+
repo_name (str): The name of the GitHub repository (e.g., 'syncthing').
45+
46+
Returns:
47+
str or None: The tag_name of the latest v1 release, or None if not found.
48+
"""
49+
url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases"
50+
try:
51+
with urllib.request.urlopen(url) as response:
52+
if response.getcode() == 200:
53+
data = json.loads(response.read().decode('utf-8'))
54+
else:
55+
print(f"Error fetching data: HTTP {response.getcode()}")
56+
return None
57+
except urllib.error.URLError as e:
58+
print(f"Error connecting to GitHub API: {e.reason}")
59+
return None
60+
except json.JSONDecodeError:
61+
print("Error decoding JSON response.")
62+
return None
63+
64+
v1_releases = []
65+
for release in data:
66+
tag_name = release.get('tag_name')
67+
prerelease = release.get('prerelease')
68+
69+
if tag_name:
70+
try:
71+
version = semver.Version.parse(tag_name.lstrip('v')) # Remove 'v' prefix if present
72+
if allow_prerelease and version.major == 1 and version.prerelease:
73+
v1_releases.append(version)
74+
elif version.major == 1:
75+
v1_releases.append(version)
76+
except ValueError:
77+
# Not a valid semver string, skip
78+
continue
79+
80+
if not v1_releases:
81+
return None
82+
83+
# Sort the prereleases to find the latest
84+
latest_v1_release = max(v1_releases)
85+
return f"v{latest_v1_release}" # Re-add the 'v' prefix for consistency
86+
3487
###
3588
# Parse the tag version and generate CFBundleShortVersionString and CFBundleVersion
3689
###
90+
owner = "syncthing"
91+
repo = "syncthing"
92+
latest_tag = get_latest_v1_tag_name(owner, repo)
93+
94+
if latest_tag:
95+
print(f"The latest v1 release tag_name for {owner}/{repo} is: {latest_tag}")
96+
else:
97+
print(f"No v1 release found for {owner}/{repo}.")
3798

3899
# Ugly hack because of https://github.com/python-semver/python-semver/issues/137
39-
tag_name = data['tag_name'].replace('v', '')
100+
tag_name = latest_tag.replace('v', '')
40101
version = semver.VersionInfo.parse(tag_name)
41102

42-
CFBundleShortVersionString = "{}-{:d}".format(
103+
CFBundleShortVersionString = "{}+{:d}".format(
43104
str(version),
44105
distVersion)
45106
CFBundleVersion = "{:d}{:03d}{:03d}{:02d}".format(

syncthing/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>1.29.7-1</string>
22+
<string>1.30.0+1</string>
2323
<key>CFBundleVersion</key>
24-
<string>102900701</string>
24+
<string>103000001</string>
2525
<key>LSApplicationCategoryType</key>
2626
<string>public.app-category.utilities</string>
2727
<key>LSMinimumSystemVersion</key>

syncthing/Scripts/syncthing-resource.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
# Download and unpack syncthing into ${PRODUCT_NAME}.app/Contents/Resources
5-
SYNCTHING_VERSION="1.29.7"
5+
SYNCTHING_VERSION="1.30.0"
66
SYNCTHING_DIST_URL="https://github.com/syncthing/syncthing/releases/download"
77
SYNCTHING_TARBALL_URL="${SYNCTHING_DIST_URL}/v${SYNCTHING_VERSION}/syncthing-macos-universal-v${SYNCTHING_VERSION}.zip"
88

0 commit comments

Comments
 (0)