From 07cf7fea903b5492caf598e05af298b817fb4ed7 Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Wed, 19 Nov 2025 02:10:36 +0300 Subject: [PATCH] Revert "Merge branch 'main' of https://github.com/LoaderSpot/LoaderSpot" This reverts commit e5cd9655305c09a1aa806f8eb3345cddcb41ea3b, reversing changes made to c77736ccc5b12761b295a043abe6921e1016142c. --- .github/workflows/update_versions.yml | 76 +++++++++-- update_version.py | 37 ++++-- versions.json | 180 -------------------------- 3 files changed, 88 insertions(+), 205 deletions(-) diff --git a/.github/workflows/update_versions.yml b/.github/workflows/update_versions.yml index 72dc87a..47b4ab2 100644 --- a/.github/workflows/update_versions.yml +++ b/.github/workflows/update_versions.yml @@ -1,5 +1,4 @@ name: Update Version - on: workflow_dispatch: inputs: @@ -13,33 +12,82 @@ on: description: 'Build type (e.g., Master, Release)' required: false default: 'false' + jobs: update-version: runs-on: ubuntu-latest permissions: contents: write - steps: - name: Checkout repository uses: actions/checkout@v5 with: token: ${{ secrets.PERSONAL_TOKEN }} - + - name: Set up Python uses: actions/setup-python@v6 with: python-version: 3.12.2 - - - name: Update version in versions.json - run: | - data="${{ github.event.inputs.datajson }}" - build_type="${{ github.event.inputs.buildType }}" - python3 update_version.py "$data" "$build_type" - - - name: Commit changes + + - name: Update version and commit with retry + env: + DATA_JSON: ${{ github.event.inputs.datajson }} + BUILD_TYPE: ${{ github.event.inputs.buildType }} + VERSION: ${{ github.event.inputs.version }} + GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add versions.json - git commit -m "Added version ${{ github.event.inputs.version }}" - git push "https://${{ secrets.PERSONAL_TOKEN }}@github.com/${{ github.repository }}.git" HEAD:main + + MAX_RETRIES=20 # Увеличено с 10 до 20 + RETRY_COUNT=0 + + # Случайная задержка 0-10 секунд в начале + RANDOM_DELAY=$((RANDOM % 10)) + echo "Initial random delay: ${RANDOM_DELAY}s" + sleep $RANDOM_DELAY + + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + echo "Attempt $((RETRY_COUNT + 1)) of $MAX_RETRIES" + + # Fetch latest changes + git fetch origin main + + # Reset to remote state (discard local commits) + git reset --hard origin/main + + # Re-checkout to ensure clean state + git checkout main + + # Run Python script on fresh data + # Передаём через отдельную переменную окружения (обходим bash экранирование) + DATA_JSON_ENV="$DATA_JSON" python3 update_version.py "$BUILD_TYPE" + + # Check if there are changes + if ! git diff --quiet versions.json; then + git add versions.json + git commit -m "Added version $VERSION" + + # Try to push + if git push "https://$GITHUB_TOKEN@github.com/${{ github.repository }}.git" HEAD:main; then + echo "✅ Successfully pushed version $VERSION" + exit 0 + else + echo "⚠️ Push failed, retrying..." + RETRY_COUNT=$((RETRY_COUNT + 1)) + + # Экспоненциальная задержка с jitter (случайностью) + BASE_DELAY=$((RETRY_COUNT * 2)) + JITTER=$((RANDOM % 5)) + TOTAL_DELAY=$((BASE_DELAY + JITTER)) + echo "Waiting ${TOTAL_DELAY}s before retry..." + sleep $TOTAL_DELAY + fi + else + echo "ℹ️ No changes detected in versions.json" + exit 0 + fi + done + + echo "❌ Failed to push after $MAX_RETRIES attempts" + exit 1 diff --git a/update_version.py b/update_version.py index 36ed54c..c37586b 100644 --- a/update_version.py +++ b/update_version.py @@ -2,11 +2,19 @@ import json import re import sys +import os -def update_version(data_json: str, build_type: str = None, version_file: str = "versions.json") -> bool: +def update_version(data_input, build_type: str = None, version_file: str = "versions.json") -> bool: try: - data = json.loads(data_json) + # Если это путь к файлу + if os.path.isfile(data_input): + with open(data_input, 'r', encoding='utf-8') as f: + data = json.load(f) + # Если это JSON строка + else: + data = json.loads(data_input) + version_key = list(data.keys())[0] version_data = data[version_key] @@ -38,8 +46,8 @@ def update_version(data_json: str, build_type: str = None, version_file: str = " except json.JSONDecodeError as e: print(f"JSON parse error: {e}", file=sys.stderr) return False - except FileNotFoundError: - print(f"File {version_file} not found", file=sys.stderr) + except FileNotFoundError as e: + print(f"File not found: {e}", file=sys.stderr) return False except Exception as e: print(f"Error: {e}", file=sys.stderr) @@ -47,15 +55,22 @@ def update_version(data_json: str, build_type: str = None, version_file: str = " def main(): - if len(sys.argv) < 2: - print("Usage: python update_version.py '' [build_type] [version_file]", file=sys.stderr) + # Проверяем переменную окружения DATA_JSON_ENV (приоритет) + if 'DATA_JSON_ENV' in os.environ: + data_input = os.environ['DATA_JSON_ENV'] + build_type = sys.argv[1] if len(sys.argv) > 1 else None + version_file = sys.argv[2] if len(sys.argv) > 2 else "versions.json" + # Иначе используем аргументы командной строки + elif len(sys.argv) >= 2: + data_input = sys.argv[1] # Может быть путь к файлу или JSON строка + build_type = sys.argv[2] if len(sys.argv) > 2 else None + version_file = sys.argv[3] if len(sys.argv) > 3 else "versions.json" + else: + print("Usage: python update_version.py [build_type] [version_file]", file=sys.stderr) + print("Or set DATA_JSON_ENV environment variable", file=sys.stderr) sys.exit(1) - data_json = sys.argv[1] - build_type = sys.argv[2] if len(sys.argv) > 2 else None - version_file = sys.argv[3] if len(sys.argv) > 3 else "versions.json" - - success = update_version(data_json, build_type, version_file) + success = update_version(data_input, build_type, version_file) sys.exit(0 if success else 1) diff --git a/versions.json b/versions.json index f5912fe..fbfb46f 100644 --- a/versions.json +++ b/versions.json @@ -1,19 +1,4 @@ { - "1.2.77.357": { - "buildType": "Release", - "fullversion": "1.2.77.357.g6a28e474", - "links": { - "win": { - "x86": "", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.77.357.g6a28e474-429.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.77.357.g6a28e474-429.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.77.357.g6a28e474-439.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.77.357.g6a28e474-429.tbz" - } - } - }, "1.2.77.352": { "buildType": "Release", "fullversion": "1.2.77.352.g26264c50", @@ -1004,21 +989,6 @@ } } }, - "1.2.62.398": { - "buildType": "Master", - "fullversion": "1.2.62.398.g54159197", - "links": { - "win": { - "x86": "", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.62.398.g54159197-824.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.62.398.g54159197-827.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.62.398.g54159197-2520.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.62.398.g54159197-2498.tbz" - } - } - }, "1.2.61.443": { "buildType": "Release", "fullversion": "1.2.61.443.gc51c574b", @@ -1259,36 +1229,6 @@ } } }, - "1.2.58.354": { - "buildType": "Master", - "fullversion": "1.2.58.354.ga9e5d5dd", - "links": { - "win": { - "x86": "", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.58.354.ga9e5d5dd-3974.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.58.354.ga9e5d5dd-3988.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.58.354.ga9e5d5dd-1465.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.58.354.ga9e5d5dd-1458.tbz" - } - } - }, - "1.2.58.318": { - "buildType": "Master", - "fullversion": "1.2.58.318.gc4769917", - "links": { - "win": { - "x86": "", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.58.318.gc4769917-3858.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.58.318.gc4769917-3872.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.58.318.gc4769917-1352.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.58.318.gc4769917-1346.tbz" - } - } - }, "1.2.57.463": { "buildType": "Release", "fullversion": "1.2.57.463.g4f748c64", @@ -1319,21 +1259,6 @@ } } }, - "1.2.57.301": { - "buildType": "Master", - "fullversion": "1.2.57.301.gb804e5ce", - "links": { - "win": { - "x86": "", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.57.301.gb804e5ce-2525.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.57.301.gb804e5ce-2544.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.57.301.gb804e5ce-78.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.57.301.gb804e5ce-76.tbz" - } - } - }, "1.2.57.248": { "buildType": "Master", "fullversion": "1.2.57.248.g99e4f91e", @@ -1394,21 +1319,6 @@ } } }, - "1.2.56.259": { - "buildType": "Master", - "fullversion": "1.2.56.259.g35fc40b3", - "links": { - "win": { - "x86": "", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.56.259.g35fc40b3-1013.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.56.259.g35fc40b3-1016.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.56.259.g35fc40b3-1083.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.56.259.g35fc40b3-1080.tbz" - } - } - }, "1.2.55.235": { "buildType": "Release", "fullversion": "1.2.55.235.g5eaa0904", @@ -1484,36 +1394,6 @@ } } }, - "1.2.53.259": { - "buildType": "Master", - "fullversion": "1.2.53.259.gecba76ba", - "links": { - "win": { - "x86": "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-1.2.53.259.gecba76ba-1080.exe", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.53.259.gecba76ba-1082.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.53.259.gecba76ba-1077.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.53.259.gecba76ba-1771.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.53.259.gecba76ba-1764.tbz" - } - } - }, - "1.2.53.257": { - "buildType": "Master", - "fullversion": "1.2.53.257.g47fa6c39", - "links": { - "win": { - "x86": "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-1.2.53.257.g47fa6c39-1076.exe", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.53.257.g47fa6c39-1078.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.53.257.g47fa6c39-1073.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.53.257.g47fa6c39-1767.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.53.257.g47fa6c39-1760.tbz" - } - } - }, "1.2.52.442": { "buildType": "Release", "fullversion": "1.2.52.442.g01893f92", @@ -1529,51 +1409,6 @@ } } }, - "1.2.52.402": { - "buildType": "Master", - "fullversion": "1.2.52.402.g4f67b282", - "links": { - "win": { - "x86": "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-1.2.52.402.g4f67b282-258.exe", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.52.402.g4f67b282-260.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.52.402.g4f67b282-259.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.52.402.g4f67b282-936.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.52.402.g4f67b282-930.tbz" - } - } - }, - "1.2.52.337": { - "buildType": "Master", - "fullversion": "1.2.52.337.g72641da6", - "links": { - "win": { - "x86": "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-1.2.52.337.g72641da6-80.exe", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.52.337.g72641da6-81.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.52.337.g72641da6-80.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.52.337.g72641da6-764.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.52.337.g72641da6-762.tbz" - } - } - }, - "1.2.52.297": { - "buildType": "Master", - "fullversion": "1.2.52.297.g9ad95283", - "links": { - "win": { - "x86": "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-1.2.52.297.g9ad95283-443.exe", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.52.297.g9ad95283-437.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.52.297.g9ad95283-436.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.52.297.g9ad95283-641.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.52.297.g9ad95283-640.tbz" - } - } - }, "1.2.52.290": { "buildType": "Master", "fullversion": "1.2.52.290.gabcab511", @@ -1604,21 +1439,6 @@ } } }, - "1.2.51.292": { - "buildType": "Master", - "fullversion": "1.2.51.292.g9ae239fb", - "links": { - "win": { - "x86": "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-1.2.51.292.g9ae239fb-406.exe", - "x64": "https://upgrade.scdn.co/upgrade/client/win32-x86_64/spotify_installer-1.2.51.292.g9ae239fb-410.exe", - "arm64": "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-1.2.51.292.g9ae239fb-405.exe" - }, - "mac": { - "intel": "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-1.2.51.292.g9ae239fb-409.tbz", - "arm64": "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-1.2.51.292.g9ae239fb-408.tbz" - } - } - }, "1.2.51.251": { "buildType": "Master", "fullversion": "1.2.51.251.g3824e6a9",