-
Notifications
You must be signed in to change notification settings - Fork 1
194 lines (163 loc) · 6.84 KB
/
release-ruby-client.yml
File metadata and controls
194 lines (163 loc) · 6.84 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
194
name: Release Ruby 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 Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- 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/ruby
run: |
CURRENT_VERSION=$(ruby -e "puts Gem::Specification.load('vizzly.gemspec').version")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Calculate new version
id: new_version
run: |
CURRENT="${{ steps.current_version.outputs.version }}"
# Validate version format (X.Y.Z)
if ! [[ "$CURRENT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format '$CURRENT'. Expected X.Y.Z"
exit 1
fi
IFS='.' read -r -a parts <<< "$CURRENT"
case "${{ github.event.inputs.version_type }}" in
major)
NEW_VERSION="$((parts[0] + 1)).0.0"
;;
minor)
NEW_VERSION="${parts[0]}.$((parts[1] + 1)).0"
;;
patch)
NEW_VERSION="${parts[0]}.${parts[1]}.$((parts[2] + 1))"
;;
esac
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=ruby/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 Ruby Client SDK v${{ steps.new_version.outputs.version }}.
Context:
- Client location: `clients/ruby/`
- Previous tag: `ruby/v${{ steps.current_version.outputs.version }}`
- New version: `${{ steps.new_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 ruby/* tag
2. Analyze which commits are relevant to `clients/ruby/`
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 Ruby client in this release"
Save the changelog to `clients/ruby/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/vizzly-cli/compare/ruby/v${{ steps.current_version.outputs.version }}...ruby/v${{ steps.new_version.outputs.version }}
claude_args: '--allowed-tools "Bash(git:*)"'
- name: Update version in gemspec
working-directory: ./clients/ruby
run: |
sed -i.bak "s/spec.version = '[^']*'/spec.version = '${{ steps.new_version.outputs.version }}'/" vizzly.gemspec
rm vizzly.gemspec.bak
- name: Update CHANGELOG.md
working-directory: ./clients/ruby
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.new_version.outputs.version }}
See the full diff for detailed changes.
EOF
fi
# Prepend new release to CHANGELOG.md
echo -e "# Vizzly Ruby Client Changelog\n" > CHANGELOG-NEW.md
echo "## [${{ steps.new_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 +2 CHANGELOG.md >> CHANGELOG-NEW.md
mv CHANGELOG-NEW.md CHANGELOG.md
rm CHANGELOG-RELEASE.md
- name: Reconfigure git auth
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n x-access-token:${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }} | base64)"
- name: Commit and push changes
run: |
git add clients/ruby/vizzly.gemspec clients/ruby/CHANGELOG.md
git commit -m "🔖 Ruby client v${{ steps.new_version.outputs.version }}"
git push origin main
git tag "${{ steps.new_version.outputs.tag }}"
git push origin "${{ steps.new_version.outputs.tag }}"
- name: Build gem
working-directory: ./clients/ruby
run: gem build vizzly.gemspec
- name: Publish to RubyGems
working-directory: ./clients/ruby
run: |
mkdir -p ~/.gem
echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
gem push vizzly-${{ steps.new_version.outputs.version }}.gem
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
- name: Read changelog for release
id: release_notes
working-directory: ./clients/ruby
run: |
# Extract just this version's changelog
CHANGELOG=$(sed -n '/## \[${{ steps.new_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.new_version.outputs.tag }}
name: 💎 Ruby Client v${{ steps.new_version.outputs.version }}
body: ${{ steps.release_notes.outputs.notes }}
files: ./clients/ruby/vizzly-${{ steps.new_version.outputs.version }}.gem
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}