Skip to content

Commit 59fbcb7

Browse files
committed
feat: add update cli
1 parent a367545 commit 59fbcb7

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

.github/workflows/updatecli.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Updatecli
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
schedule:
10+
# * is a special character in YAML so you have to quote this string
11+
# Run once a day
12+
- cron: '0 0 * * *'
13+
14+
jobs:
15+
updatecli:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Install updatecli
22+
uses: updatecli/updatecli-action@v2
23+
24+
- name: Diff
25+
continue-on-error: true
26+
run: |
27+
updatecli diff --config updatecli/updatecli.d --values updatecli/values.yaml
28+
env:
29+
UPDATECLI_GITHUB_TOKEN: ${{ secrets.CPP_LINTER_TOEKN }}
30+
31+
- name: Apply
32+
if: github.ref == 'refs/heads/main'
33+
run: |
34+
updatecli apply --config updatecli/updatecli.d --values updatecli/values.yaml
35+
env:
36+
UPDATECLI_GITHUB_TOKEN: ${{ secrets.CPP_LINTER_TOEKN }}

updatecli/check-tag.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
lastest_tag=`curl -s https://api.github.com/repos/cpp-linter/clang-tools-static-binaries/releases/latest | jq -r '.tag_name'`
4+
current_tag=`grep -oP "^release_tag = '\K[^']+" ../clang_tools/__init__.py`
5+
6+
if [[ $lastest_tag = $current_tag ]]; then
7+
exit 0;
8+
else
9+
eixt 1;
10+
fi

updatecli/update-tag.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
new_release_tag=$1
4+
file_path="clang_tools/__init__.py"
5+
regex="^release_tag = 'master-\\w*'"
6+
7+
script_dir=`pwd`
8+
cd "$script_dir/.."
9+
10+
# Check if the file exists
11+
if [ -f "$file_path" ]; then
12+
# Use sed to replace the regex with the desired string
13+
sed -i "s/$regex/release_tag = '$new_release_tag'/g" "$file_path"
14+
echo "release_tag updated successfully."
15+
else
16+
echo "File $file_path not found."
17+
fi
18+
19+
# Return to the original directory
20+
cd - >/dev/null
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Bump clang-tools static binaries version
3+
4+
scms:
5+
default:
6+
kind: github
7+
spec:
8+
user: "{{ .github.user }}"
9+
email: "{{ .github.email }}"
10+
owner: "{{ .github.owner }}"
11+
repository: "{{ .github.repository }}"
12+
token: "{{ requiredEnv .github.token }}"
13+
username: "{{ .github.username }}"
14+
branch: "{{ .github.branch }}"
15+
16+
sources:
17+
lastVersion:
18+
kind: githubrelease
19+
name: Get the latest clang-tools static binaries version
20+
spec:
21+
owner: "cpp-linter"
22+
repository: "clang-tools-static-binaries"
23+
token: "{{ requiredEnv .github.token }}"
24+
username: "{{ .github.username }}"
25+
versionfilter:
26+
kind: latest
27+
transformers:
28+
- addprefix: "master-"
29+
30+
conditions:
31+
checkIfReleaseIsAvailable:
32+
sourceid: lastVersion
33+
kind: shell
34+
spec:
35+
command: bash ./updatecli/check-tag.sh # source input value passed as argument
36+
37+
targets:
38+
updateVersion:
39+
name: "Update clang-tools-pip"
40+
sourceid: lastVersion
41+
scmid: github
42+
kind: shell
43+
spec:
44+
command: bash {{ "GITHUB_WORKSPACE" }}/updatecli/update-tag.sh
45+
46+
actions:
47+
default:
48+
kind: github/pullrequest
49+
scmid: default
50+
title: Bump clang-tools-static-binaries version to {{ source "lastVersion" }}
51+
spec:
52+
labels:
53+
- dependencies
54+
- clang-tools-static-binaries

updatecli/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github:
2+
user: "Cpp Linter Bot (updatecli)"
3+
4+
username: "cpp-linter-bot"
5+
token: "CPP_LINTER_TOKEN"
6+
branch: "main"
7+
owner: "cpp-linter"
8+
repository: "clang-tools-pip"

0 commit comments

Comments
 (0)