-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 2.12 KB
/
Copy pathversion-sync.yml
File metadata and controls
64 lines (55 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Version Sync
on:
push:
branches: [master]
paths:
- 'pyproject.toml'
permissions:
contents: write
jobs:
sync-plugin-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get pyproject.toml version
id: pyproject
run: |
VER=$(python3 -c "import re, pathlib; m=re.search(r'^version\s*=\s*\"([^\"]+)\"', pathlib.Path('pyproject.toml').read_text(), re.MULTILINE); print(m.group(1))")
echo "version=$VER" >> "$GITHUB_OUTPUT"
- name: Get plugin.json version
id: plugin
run: |
VER=$(python3 -c "import json; print(json.load(open('.claude-plugin/plugin.json'))['version'])")
echo "version=$VER" >> "$GITHUB_OUTPUT"
- name: Update plugin versions
if: steps.pyproject.outputs.version != steps.plugin.outputs.version
env:
VERSION: ${{ steps.pyproject.outputs.version }}
run: |
python3 - <<'EOF'
import json, os
version = os.environ["VERSION"]
path = ".claude-plugin/plugin.json"
data = json.load(open(path))
data["version"] = version
with open(path, "w") as f:
json.dump(data, f, indent=2)
f.write("\n")
path = ".claude-plugin/marketplace.json"
data = json.load(open(path))
data["metadata"]["version"] = version
data["plugins"][0]["version"] = version
with open(path, "w") as f:
json.dump(data, f, indent=2)
f.write("\n")
EOF
- name: Commit and push
if: steps.pyproject.outputs.version != steps.plugin.outputs.version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .claude-plugin/plugin.json .claude-plugin/marketplace.json
git diff --cached --quiet || git commit -m "chore: sync plugin version to ${{ steps.pyproject.outputs.version }}"
git push