-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (174 loc) · 6.22 KB
/
Copy pathrelease.yml
File metadata and controls
193 lines (174 loc) · 6.22 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: release
on:
push:
tags:
- "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
version-match:
name: version-match (plugin.json == tag)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Assert plugin.json.version == tag without v
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
expected="${tag#v}"
actual=$(python3 -c "import json; print(json.load(open('.claude-plugin/plugin.json'))['version'])")
if [ "$expected" != "$actual" ]; then
echo "::error ::tag $tag (without v: $expected) != plugin.json.version $actual"
exit 1
fi
echo "ok: tag=$tag matches plugin.json.version=$actual"
selftest:
name: selftest (ubuntu, py 3.11)
runs-on: ubuntu-latest
needs: [version-match]
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Node
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .nvmrc
cache: npm
- name: Install Node deps
run: npm ci
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.11"
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install dev deps
run: python -m pip install --upgrade pip && pip install -r requirements-dev.txt
- name: Pytest selftest (smoke + scenarios)
run: pytest bin/tests -q
build-bundle:
name: build-bundle (curated plugin-only)
runs-on: ubuntu-latest
needs: [version-match]
outputs:
bundle_path: ${{ steps.pack.outputs.bundle_path }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Pack curated bundle
id: pack
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
bundle="pos-${tag}.tar.gz"
tar -czf "$bundle" \
.claude-plugin \
.claude/skills \
.claude/rules \
hooks \
agents \
policy.yaml \
bin/pos-selftest.sh \
bin/_selftest.py \
docs/RELEASE.md
echo "bundle_path=$bundle" >> "$GITHUB_OUTPUT"
echo "ok: built $bundle"
ls -lh "$bundle"
- name: Upload bundle artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45581b # v4.6.0
with:
name: pos-bundle
path: ${{ steps.pack.outputs.bundle_path }}
if-no-files-found: error
retention-days: 30
publish-release:
name: publish-release
runs-on: ubuntu-latest
needs: [version-match, selftest, build-bundle]
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Download bundle artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: pos-bundle
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
bundle="pos-${tag}.tar.gz"
gh release create "$tag" \
--title "$tag" \
--generate-notes \
"$bundle"
mirror-marketplace:
name: mirror-marketplace (skippable)
runs-on: ubuntu-latest
needs: [publish-release]
if: ${{ vars.POS_MARKETPLACE_REPO != '' }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Open PR against marketplace repo
env:
GH_TOKEN: ${{ secrets.POS_MARKETPLACE_TOKEN }}
MARKETPLACE_REPO: ${{ vars.POS_MARKETPLACE_REPO }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
if [ -z "${MARKETPLACE_REPO:-}" ]; then
echo "POS_MARKETPLACE_REPO unset; skip mirror"
exit 0
fi
workdir=$(mktemp -d)
cd "$workdir"
gh repo clone "$MARKETPLACE_REPO" mp -- --depth=1
cd mp
branch="bump/pos-${version}"
git checkout -b "$branch"
python3 - <<PY
import json, pathlib
src = json.loads(pathlib.Path('${{ github.workspace }}/.claude-plugin/marketplace.json').read_text())
dst_path = pathlib.Path('marketplace.json')
dst = json.loads(dst_path.read_text()) if dst_path.exists() else src
plugins = dst.get('plugins') or []
target = next((p for p in plugins if p.get('name') == 'pos'), None)
if target is None:
plugins.append(src['plugins'][0])
else:
target['source'] = src['plugins'][0]['source']
target['version'] = src['plugins'][0]['version']
target['description'] = src['plugins'][0].get('description', target.get('description', ''))
dst['plugins'] = plugins
dst_path.write_text(json.dumps(dst, indent=2) + '\n')
PY
git add marketplace.json
if git diff --cached --quiet --exit-code; then
echo "No marketplace changes detected; skip mirror"
exit 0
fi
git -c user.email=actions@github.com -c user.name="github-actions[bot]" \
commit -m "bump pos to ${tag}"
git push -u origin "$branch"
existing_pr=$(gh pr list \
--repo "$MARKETPLACE_REPO" \
--head "$branch" \
--state open \
--json number \
--jq '.[0].number')
if [ -n "$existing_pr" ]; then
echo "Open PR #$existing_pr already exists for branch $branch; skip create"
else
gh pr create \
--repo "$MARKETPLACE_REPO" \
--title "bump pos to ${tag}" \
--body "Automated bump of pos plugin to ${tag}." \
--head "$branch"
fi