Skip to content

Commit 2e25576

Browse files
author
David Elner
committed
Refactored: rake release to follow convention more closely
1 parent ae42391 commit 2e25576

6 files changed

Lines changed: 65 additions & 156 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
4242

4343
ensure-pinned-actions:
44-
runs-on: ubuntu-latest
44+
runs-on: ubuntu-24.04
4545
timeout-minutes: 2
4646
steps:
4747
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -52,7 +52,7 @@ jobs:
5252
ci-success:
5353
name: CI Success
5454
needs: [test, ensure-pinned-actions]
55-
runs-on: ubuntu-latest
55+
runs-on: ubuntu-24.04
5656
if: always()
5757
steps:
5858
- name: Check test matrix success

.github/workflows/release.yml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
jobs:
2828
validate:
2929
# Generic except where marked LANGUAGE-SPECIFIC
30-
runs-on: ubuntu-latest
30+
runs-on: ubuntu-24.04
3131
timeout-minutes: 10
3232
permissions:
3333
contents: read
@@ -44,7 +44,8 @@ jobs:
4444
fetch-depth: 0
4545

4646
# LANGUAGE-SPECIFIC: replace with your language's setup action
47-
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
47+
- name: Set up language runtime
48+
uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
4849
with:
4950
ruby-version: '3.4'
5051
bundler-cache: true
@@ -90,7 +91,7 @@ jobs:
9091
9192
prepare:
9293
needs: validate
93-
runs-on: ubuntu-latest
94+
runs-on: ubuntu-24.04
9495
timeout-minutes: 5
9596
permissions:
9697
contents: write # required for releases/generate-notes API
@@ -128,7 +129,7 @@ jobs:
128129
129130
notify:
130131
needs: [validate, prepare]
131-
runs-on: ubuntu-latest
132+
runs-on: ubuntu-24.04
132133
timeout-minutes: 5
133134
permissions:
134135
contents: read
@@ -215,11 +216,12 @@ jobs:
215216
curl -s -X POST "https://slack.com/api/chat.postMessage" \
216217
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
217218
-H "Content-Type: application/json; charset=utf-8" \
218-
-d "{\"channel\": \"$SLACK_CHANNEL\", \"text\": \"$TEXT\"}"
219+
-d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$TEXT" \
220+
'{channel: $channel, text: $text}')"
219221
220222
publish:
221223
needs: [validate, prepare, notify]
222-
runs-on: ubuntu-latest
224+
runs-on: ubuntu-24.04
223225
timeout-minutes: 15
224226
environment: ${{ inputs.dry_run && 'rubygems-publish-dry-run' || 'rubygems-publish' }}
225227

@@ -234,32 +236,44 @@ jobs:
234236
fetch-depth: 0
235237

236238
# LANGUAGE-SPECIFIC: replace with your language's setup action
237-
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
239+
- name: Set up language runtime
240+
uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
238241
with:
239242
ruby-version: '3.4'
240243
bundler-cache: true
241244

242-
- name: Create release tag
243-
if: ${{ !inputs.dry_run }}
244-
run: git tag "$GITHUB_REF_NAME"
245+
# LANGUAGE-SPECIFIC: replace with your language's publish command.
246+
# Runs `bundle exec rake release` which: lints, builds, pushes gem to
247+
# RubyGems with SLSA attestation, and pushes the git tag to GitHub.
248+
# In dry run, gem push and tag push are skipped via DRY_RUN env var
249+
# in the Rakefile — rubygems/release-gem itself has no dry run mode.
250+
# await-release is disabled in dry run since no gem is pushed.
251+
- name: Publish package with attestation
252+
uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # v1.2.0
253+
with:
254+
await-release: ${{ inputs.dry_run && 'false' || 'true' }}
245255
env:
246-
GITHUB_REF_NAME: ${{ needs.validate.outputs.release_tag }}
256+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
257+
DRY_RUN: ${{ inputs.dry_run }}
247258

248-
# LANGUAGE-SPECIFIC: replace with your language's publish command
249-
- name: Publish package with attestation
259+
- name: Create GitHub release
250260
if: ${{ !inputs.dry_run }}
251-
uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # v1.2.0
252261
env:
253262
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
254-
GITHUB_REF_NAME: ${{ needs.validate.outputs.release_tag }}
263+
TAG: ${{ needs.validate.outputs.release_tag }}
264+
run: |
265+
echo "${{ needs.prepare.outputs.notes }}" | base64 -d 2>/dev/null > /tmp/release-notes.md
266+
gh release create "$TAG" \
267+
--title "$TAG" \
268+
--notes-file /tmp/release-notes.md \
269+
--target "${{ inputs.sha }}"
255270
256-
# LANGUAGE-SPECIFIC: replace with your language's build/check command
257-
- name: Dry run — build and check only
271+
- name: Release notes preview
258272
if: ${{ inputs.dry_run }}
259273
run: |
260-
bundle exec rake lint
261-
bundle exec rake build
262-
echo "DRY RUN: would push gem ${{ needs.validate.outputs.release_tag }} to RubyGems and create tag"
274+
echo "DRY RUN: would create GitHub release ${{ needs.validate.outputs.release_tag }}"
275+
echo "--- Release notes preview ---"
276+
echo "${{ needs.prepare.outputs.notes }}" | base64 -d 2>/dev/null || echo "(unavailable)"
263277
264278
- name: Notify Slack on release
265279
env:
@@ -309,4 +323,5 @@ jobs:
309323
curl -s -X POST "https://slack.com/api/chat.postMessage" \
310324
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
311325
-H "Content-Type: application/json; charset=utf-8" \
312-
-d "{\"channel\": \"$SLACK_CHANNEL\", \"text\": \"$TEXT\"}"
326+
-d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$TEXT" \
327+
'{channel: $channel, text: $text}')"

.github/workflows/security-audit.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
dependabot-alerts:
13-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-24.04
1414
timeout-minutes: 5
1515
steps:
1616
- name: Generate scoped token
@@ -31,11 +31,10 @@ jobs:
3131
3232
if [ "$ALERTS" -gt 0 ]; then
3333
SECURITY_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/security/dependabot"
34+
TEXT=":warning: *braintrust-sdk-ruby* has $ALERTS open Dependabot alert(s). <$SECURITY_URL|View alerts>"
3435
curl -s -X POST "https://slack.com/api/chat.postMessage" \
3536
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
3637
-H "Content-Type: application/json; charset=utf-8" \
37-
-d "{
38-
\"channel\": \"$SLACK_CHANNEL\",
39-
\"text\": \":warning: *braintrust-sdk-ruby* has $ALERTS open Dependabot alert(s). <$SECURITY_URL|View alerts>\"
40-
}"
38+
-d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$TEXT" \
39+
'{channel: $channel, text: $text}')"
4140
fi

Rakefile

Lines changed: 23 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,7 @@ end
199199

200200
# Release tasks
201201
namespace :release do
202-
task :validate do
203-
sh "bash scripts/validate-release-tag.sh"
204-
end
205-
206-
task publish: ["release:validate", :lint, :build] do
202+
task publish: [:lint, :build] do
207203
gem_files = FileList["braintrust-*.gem"]
208204
if gem_files.empty?
209205
puts "Error: No gem file found. Build task should have created it."
@@ -213,70 +209,36 @@ namespace :release do
213209
puts "Found: #{gem_files.join(", ")}"
214210
exit 1
215211
end
216-
sh "gem push #{gem_files.first}"
217-
puts "✓ Gem pushed to RubyGems"
218-
end
219-
220-
task :changelog do
221-
sh "bash scripts/generate-release-notes.sh > changelog.md"
222-
puts "✓ Changelog generated: changelog.md"
212+
if ENV["DRY_RUN"] == "true"
213+
puts "DRY RUN: would push #{gem_files.first} to RubyGems (skipped)"
214+
else
215+
# TEMPORARILY DISABLED FOR TESTING — re-enable before merging
216+
puts "REAL PATH: gem push #{gem_files.first} (disabled for testing)"
217+
# sh "gem push #{gem_files.first}"
218+
# puts "✓ Gem pushed to RubyGems"
219+
end
223220
end
224221

225-
task github: [:changelog] do
222+
task :push_tag do
226223
require_relative "lib/braintrust/version"
227224
tag = "v#{Braintrust::VERSION}"
228-
229-
sh "gh release create #{tag} --title '#{tag}' --notes-file changelog.md"
230-
231-
# Get the repository URL
232-
repo = `gh repo view --json nameWithOwner -q .nameWithOwner`.strip
233-
release_url = "https://github.com/#{repo}/releases/tag/#{tag}"
234-
235-
puts "✓ GitHub release created: #{tag}"
236-
puts " #{release_url}"
237-
end
238-
239-
task :prerelease do
240-
# Get current version
241-
require_relative "lib/braintrust/version"
242-
original_version = Braintrust::VERSION
243-
244-
# Generate rc version with GitHub run number or timestamp
245-
run_number = ENV["GITHUB_RUN_NUMBER"] || Time.now.to_i.to_s
246-
prerelease_version = "#{original_version}.rc.#{run_number}"
247-
248-
puts "Original version: #{original_version}"
249-
puts "Prerelease version: #{prerelease_version}"
250-
251-
# Temporarily modify version.rb
252-
version_file = "lib/braintrust/version.rb"
253-
content = File.read(version_file)
254-
modified_content = content.gsub(
255-
/VERSION = "#{Regexp.escape(original_version)}"/,
256-
"VERSION = \"#{prerelease_version}\""
257-
)
258-
259-
File.write(version_file, modified_content)
260-
261-
begin
262-
# Lint, build, and push directly — bypasses release:validate which is
263-
# git-tag-centric and not applicable to prereleases.
264-
Rake::Task[:lint].invoke
265-
Rake::Task[:build].invoke
266-
gem_files = FileList["braintrust-*.gem"]
267-
raise "No gem file found after build" if gem_files.empty?
268-
sh "gem push #{gem_files.first}"
269-
puts "✓ Prerelease #{prerelease_version} published to RubyGems"
270-
ensure
271-
# Restore original version
272-
File.write(version_file, content)
273-
puts "Restored original version.rb"
225+
if ENV["DRY_RUN"] == "true"
226+
puts "DRY RUN: would push tag #{tag} to origin (skipped)"
227+
else
228+
# TEMPORARILY DISABLED FOR TESTING — re-enable before merging
229+
puts "REAL PATH: git tag #{tag} + push (disabled for testing)"
230+
# sh "git tag #{tag}"
231+
# sh "git push origin #{tag}"
232+
# puts "✓ Tag #{tag} pushed"
274233
end
275234
end
276235
end
277236

278-
task release: ["release:publish", "release:github"] do
279-
puts "✓ Release completed successfully!"
237+
# Called by rubygems/release-gem in the release workflow.
238+
# Follows Bundler convention: build, push gem, push tag.
239+
# GitHub release creation is handled separately by the workflow.
240+
task release: ["release:publish", "release:push_tag"] do
241+
puts "✓ Release complete"
280242
end
281243

282244
# Contrib tasks

scripts/generate-release-notes.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

scripts/validate-release-tag.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)