diff --git a/.github/workflows/bump-version.py b/.github/workflows/bump-version.py new file mode 100644 index 0000000..114284d --- /dev/null +++ b/.github/workflows/bump-version.py @@ -0,0 +1,30 @@ +import requests +import sys +sys.path.append('../../') +from clang_tools import release_tag + + +def get_latest_tag() -> str: + response = requests.get("https://api.github.com/repos/cpp-linter/clang-tools-static-binaries/releases/latest") + return response.json()['tag_name'] + + +def update_tag(current_tag, latest_tag) -> None: + file_path = "../../clang_tools/__init__.py" + with open(file_path) as file: + file_content = file.read() + + updated_content = file_content.replace(current_tag, latest_tag) + + with open(file_path, 'w') as file: + file.write(updated_content) + + +if __name__ == "__main__": + latest_tag = get_latest_tag() + current_tag = release_tag + + if latest_tag != current_tag: + update_tag(current_tag, latest_tag) + + print(latest_tag) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 0000000..f3d1802 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,53 @@ +name: Bump clang-tools binaries version +on: + push: + branches: + - "main" + schedule: + # Run once a day + - cron: '0 0 * * *' + workflow_dispatch: + +jobs: + bump_version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: pip install requests + + - name: Bump version + id: bump + run: | + cd .github/workflows + bump_tag=`python3 bump-version.py` + echo "bump_tag=$bump_tag" >> $GITHUB_OUTPUT + + cd ${{ github.workspace }} + + if git diff --exit-code; then + echo "No changes detected." + exit 0 + fi + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + add-paths: "clang_tools/__init__.py" + commit-message: "chore: bump clang-tools-static-binaries to ${{ steps.bump.outputs.bump_tag }}" + title: "Bump cpp-linter/clang-tools-static-binaries to ${{ steps.bump.outputs.bump_tag }}" + body: | + Bump [cpp-linter/clang-tools-static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries/releases) to `${{ steps.bump.outputs.bump_tag }}` + - This PR was auto-generated by [create-pull-request][1] + + [1]: https://github.com/peter-evans/create-pull-request + base: main + labels: dependencies + branch: bump-clang-tools-static-binaries-version + delete-branch: true diff --git a/.github/workflows/renovatebot.yml b/.github/workflows/renovatebot.yml deleted file mode 100644 index 9ce0b57..0000000 --- a/.github/workflows/renovatebot.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Renovate - -on: - push: - branches: - - "main" - workflow_dispatch: - -jobs: - renovate: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3.6.0 - - name: Self-hosted Renovate - uses: renovatebot/github-action@v39.2.4 - with: - token: ${{ secrets.CPP_LINTER_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9d114f..c488b3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,7 @@ repos: hooks: - id: flake8 args: [--max-line-length=120] + exclude: ^(.github/workflows/bump-version.py) # - repo: local # hooks: # - id: pytest diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 4495f95..0000000 --- a/renovate.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "baseBranches": ["main"], - "rebaseWhen": "behind-base-branch", - "dependencyDashboard": false, - "labels": ["dependencies"], - "commitMessagePrefix": "", - "commitMessageTopic": "{{depName}}", - "regexManagers": [ - { - "customType": "regex", - "matchStrings": [ - "\\sappVersion: (?.*)\\s" - ], - "datasourceTemplate": "github-releases", - "depNameTemplate": "cpp-linter/clang-tools-static-binaries", - "extractVersionTemplate": "^master-\\w*" - } - ], - "packageRules": [ - { - "matchDatasources": ["github-releases"], - "matchDepNames": ["cpp-linter/clang-tools-static-binaries"], - "matchUpdateTypes": ["minor", "patch"], - "automerge": true - } - ] - }