-
Notifications
You must be signed in to change notification settings - Fork 2
215 lines (179 loc) · 7.4 KB
/
release-ruby-client.yml
File metadata and controls
215 lines (179 loc) · 7.4 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Release Ruby Client
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
concurrency:
group: sdk-release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '22.13.1'
- name: Set up Ruby
uses: ruby/setup-ruby@97ecb7b512899eb71ab1bf2310a624c6f1589ac6 # 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: Ensure we have latest main
run: |
git fetch origin main
git reset --hard origin/main
- 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
continue-on-error: true
uses: openai/codex-action@a26d2d4d8b78a694338b8e3715c3630254340b2c # v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
sandbox: workspace-write
safety-strategy: drop-sudo
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 to inspect commits and changed files since the previous Ruby tag.
2. Analyze which changes are relevant to `clients/ruby/`.
3. Read relevant code changes when commit messages are not enough.
4. Generate user-friendly release notes with categories: Added, Changed, Fixed.
5. Focus on user-facing changes only.
6. If there are no relevant changes, output: "No changes to Ruby client in this release".
7. Save the changelog to `clients/ruby/CHANGELOG-RELEASE.md`.
Use 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/ruby/v${{ steps.current_version.outputs.version }}...ruby/v${{ steps.new_version.outputs.version }}
- name: Install dependencies
working-directory: ./clients/ruby
run: bundle install
- 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: Run tests
working-directory: ./clients/ruby
run: bundle exec rake
- name: Verify gem version is unpublished
working-directory: ./clients/ruby
run: |
if gem list --remote --exact vizzly --version "${{ steps.new_version.outputs.version }}" | grep -q '^vizzly '; then
echo "vizzly ${{ steps.new_version.outputs.version }} is already published"
exit 1
fi
- name: Configure git identity
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
- 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
- name: Release to RubyGems
uses: rubygems/release-gem@f0d7faff26625599a847d40d9fa28ace24c2aacc # v1
with:
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
working-directory: ./clients/ruby
- 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@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # 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/pkg/vizzly-${{ steps.new_version.outputs.version }}.gem
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}