Skip to content

Commit 22d9f8e

Browse files
authored
feat: bump clang-tools-static-binaries tag with github action (#68)
1 parent 8325c25 commit 22d9f8e

File tree

5 files changed

+84
-46
lines changed

5 files changed

+84
-46
lines changed

.github/workflows/bump-version.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import requests
2+
import sys
3+
sys.path.append('../../')
4+
from clang_tools import release_tag
5+
6+
7+
def get_latest_tag() -> str:
8+
response = requests.get("https://api.github.com/repos/cpp-linter/clang-tools-static-binaries/releases/latest")
9+
return response.json()['tag_name']
10+
11+
12+
def update_tag(current_tag, latest_tag) -> None:
13+
file_path = "../../clang_tools/__init__.py"
14+
with open(file_path) as file:
15+
file_content = file.read()
16+
17+
updated_content = file_content.replace(current_tag, latest_tag)
18+
19+
with open(file_path, 'w') as file:
20+
file.write(updated_content)
21+
22+
23+
if __name__ == "__main__":
24+
latest_tag = get_latest_tag()
25+
current_tag = release_tag
26+
27+
if latest_tag != current_tag:
28+
update_tag(current_tag, latest_tag)
29+
30+
print(latest_tag)

.github/workflows/bump-version.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Bump clang-tools binaries version
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
schedule:
7+
# Run once a day
8+
- cron: '0 0 * * *'
9+
workflow_dispatch:
10+
11+
jobs:
12+
bump_version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Install dependencies
23+
run: pip install requests
24+
25+
- name: Bump version
26+
id: bump
27+
run: |
28+
cd .github/workflows
29+
bump_tag=`python3 bump-version.py`
30+
echo "bump_tag=$bump_tag" >> $GITHUB_OUTPUT
31+
32+
cd ${{ github.workspace }}
33+
34+
if git diff --exit-code; then
35+
echo "No changes detected."
36+
exit 0
37+
fi
38+
39+
- name: Create Pull Request
40+
uses: peter-evans/create-pull-request@v5
41+
with:
42+
add-paths: "clang_tools/__init__.py"
43+
commit-message: "chore: bump clang-tools-static-binaries to ${{ steps.bump.outputs.bump_tag }}"
44+
title: "Bump cpp-linter/clang-tools-static-binaries to ${{ steps.bump.outputs.bump_tag }}"
45+
body: |
46+
Bump [cpp-linter/clang-tools-static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries/releases) to `${{ steps.bump.outputs.bump_tag }}`
47+
- This PR was auto-generated by [create-pull-request][1]
48+
49+
[1]: https://github.com/peter-evans/create-pull-request
50+
base: main
51+
labels: dependencies
52+
branch: bump-clang-tools-static-binaries-version
53+
delete-branch: true

.github/workflows/renovatebot.yml

-18
This file was deleted.

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ repos:
2020
hooks:
2121
- id: flake8
2222
args: [--max-line-length=120]
23+
exclude: ^(.github/workflows/bump-version.py)
2324
# - repo: local
2425
# hooks:
2526
# - id: pytest

renovate.json

-28
This file was deleted.

0 commit comments

Comments
 (0)