Skip to content

Commit 124f244

Browse files
committed
chore: add version validation pre-push hook and .envrc
1 parent 76d047c commit 124f244

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Install git hooks for version validation
2+
git config core.hooksPath Build/hooks

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2424

25+
- name: Validate plugin.json matches tag
26+
env:
27+
TAG_VERSION: ${{ github.ref_name }}
28+
run: |
29+
PLUGIN_VERSION=$(python3 -c "import json; print(json.load(open('.claude-plugin/plugin.json'))['version'])")
30+
TAG_BARE="${TAG_VERSION#v}"
31+
if [[ "${TAG_BARE}" != "${PLUGIN_VERSION}" ]]; then
32+
echo "::error file=.claude-plugin/plugin.json::Tag ${TAG_VERSION} does not match plugin.json version ${PLUGIN_VERSION}"
33+
exit 1
34+
fi
35+
echo "Version validated: ${TAG_VERSION} matches plugin.json ${PLUGIN_VERSION}"
36+
2537
- name: Get version from tag
2638
id: version
2739
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
TAGS=$(git tag --points-at HEAD | sed -nE 's/^v?([0-9]+\.[0-9]+\.[0-9]+)$/\1/p' || true)
4+
[[ -z "${TAGS}" ]] && exit 0
5+
PLUGIN_VERSION=$(python3 -c "import json; print(json.load(open('.claude-plugin/plugin.json'))['version'])")
6+
if [[ -z "${PLUGIN_VERSION}" ]]; then
7+
echo "ERROR: Could not extract version from .claude-plugin/plugin.json" >&2
8+
exit 1
9+
fi
10+
if ! echo "${TAGS}" | grep -qFx "${PLUGIN_VERSION}"; then
11+
echo "ERROR: .claude-plugin/plugin.json version (${PLUGIN_VERSION}) does not match any semver tag at HEAD." >&2
12+
echo "Tags found at HEAD:" >&2
13+
echo "${TAGS}" >&2
14+
exit 1
15+
fi

Build/hooks/pre-push

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
"$(dirname "$0")/../Scripts/check-plugin-version.sh"

0 commit comments

Comments
 (0)