-
Notifications
You must be signed in to change notification settings - Fork 2
102 lines (90 loc) · 4.43 KB
/
version-check.yml
File metadata and controls
102 lines (90 loc) · 4.43 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Version Consistency Check
on:
pull_request:
paths:
- "plugins/plugin-dev/.claude-plugin/plugin.json"
- ".claude-plugin/marketplace.json"
- "CLAUDE.md"
workflow_dispatch: # Manual trigger for pre-release checks
# Cancel any in-progress check for the same PR when new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check-versions:
# Skip bots
if: |
github.actor != 'dependabot[bot]' &&
github.actor != 'claude[bot]'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Check version consistency
uses: anthropics/claude-code-action@b47fd721da662d48c5680e154ad16a73ed74d2e0 # v1.0.93
id: version-check
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Check version consistency across all plugin version files.
## Files to Check
1. `plugins/plugin-dev/.claude-plugin/plugin.json` - Extract `version` field (source of truth)
2. `.claude-plugin/marketplace.json` - Extract BOTH:
- `metadata.version` field
- `plugins[0].version` field
3. `CLAUDE.md` - Extract version from "What This Is" section (pattern: `**Version**: vX.Y.Z`)
## Instructions
1. Read plugin.json and extract the version (this is the expected version)
2. Read marketplace.json and extract both version fields
3. Read CLAUDE.md and extract version from the "**Version**:" line
4. Compare all versions against the plugin.json version
5. Return structured JSON with results
claude_args: |
--model claude-opus-4-6
--allowedTools "Read"
--json-schema '{"type":"object","properties":{"plugin_json_version":{"type":"string","description":"Version from plugin.json"},"marketplace_metadata_version":{"type":"string","description":"Version from marketplace.json metadata.version"},"marketplace_plugin_version":{"type":"string","description":"Version from marketplace.json plugins[0].version"},"claude_md_version":{"type":"string","description":"Version from CLAUDE.md Quick Reference"},"all_match":{"type":"boolean","description":"True if all versions match plugin.json"},"expected_version":{"type":"string","description":"The expected version (from plugin.json)"},"mismatches":{"type":"array","description":"List of files with mismatched versions","items":{"type":"string"}}},"required":["plugin_json_version","all_match","expected_version","mismatches"]}'
- name: Report version status
if: always() && steps.version-check.outputs.structured_output != ''
env:
VERSION_OUTPUT: ${{ steps.version-check.outputs.structured_output }}
run: |
{
echo "## Version Consistency Check Results"
echo '```json'
echo "$VERSION_OUTPUT" | jq .
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Fail if mismatched
if: always() && steps.version-check.outputs.structured_output != ''
env:
VERSION_OUTPUT: ${{ steps.version-check.outputs.structured_output }}
run: |
# Validate JSON output before processing
if ! all_match=$(echo "$VERSION_OUTPUT" | jq -r '.all_match' 2>/dev/null); then
echo "Error: Invalid JSON output from version check step"
echo "Raw output:"
echo "$VERSION_OUTPUT"
exit 1
fi
if [ "$all_match" != "true" ]; then
expected=$(echo "$VERSION_OUTPUT" | jq -r '.expected_version')
echo "❌ Version mismatch detected!"
echo ""
echo "Expected version: $expected"
echo ""
echo "Mismatches:"
echo "$VERSION_OUTPUT" | jq -r '.mismatches[]' | while read -r mismatch; do
echo " - $mismatch"
done
echo ""
echo "Please update all version files to match plugin.json version ($expected)"
exit 1
fi
expected=$(echo "$VERSION_OUTPUT" | jq -r '.expected_version')
echo "✅ All versions match: $expected"