qbit_manage/scripts/update-readme-version.py

53 lines
1.8 KiB
Python
Raw Normal View History

4.1.1 (#528) * 4.1.1-develop * Updated docs * chore(docs): Sync wiki to docs [skip-cd] * chore(docs): Sync wiki to docs [skip-cd] * Fixes #522 * (docs): automatically add Supported Version to README (#521) * (docs): add version for qbit / qbit api to readme (#523) (cherry picked from commit 37e560f7ef5a69635acc0f76a5b88f7bd1aa05ce) * (docs): automate supported versions for readme (docs): readme updates (chore): fix pre-commit increase_version * (chore): automate supported version updates --------- Co-authored-by: bakerboy448 <mailto:55419169+bakerboy448@users.noreply.github.com> * Adds pre-commit hook to update-readme-version * Bump actions/setup-python from 4 to 5 (#525) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/checkout from 3 to 4 (#526) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump peter-evans/create-pull-request from 4 to 6 (#527) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 4 to 6. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v4...v6) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Dependabot to auto-update qbittorrent-api on master * 4.1.1 * fixes pre-commit on github actions --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Actionbot <actions@github.com> Co-authored-by: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Co-authored-by: bakerboy448 <mailto:55419169+bakerboy448@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-08 09:33:15 +08:00
import json
import re
import subprocess
import sys
try:
from qbittorrentapi import Version
except ImportError:
subprocess.check_call([sys.executable, "-m", "pip", "install", "qbittorrent-api"])
from qbittorrentapi import Version
# Check if a branch name was provided
if len(sys.argv) != 2:
print("Usage: python update_versions.py <branch_name>")
sys.exit(1)
branch_name = sys.argv[1]
print(f"Branch name: {branch_name}")
# Load or initialize the SUPPORTED_VERSIONS.json file
versions_file_path = "SUPPORTED_VERSIONS.json"
try:
with open(versions_file_path, encoding="utf-8") as file:
supported_versions = json.load(file)
except FileNotFoundError:
supported_versions = {}
# Extract the current qbittorrent-api version from requirements.txt
print("Reading requirements.txt...")
with open("requirements.txt", encoding="utf-8") as file:
requirements = file.read()
qbittorrent_api_version = re.search(r"qbittorrent-api==(.+)", requirements).group(1)
print(f"Current qbittorrent-api version: {qbittorrent_api_version}")
# Fetch the latest supported qBittorrent version
supported_version = Version.latest_supported_app_version()
print(f"Latest supported qBittorrent version: {supported_version}")
# Ensure the branch is initialized in the dictionary
if branch_name not in supported_versions:
supported_versions[branch_name] = {}
# Update the versions in the dictionary
supported_versions[branch_name]["qbit"] = supported_version
supported_versions[branch_name]["qbitapi"] = qbittorrent_api_version
print("Writing updated versions to SUPPORTED_VERSIONS.json...")
# Write the updated versions back to SUPPORTED_VERSIONS.json
with open(versions_file_path, "w", encoding="utf-8") as file:
json.dump(supported_versions, file, indent=4)
file.write("\n")