Skip to content

Commit b0a9b56

Browse files
committed
Use 'brew livecheck' to check for package updates
1 parent a8fab48 commit b0a9b56

File tree

3 files changed

+30
-87
lines changed

3 files changed

+30
-87
lines changed

.github/scripts/check-update.py

Lines changed: 27 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# FileName: check-update.py
2-
# SPDX-FileCopyrightText: (C) 2023 SeongTae Jeong <seongtaejg@gmail.com>
2+
# SPDX-FileCopyrightText: (C) 2024 SeongTae Jeong <seongtaejg@sqlitebrowser.org>
33
# SPDX-License-Identifier: BSD-2-Clause
44

55
"""
66
This script checks whether the package version of the formulae we're defining
7-
has been updated, and if so, notifies the maintainer by creating a Github Issue.
7+
has been updated, and if so, notifies the maintainer by creating a GitHub issue.
88
"""
99

10+
import json
1011
import os
11-
import re
12-
import requests
1312
import subprocess
1413
from enum import Enum
1514

@@ -79,73 +78,31 @@ def check_if_issue_exists():
7978
)
8079

8180

82-
def get_version_from_formula(formula_name):
83-
filepath = os.path.join(os.getcwd(), "Formula", formula_name + ".rb")
84-
with open(filepath, "r") as formula:
85-
formula_content = formula.read()
86-
version = re.search(r'version "(.*?)"', formula_content).group(1)
81+
def return_package_name_from_formula(formula):
82+
if formula == "sqlb-openssl@3":
83+
return Package.OPENSSL
84+
elif formula == "sqlb-qt@5":
85+
return Package.QT
86+
elif formula == "sqlb-sqlcipher":
87+
return Package.SQLCIPHER
88+
elif formula == "sqlb-sqlite":
89+
return Package.SQLITE
8790

88-
return version
8991

90-
91-
def check_sqlcipher_version():
92-
current_version = get_version_from_formula("sqlb-sqlcipher")
93-
94-
release_list = subprocess.check_output(
95-
"gh release list --repo sqlcipher/sqlcipher --limit 1", shell=True, text=True
96-
)
97-
latest_version = release_list.split()[0][1:]
98-
99-
if current_version != latest_version:
100-
return (Package.SQLCIPHER, current_version, latest_version)
101-
102-
103-
def check_sqlite_version():
104-
current_version = get_version_from_formula("sqlb-sqlite")
105-
106-
response = requests.get("https://sqlite.org/index.html")
107-
latest_version = (
108-
re.search(r"href=.*?releaselog/v?(\d+(?:[._]\d+)+)\.html", response.text)
109-
.group(1)
110-
.replace("_", ".")
111-
)
112-
113-
if current_version != latest_version:
114-
return (Package.SQLITE, current_version, latest_version)
115-
116-
117-
def check_openssl_version():
118-
current_version = get_version_from_formula("sqlb-openssl@3")
119-
120-
response = requests.get("https://www.openssl.org/source/")
121-
latest_version = re.findall(
122-
r"href=.*?openssl[._-]v?(\d+(?:\.\d+)+)\.t", response.text
123-
)[-1]
124-
125-
if current_version != latest_version:
126-
return (Package.OPENSSL, current_version, latest_version)
127-
128-
129-
def check_qt_version():
130-
current_version = get_version_from_formula("sqlb-qt@5")
131-
132-
response = requests.get(
133-
"https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/q/qt%405.rb"
92+
if __name__ == "__main__":
93+
data = json.loads(
94+
subprocess.run(
95+
"brew livecheck sqlb-openssl sqlb-qt sqlb-sqlcipher sqlb-sqlite --json",
96+
shell=True,
97+
capture_output=True,
98+
text=True,
99+
).stdout.strip()
134100
)
135-
latest_version = re.search(r'url "(.*?)"', response.text).group(1).split("/")[-3]
136-
137-
if current_version != latest_version:
138-
return (Package.QT, current_version, latest_version)
139-
101+
for formula in data:
102+
if formula["version"]["current"] != formula["version"]["latest"]:
103+
generate_issue(
104+
return_package_name_from_formula(formula["formula"]),
105+
formula["version"]["current"],
106+
formula["version"]["latest"],
107+
)
140108

141-
if __name__ == "__main__":
142-
functions = [
143-
check_sqlite_version,
144-
check_sqlcipher_version,
145-
check_openssl_version,
146-
check_qt_version,
147-
]
148-
for function in functions:
149-
response = function()
150-
if response is not None:
151-
generate_issue(response[0], response[1], response[2])

.github/scripts/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/check-for-packages-updates.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,13 @@ on:
88
jobs:
99
check:
1010
name: Check for packages updates
11-
runs-on: ubuntu-latest
11+
runs-on: macos-14
1212
steps:
13-
- uses: actions/checkout@v4
13+
- run: brew tap sqlitebrowser/tap
1414

15-
- name: Set up Python
16-
uses: actions/setup-python@v5
17-
with:
18-
cache: 'pip'
19-
python-version: '3.11.5'
20-
21-
- name: Install dependencies
22-
run: pip install -r ./.github/scripts/requirements.txt
23-
2415
- name: Run the script
2516
env:
2617
ASSIGNEES: ${{ vars.ASSIGNEES }}
2718
GITHUB_REPO: ${{ github.repository }}
2819
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
run: python3 ./.github/scripts/check-update.py
20+
run: curl https://raw.githubusercontent.com/sqlitebrowser/homebrew-tap/refs/heads/main/.github/scripts/check-update.py | python3

0 commit comments

Comments
 (0)