-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (148 loc) · 6.23 KB
/
release-storybook-client.yml
File metadata and controls
176 lines (148 loc) · 6.23 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
name: Release Storybook Client
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Configure git
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
- name: Get current version
id: current_version
working-directory: ./clients/storybook
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Bump version
id: version
working-directory: ./clients/storybook
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version | sed 's/v//')
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=storybook/v$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Generate changelog with Claude
id: changelog
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Generate release notes for the Vizzly Storybook Plugin v${{ steps.version.outputs.version }}.
Context:
- Client location: `clients/storybook/`
- Previous tag: `storybook/v${{ steps.current_version.outputs.version }}`
- New version: `${{ steps.version.outputs.version }}`
- This is a monorepo with multiple clients and a CLI
Instructions:
1. Use git commands (via Bash tool) to get commits since last storybook/* tag
2. Analyze which commits are relevant to `clients/storybook/`
3. Read the code changes if needed to understand impact
4. Generate user-friendly release notes with categories: Added, Changed, Fixed
5. Focus on user-facing changes only
6. If no relevant changes, output: "No changes to Storybook plugin in this release"
Save the changelog to `clients/storybook/CHANGELOG-RELEASE.md` with this format:
## What's Changed
### Added
- New features
### Changed
- Breaking or notable changes
### Fixed
- Bug fixes
**Full Changelog**: https://github.com/vizzly-testing/cli/compare/storybook/v${{ steps.current_version.outputs.version }}...storybook/v${{ steps.version.outputs.version }}
claude_args: '--allowed-tools "Bash(git:*)"'
- name: Install dependencies
working-directory: ./clients/storybook
run: npm install
- name: Run tests
working-directory: ./clients/storybook
run: npm test
- name: Run linter
working-directory: ./clients/storybook
run: npm run lint
- name: Update CHANGELOG.md
working-directory: ./clients/storybook
run: |
# Check if changelog was generated successfully
if [ ! -f CHANGELOG-RELEASE.md ]; then
echo "Warning: CHANGELOG-RELEASE.md not found, creating fallback changelog"
cat > CHANGELOG-RELEASE.md << 'EOF'
## What's Changed
Release v${{ steps.version.outputs.version }}
See the full diff for detailed changes.
EOF
fi
# Prepend new release to CHANGELOG.md
echo -e "# Changelog\n" > CHANGELOG-NEW.md
echo "All notable changes to this project will be documented in this file." >> CHANGELOG-NEW.md
echo "" >> CHANGELOG-NEW.md
echo "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)," >> CHANGELOG-NEW.md
echo "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)." >> CHANGELOG-NEW.md
echo "" >> CHANGELOG-NEW.md
echo "## [${{ steps.version.outputs.version }}] - $(date +%Y-%m-%d)" >> CHANGELOG-NEW.md
echo "" >> CHANGELOG-NEW.md
cat CHANGELOG-RELEASE.md >> CHANGELOG-NEW.md
echo "" >> CHANGELOG-NEW.md
tail -n +8 CHANGELOG.md >> CHANGELOG-NEW.md
mv CHANGELOG-NEW.md CHANGELOG.md
rm CHANGELOG-RELEASE.md
- name: Build package
working-directory: ./clients/storybook
run: npm run build
- name: Commit and push changes
run: |
git add clients/storybook/package.json clients/storybook/CHANGELOG.md
git commit -m "🔖 Storybook plugin v${{ steps.version.outputs.version }}"
git push origin main
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Publish to npm
working-directory: ./clients/storybook
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Read changelog for release
id: release_notes
working-directory: ./clients/storybook
run: |
# Extract just this version's changelog
CHANGELOG=$(sed -n '/## \[${{ steps.version.outputs.version }}\]/,/## \[/p' CHANGELOG.md | sed '$ d')
{
echo 'notes<<CHANGELOG_EOF'
echo "$CHANGELOG"
echo 'CHANGELOG_EOF'
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: 📚 Storybook Plugin v${{ steps.version.outputs.version }}
body: ${{ steps.release_notes.outputs.notes }}
files: ./clients/storybook/*.tgz
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}