-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (111 loc) · 4.59 KB
/
release.yml
File metadata and controls
131 lines (111 loc) · 4.59 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Release Skill
on:
push:
tags:
- 'v*'
workflow_call:
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Validate version and build packages
env:
TAG_VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
PLUGIN_FILE=".claude-plugin/plugin.json"
# --- Validate version ---
PLUGIN_VERSION=$(python3 -c "import json; print(json.load(open('$PLUGIN_FILE'))['version'])")
PLUGIN_NAME=$(python3 -c "import json; print(json.load(open('$PLUGIN_FILE'))['name'])")
TAG_BARE="${TAG_VERSION#v}"
if [[ "$TAG_BARE" != "$PLUGIN_VERSION" ]]; then
echo "::error file=$PLUGIN_FILE::Tag $TAG_VERSION does not match plugin.json version $PLUGIN_VERSION"
exit 1
fi
echo "Version validated: $TAG_VERSION"
# --- Discover skills from plugin.json ---
SKILL_PATHS=$(python3 -c "
import json
data = json.load(open('$PLUGIN_FILE'))
skills = data.get('skills', [])
if isinstance(skills, str):
skills = [skills]
for s in skills:
print(s.strip('/').rstrip('/'))
")
mkdir -p dist/releases
# --- Helper: copy skill contents ---
copy_skill() {
local src="$1" dst="$2"
for item in SKILL.md references scripts assets templates examples; do
if [[ -e "$src/$item" ]]; then
cp -r "$src/$item" "$dst/"
fi
done
[[ -f "$src/checkpoints.yaml" ]] && cp "$src/checkpoints.yaml" "$dst/"
cp LICENSE "$dst/" 2>/dev/null || true
}
# --- Package each skill standalone ---
while IFS= read -r skill_path; do
[[ -z "$skill_path" ]] && continue
skill_path="${skill_path#./}"
if [[ "$skill_path" == "." ]]; then
SKILL_NAME="$PLUGIN_NAME"
SKILL_SRC="."
else
SKILL_NAME=$(basename "$skill_path")
SKILL_SRC="$skill_path"
fi
echo "=== Packaging standalone skill: $SKILL_NAME ==="
SKILL_DIST="dist/skill-$SKILL_NAME"
mkdir -p "$SKILL_DIST"
copy_skill "$SKILL_SRC" "$SKILL_DIST"
(cd "$SKILL_DIST" && zip -qr "../releases/${SKILL_NAME}-skill-${TAG_VERSION}.zip" .)
(cd "$SKILL_DIST" && tar -czf "../releases/${SKILL_NAME}-skill-${TAG_VERSION}.tar.gz" .)
echo "Created ${SKILL_NAME}-skill-${TAG_VERSION}.zip/.tar.gz"
done <<< "$SKILL_PATHS"
# --- Package full plugin ---
echo "=== Packaging plugin: $PLUGIN_NAME ==="
PLUGIN_DIST="dist/plugin"
mkdir -p "$PLUGIN_DIST"
while IFS= read -r skill_path; do
[[ -z "$skill_path" ]] && continue
skill_path="${skill_path#./}"
if [[ "$skill_path" == "." ]]; then
copy_skill "." "$PLUGIN_DIST"
else
mkdir -p "$PLUGIN_DIST/$skill_path"
copy_skill "$skill_path" "$PLUGIN_DIST/$skill_path"
fi
done <<< "$SKILL_PATHS"
cp LICENSE "$PLUGIN_DIST/" 2>/dev/null || true
[[ -d ".claude-plugin" ]] && cp -r .claude-plugin "$PLUGIN_DIST/"
[[ -d "hooks" ]] && cp -r hooks "$PLUGIN_DIST/"
if [[ -d "scripts" ]]; then
cp -r scripts "$PLUGIN_DIST/"
find "$PLUGIN_DIST/scripts" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
fi
(cd "$PLUGIN_DIST" && zip -qr "../releases/${PLUGIN_NAME}-plugin-${TAG_VERSION}.zip" .)
(cd "$PLUGIN_DIST" && tar -czf "../releases/${PLUGIN_NAME}-plugin-${TAG_VERSION}.tar.gz" .)
echo "Created ${PLUGIN_NAME}-plugin-${TAG_VERSION}.zip/.tar.gz"
# --- Checksums ---
(cd dist/releases && sha256sum *.zip *.tar.gz > SHA256SUMS.txt)
echo ""
echo "=== Release packages ==="
ls -lh dist/releases/
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
files: dist/releases/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}