-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (118 loc) · 4.38 KB
/
release.yml
File metadata and controls
139 lines (118 loc) · 4.38 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install -q -y jq
- name: Ensure scripts are executable
run: |
chmod +x scripts/*.sh
find tests -name '*.sh' -exec chmod +x {} +
- name: Extract tag version
id: tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "Tag version: $TAG_VERSION"
- name: Check versions match tag
run: |
TAG_VERSION="${{ steps.tag.outputs.version }}"
V_PLUGIN=$(jq -r .version .claude-plugin/plugin.json)
V_MKT=$(jq -r '.plugins[0].version' .claude-plugin/marketplace.json)
echo "tag=$TAG_VERSION plugin.json=$V_PLUGIN marketplace.json=$V_MKT"
MISMATCH=false
if [ "$V_PLUGIN" != "$TAG_VERSION" ]; then
echo "::error::plugin.json ($V_PLUGIN) does not match tag ($TAG_VERSION)"
MISMATCH=true
fi
if [ "$V_MKT" != "$TAG_VERSION" ]; then
echo "::error::marketplace.json ($V_MKT) does not match tag ($TAG_VERSION)"
MISMATCH=true
fi
if [ "$MISMATCH" = "true" ]; then
exit 1
fi
echo "All versions match tag: $TAG_VERSION"
- name: Run tests
run: bash tests/run-tests.sh
release:
needs: validate
runs-on: ubuntu-latest
steps:
- name: Checkout (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
# Find previous tag
PREV_TAG=$(git tag --sort=-v:refname | grep '^v' | sed -n '2p')
if [ -z "$PREV_TAG" ]; then
# First release — use all commits
RANGE="HEAD"
else
RANGE="${PREV_TAG}..HEAD"
fi
echo "Generating changelog for $RANGE"
CHANGELOG=""
# Collect commits by type
FEATS=$(git log "$RANGE" --pretty=format:"%s" --no-merges | grep -E "^feat(\(.+\))?:" | sed -E 's/^feat(\([^)]*\))?: //' || true)
FIXES=$(git log "$RANGE" --pretty=format:"%s" --no-merges | grep -E "^fix(\(.+\))?:" | sed -E 's/^fix(\([^)]*\))?: //' || true)
REFACTORS=$(git log "$RANGE" --pretty=format:"%s" --no-merges | grep -E "^refactor(\(.+\))?:" | sed -E 's/^refactor(\([^)]*\))?: //' || true)
DOCS=$(git log "$RANGE" --pretty=format:"%s" --no-merges | grep -E "^docs(\(.+\))?:" | sed -E 's/^docs(\([^)]*\))?: //' || true)
CHORES=$(git log "$RANGE" --pretty=format:"%s" --no-merges | grep -E "^chore(\(.+\))?:" | sed -E 's/^chore(\([^)]*\))?: //' || true)
if [ -n "$FEATS" ]; then
CHANGELOG+=$'\n## Features\n\n'
while IFS= read -r line; do
CHANGELOG+="- $line"$'\n'
done <<< "$FEATS"
fi
if [ -n "$FIXES" ]; then
CHANGELOG+=$'\n## Fixes\n\n'
while IFS= read -r line; do
CHANGELOG+="- $line"$'\n'
done <<< "$FIXES"
fi
if [ -n "$REFACTORS" ]; then
CHANGELOG+=$'\n## Refactors\n\n'
while IFS= read -r line; do
CHANGELOG+="- $line"$'\n'
done <<< "$REFACTORS"
fi
if [ -n "$DOCS" ]; then
CHANGELOG+=$'\n## Documentation\n\n'
while IFS= read -r line; do
CHANGELOG+="- $line"$'\n'
done <<< "$DOCS"
fi
if [ -n "$CHORES" ]; then
CHANGELOG+=$'\n## Maintenance\n\n'
while IFS= read -r line; do
CHANGELOG+="- $line"$'\n'
done <<< "$CHORES"
fi
if [ -z "$CHANGELOG" ]; then
CHANGELOG=$'\nNo categorized changes in this release.\n'
fi
# Write to file (multi-line output is easier via file)
echo "$CHANGELOG" > /tmp/changelog.md
echo "Changelog generated:"
cat /tmp/changelog.md
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--notes-file /tmp/changelog.md \
--latest