Daily Tor Expert Bundle Version Update #540
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Daily Tor Expert Bundle Version Update" | |
| # Schedule the workflow to run every 30 minutes | |
| on: | |
| schedule: | |
| # Runs every 12 hours | |
| - cron: '0 */12 * * *' | |
| # Allows you to manually trigger the workflow from the GitHub UI | |
| workflow_dispatch: | |
| # Grant write permissions to the workflow | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-tor-versions: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Use GITHUB_TOKEN with proper permissions | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run Tor version scraper | |
| run: python main.py | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Commit and push changes | |
| run: | | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "[Auto] Update Tor versions data - $(date)" | |
| git push | |
| fi | |
| extract-daemon-versions: | |
| needs: update-tor-versions | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| filter: linux | |
| - os: windows-latest | |
| filter: windows | |
| - os: macos-latest | |
| filter: macos | |
| - os: ubuntu-latest | |
| filter: android | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ref: main | |
| - name: Pull latest changes | |
| run: git pull origin main | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Extract daemon versions for ${{ matrix.filter }} | |
| continue-on-error: true | |
| id: extract | |
| run: python extract_daemon_versions.py | |
| env: | |
| OS_FILTER: ${{ matrix.filter }} | |
| - name: Commit and push changes | |
| if: steps.extract.outcome == 'success' | |
| shell: bash | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add data/json/latest_export_versions.json | |
| if git diff --staged --quiet; then | |
| echo "No daemon versions updated" | |
| else | |
| git commit -m "[Auto] Update ${{ matrix.filter }} daemon versions" | |
| # Retry push with rebase up to 10 times to handle parallel job conflicts | |
| MAX_RETRIES=10 | |
| RETRY_COUNT=0 | |
| while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do | |
| echo "Attempt $((RETRY_COUNT + 1)) of $MAX_RETRIES" | |
| # Pull with rebase | |
| if git pull --rebase origin main; then | |
| # No conflicts, try to push | |
| if git push origin main; then | |
| echo "Successfully pushed changes" | |
| exit 0 | |
| else | |
| echo "Push failed, retrying..." | |
| fi | |
| else | |
| # Rebase failed due to conflicts | |
| echo "Conflict detected, resolving..." | |
| # Abort the failed rebase | |
| git rebase --abort | |
| # Fetch latest changes | |
| git fetch origin main | |
| # Reset to latest main | |
| git reset --hard origin/main | |
| # Re-run the script to apply our changes on top of latest | |
| python extract_daemon_versions.py | |
| # Stage and commit again | |
| git add data/json/latest_export_versions.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "[Auto] Update ${{ matrix.filter }} daemon versions" | |
| else | |
| echo "No changes to commit after re-run" | |
| exit 0 | |
| fi | |
| fi | |
| RETRY_COUNT=$((RETRY_COUNT + 1)) | |
| sleep $((RETRY_COUNT * 3)) | |
| done | |
| echo "Failed to push after $MAX_RETRIES attempts" | |
| exit 1 | |
| fi | |
| calculate-all-hashes: | |
| needs: extract-daemon-versions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ref: main | |
| - name: Pull latest changes | |
| run: git pull origin main | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Calculate hashes for all binaries | |
| run: python calculate_binary_hashes.py | |
| - name: Commit and push hash updates | |
| shell: bash | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add data/json/latest_export_versions.json | |
| if git diff --staged --quiet; then | |
| echo "No hash updates" | |
| else | |
| git commit -m "[Auto] Update binary hashes (MD5 & SHA256)" | |
| git push origin main | |
| fi |