Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release

on:
push:
tags: ["v*"]

permissions:
contents: read

jobs:
push:
name: Push the gem to RubyGems.org
runs-on: ubuntu-latest
permissions:
contents: write # create the GitHub release
id-token: write # mint the RubyGems trusted publishing token

steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
- name: Check the tag against PpSql::VERSION
run: |
version="v$(ruby -Ilib -rpp_sql/version -e 'print PpSql::VERSION')"
if [ "$version" != "$GITHUB_REF_NAME" ]; then
echo "tag $GITHUB_REF_NAME does not match PpSql::VERSION ($version)" >&2
exit 1
fi
- name: Build the gem
run: gem build pp_sql.gemspec
# Exchanges the Actions OIDC token for a short lived RubyGems token, so
# the push carries no API key and satisfies rubygems_mfa_required.
- name: Configure RubyGems credentials
uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
- name: Push the gem
run: gem push pp_sql-*.gem

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make release creation retryable after publishing

If gh release create fails after the gem is successfully published—for example, due to a transient GitHub API or asset-upload failure—rerunning this workflow stops here because RubyGems rejects publishing the same name/version again, so the GitHub release can never be retried through the workflow. gem help push confirms that this command uploads the gem and adds it to the index, while gh release create --help describes release creation as a separate later operation. Make the publication/release sequence idempotent, such as by detecting an already-published gem and continuing to the release step.

Useful? React with 👍 / 👎.

- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --generate-notes pp_sql-*.gem
6 changes: 1 addition & 5 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['3.2', '3.3', '3.4']
ruby-version: ['3.3', '3.4', '4.0']
gemfile:
- gemfiles/rails_7_1.gemfile
- gemfiles/rails_7_2.gemfile
- gemfiles/rails_8_0.gemfile
- gemfiles/rails_8_1.gemfile
- gemfiles/activerecord_7_1.gemfile
- gemfiles/activerecord_7_2.gemfile
- gemfiles/activerecord_8_0.gemfile
- gemfiles/activerecord_8_1.gemfile

Expand Down
26 changes: 0 additions & 26 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ skip_gems_snippet = <<~GEMS
end
GEMS

appraise 'rails-7-1' do
gem 'rails', '~> 7.1.0'
gem 'sqlite3', '~> 2.0'
eval(skip_gems_snippet)
end

appraise 'rails-7-2' do
gem 'rails', '~> 7.2.0'
gem 'sqlite3', '~> 2.0'
eval(skip_gems_snippet)
end

appraise 'rails-8-0' do
gem 'rails', '~> 8.0.0'
gem 'sqlite3', '~> 2.0'
Expand All @@ -31,20 +19,6 @@ appraise 'rails-8-1' do
eval(skip_gems_snippet)
end

appraise 'activerecord-7-1' do
gem 'activerecord', '~> 7.1.0'
gem 'rake'
gem 'sqlite3', '~> 2.0'
eval(skip_gems_snippet)
end

appraise 'activerecord-7-2' do
gem 'activerecord', '~> 7.2.0'
gem 'rake'
gem 'sqlite3', '~> 2.0'
eval(skip_gems_snippet)
end

appraise 'activerecord-8-0' do
gem 'activerecord', '~> 8.0.0'
gem 'rake'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ group :local_development do
gem 'appraisal'
gem 'overcommit'
gem 'pry'
gem 'rails', '>= 7.1'
gem 'rails', '>= 8.0'
gem 'reek'
gem 'rubocop', '~> 1.85'
gem 'sqlite3', '>= 1.4'
gem 'sqlite3', '~> 2.0'
end
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Or in console

## Require

Ruby 3.1+
Ruby 3.3+

## Rails

Rails / ActiveRecord 7.1+ (optional), will be injected automatically
Rails / ActiveRecord 8.0+ (optional), will be injected automatically

## Legacy

Expand Down Expand Up @@ -102,8 +102,21 @@ bundle exec appraisal install
bundle exec appraisal rake
```

GitHub Actions runs the Rails / ActiveRecord `7.1`, `7.2`, `8.0`, and `8.1`
matrix on Ruby `3.2`, `3.3`, and `3.4`.
GitHub Actions runs the Rails / ActiveRecord `8.0` and `8.1` matrix on
Ruby `3.3`, `3.4`, and `4.0`.

## Releasing

Bump `PpSql::VERSION`, merge it, then push the matching tag:

```bash
git tag v2.3.0
git push origin v2.3.0
```

The `Release` workflow checks the tag against `PpSql::VERSION`, builds the gem,
pushes it to RubyGems.org through trusted publishing and creates the GitHub
release.

## License

Expand Down
10 changes: 0 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'PpSql'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end

require 'bundler/gem_tasks'

require 'rake/testtask'
Expand Down
17 changes: 0 additions & 17 deletions gemfiles/activerecord_7_1.gemfile

This file was deleted.

17 changes: 0 additions & 17 deletions gemfiles/activerecord_7_2.gemfile

This file was deleted.

16 changes: 0 additions & 16 deletions gemfiles/rails_7_1.gemfile

This file was deleted.

16 changes: 0 additions & 16 deletions gemfiles/rails_7_2.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion lib/pp_sql/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module PpSql
VERSION = '2.2.0'
VERSION = '2.3.0'
end
4 changes: 2 additions & 2 deletions pp_sql.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Gem::Specification.new do |s|

s.files = Dir['lib/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']

s.required_ruby_version = '>= 3.1.0'
s.required_ruby_version = '>= 3.3.0'

s.add_dependency 'activerecord'
s.add_dependency 'activerecord', '>= 8.0'
s.add_dependency 'anbt-sql-formatter', '~> 0.1.0'

s.metadata['rubygems_mfa_required'] = 'true'
Expand Down