From 06ba92fc5404cc6fe5f719c36bafdf7c4d6acbf1 Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Tue, 18 Nov 2025 06:06:50 +0300 Subject: [PATCH] Update update_versions.yml --- .github/workflows/update_versions.yml | 76 +++++---------------------- 1 file changed, 14 insertions(+), 62 deletions(-) diff --git a/.github/workflows/update_versions.yml b/.github/workflows/update_versions.yml index 47b4ab2..72dc87a 100644 --- a/.github/workflows/update_versions.yml +++ b/.github/workflows/update_versions.yml @@ -1,4 +1,5 @@ name: Update Version + on: workflow_dispatch: inputs: @@ -12,82 +13,33 @@ 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 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 }} + + - 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 run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - - 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 + 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