-
Couldn't load subscription status.
- Fork 3
feat: create script to update versions automatically #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c31b410
518be04
07ec87c
75397a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| name: Update Tool Versions | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run every Monday at 2 AM UTC | ||
| - cron: '0 2 * * 1' | ||
| workflow_dispatch: # Allow manual trigger | ||
|
|
||
| jobs: | ||
| update-versions: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Update versions | ||
| run: | | ||
| python3 scripts/update_versions.py | ||
|
|
||
| - name: Check for changes | ||
| id: verify-changed-files | ||
| run: | | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Get latest versions for PR description | ||
| if: steps.verify-changed-files.outputs.changed == 'true' | ||
| id: get-versions | ||
| run: | | ||
| CLANG_FORMAT_VERSION=$(python3 -c 'from cpp_linter_hooks.versions import CLANG_FORMAT_VERSIONS; print(CLANG_FORMAT_VERSIONS[-1])') | ||
| CLANG_TIDY_VERSION=$(python3 -c 'from cpp_linter_hooks.versions import CLANG_TIDY_VERSIONS; print(CLANG_TIDY_VERSIONS[-1])') | ||
| echo "clang_format_version=$CLANG_FORMAT_VERSION" >> $GITHUB_OUTPUT | ||
| echo "clang_tidy_version=$CLANG_TIDY_VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create Pull Request | ||
| if: steps.verify-changed-files.outputs.changed == 'true' | ||
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: | | ||
| chore: update clang-format and clang-tidy versions | ||
|
|
||
| - Updated versions automatically from PyPI | ||
| title: "chore: update tool versions to latest" | ||
| body: | | ||
| ## 🔄 Automated Version Update | ||
|
|
||
| This PR updates the hardcoded versions for clang-format and clang-tidy tools to the latest available versions from PyPI. | ||
|
|
||
| ### 📦 Updated Versions | ||
| - **clang-format**: `${{ steps.get-versions.outputs.clang_format_version }}` | ||
| - **clang-tidy**: `${{ steps.get-versions.outputs.clang_tidy_version }}` | ||
|
|
||
| ### 🤖 Automation Details | ||
| - This update was triggered automatically by the scheduled workflow | ||
| - Versions are fetched from the official PyPI APIs | ||
| - Only stable versions (no pre-releases) are included | ||
|
|
||
| ### ✅ What's Changed | ||
| - Updated `cpp_linter_hooks/versions.py` with latest tool versions | ||
| - No breaking changes expected | ||
| - Maintains backward compatibility | ||
|
|
||
| ### 🔍 Review Checklist | ||
| - [ ] Verify the new versions are stable releases | ||
| - [ ] Check that no pre-release versions were included | ||
| - [ ] Confirm the version format matches expectations | ||
|
|
||
| --- | ||
|
|
||
| *This PR was created automatically by the `update-versions.yml` workflow.* | ||
| branch: update-tool-versions | ||
| delete-branch: true | ||
| base: main | ||
| labels: dependencies |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| """ | ||
| Version management for clang-format and clang-tidy. | ||
|
|
||
| This module provides hardcoded version lists that are updated periodically via GitHub Actions. | ||
| """ | ||
|
|
||
| # Updated automatically by GitHub Actions - DO NOT EDIT MANUALLY | ||
| CLANG_FORMAT_VERSIONS = [ | ||
| "6.0.1", | ||
| "7.1.0", | ||
| "8.0.1", | ||
| "9.0.0", | ||
| "10.0.1", | ||
| "10.0.1.1", | ||
| "11.0.1", | ||
| "11.0.1.1", | ||
| "11.0.1.2", | ||
| "11.1.0", | ||
| "11.1.0.1", | ||
| "11.1.0.2", | ||
| "12.0.1", | ||
| "12.0.1.1", | ||
| "12.0.1.2", | ||
| "13.0.0", | ||
| "13.0.1", | ||
| "13.0.1.1", | ||
| "14.0.0", | ||
| "14.0.1", | ||
| "14.0.3", | ||
| "14.0.4", | ||
| "14.0.5", | ||
| "14.0.6", | ||
| "15.0.4", | ||
| "15.0.6", | ||
| "15.0.7", | ||
| "16.0.0", | ||
| "16.0.1", | ||
| "16.0.2", | ||
| "16.0.3", | ||
| "16.0.4", | ||
| "16.0.5", | ||
| "16.0.6", | ||
| "17.0.1", | ||
| "17.0.2", | ||
| "17.0.3", | ||
| "17.0.4", | ||
| "17.0.5", | ||
| "17.0.6", | ||
| "18.1.0", | ||
| "18.1.1", | ||
| "18.1.2", | ||
| "18.1.3", | ||
| "18.1.4", | ||
| "18.1.5", | ||
| "18.1.6", | ||
| "18.1.7", | ||
| "18.1.8", | ||
| "19.1.0", | ||
| "19.1.1", | ||
| "19.1.2", | ||
| "19.1.3", | ||
| "19.1.4", | ||
| "19.1.5", | ||
| "19.1.6", | ||
| "19.1.7", | ||
| "20.1.0", | ||
| "20.1.3", | ||
| "20.1.4", | ||
| "20.1.5", | ||
| "20.1.6", | ||
| "20.1.7", | ||
| "20.1.8", | ||
| "21.1.0", | ||
| "21.1.1", | ||
| "21.1.2", | ||
| ] | ||
|
|
||
| # Updated automatically by GitHub Actions - DO NOT EDIT MANUALLY | ||
| CLANG_TIDY_VERSIONS = [ | ||
| "13.0.1.1", | ||
| "14.0.6", | ||
| "15.0.2", | ||
| "15.0.2.1", | ||
| "16.0.4", | ||
| "17.0.1", | ||
| "18.1.1", | ||
| "18.1.8", | ||
| "19.1.0", | ||
| "19.1.0.1", | ||
| "20.1.0", | ||
| "21.1.0", | ||
| "21.1.1", | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,87 @@ | ||||||||||||||||||||||
| #!/usr/bin/env python3 | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
| Script to update clang-format and clang-tidy versions from PyPI API. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Usage: | ||||||||||||||||||||||
| python scripts/update_versions.py | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import json | ||||||||||||||||||||||
| import urllib.request | ||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||
| import re | ||||||||||||||||||||||
| from typing import List | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def fetch_versions_from_pypi(package_name: str) -> List[str]: | ||||||||||||||||||||||
| """Fetch available versions for a package from PyPI API.""" | ||||||||||||||||||||||
| url = f"https://pypi.org/pypi/{package_name}/json" | ||||||||||||||||||||||
| try: | ||||||||||||||||||||||
| with urllib.request.urlopen(url, timeout=10) as response: | ||||||||||||||||||||||
| data = json.loads(response.read()) | ||||||||||||||||||||||
| versions = list(data["releases"].keys()) | ||||||||||||||||||||||
| # Filter out pre-release versions and sort | ||||||||||||||||||||||
| stable_versions = [ | ||||||||||||||||||||||
| v | ||||||||||||||||||||||
| for v in versions | ||||||||||||||||||||||
| if not any(char in v for char in ["a", "b", "rc", "dev"]) | ||||||||||||||||||||||
|
||||||||||||||||||||||
| stable_versions = [ | |
| v | |
| for v in versions | |
| if not any(char in v for char in ["a", "b", "rc", "dev"]) | |
| # Exclude pre-releases: versions with 'aN', 'bN', 'rcN', or '.devN' suffixes | |
| pre_release_pattern = re.compile(r"(a|b|rc|\.dev)\d+", re.IGNORECASE) | |
| stable_versions = [ | |
| v | |
| for v in versions | |
| if not pre_release_pattern.search(v) |
Uh oh!
There was an error while loading. Please reload this page.