diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 0000000..5e58a87 --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,28 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/ci.yml': + - 'actions/checkout@v7.0.1' + - 'ruby/setup-ruby@v1.336.0' + '.github/workflows/publish.yml': + - 'actions/checkout@v7.0.1' + - 'googleapis/release-please-action@v5.0.0' + - 'ruby/setup-ruby@v1.336.0' +dependencies: + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'googleapis/release-please-action@v5.0.0': + ref: 'v5.0.0' + commit: 'sha1-45996ed1f6d02564a971a2fa1b5860e934307cf7' + owner_id: 16785467 + repo_id: 262236530 + 'ruby/setup-ruby@v1.336.0': + ref: 'v1.336.0' + commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94' + owner_id: 210414 + repo_id: 231208785 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bc84b0..df26a54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,57 +1,62 @@ name: CI -on: [push] + +on: + push: + branches: + - main + pull_request: + jobs: rubocop: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.1 - - uses: ruby/setup-ruby@v1 + - uses: ruby/setup-ruby@v1.336.0 with: - ruby-version: 3.3 + ruby-version: '3.4' bundler-cache: true - name: Run rubocop - run: bundle exec rubocop + run: bundle exec rubocop --format github brakeman: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.1 - - uses: ruby/setup-ruby@v1 + - uses: ruby/setup-ruby@v1.336.0 with: - ruby-version: 3.3 + ruby-version: '3.4' bundler-cache: true - name: Run brakeman - run: bundle exec brakeman --quiet --format tabs --force-scan + run: bundle exec brakeman --quiet --format github --force-scan rspec: strategy: fail-fast: false matrix: ruby: - - '3.2' - '3.3' - '3.4' + - '4.0' gemfile: - - rails_7_1 - - rails_7_2 - rails_8_0 + - rails_8_1 runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.1 - name: Set BUNDLE_GEMFILE run: echo 'BUNDLE_GEMFILE=${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile' >> $GITHUB_ENV - - uses: ruby/setup-ruby@v1 + - uses: ruby/setup-ruby@v1.336.0 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1eb86dc..aa717f0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,58 +1,73 @@ name: Publish + on: - release: - types: [published] + push: + branches: + - main + +permissions: + contents: write + packages: write + pull-requests: write jobs: + release: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + sha: ${{ steps.release.outputs.sha }} + steps: + - uses: googleapis/release-please-action@v5.0.0 + id: release + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + # Separate jobs so a failed upload can be retried with "Re-run failed jobs" without publishing twice publish-github: + needs: release + if: ${{ needs.release.outputs.release_created == 'true' }} runs-on: ubuntu-latest steps: - - name: Checkout repo - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v7.0.1 + with: + ref: ${{ needs.release.outputs.sha }} - name: Setup Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1.336.0 with: - ruby-version: 3.0 + ruby-version: '3.4' - - name: Setup GitHub Package Registry credentials + - name: Build and publish gem to GitHub Package Registry run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials printf -- "---\n:github: Bearer ${{ secrets.GITHUB_TOKEN }}\n" > $HOME/.gem/credentials - - - name: Replace version by tag value - run: sed -i "s/'[0-9]\.[0-9]\..*'/'${GITHUB_REF##*/}'/" lib/keypairs/version.rb - - - name: Build and Publish gem to GitHub Package Registry - run: | gem build --verbose *.gemspec gem push --verbose --key github --host https://rubygems.pkg.github.com/${OWNER} *.gem env: OWNER: Drieam publish-rubygems: + needs: release + if: ${{ needs.release.outputs.release_created == 'true' }} runs-on: ubuntu-latest steps: - - name: Checkout repo - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v7.0.1 + with: + ref: ${{ needs.release.outputs.sha }} - name: Setup Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1.336.0 with: - ruby-version: 3.0 + ruby-version: '3.4' - - name: Replace version by tag value - run: sed -i "s/'[0-9]\.[0-9]\..*'/'${GITHUB_REF##*/}'/" lib/keypairs/version.rb - - - name: Publish to RubyGems + - name: Build and publish gem to RubyGems run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials gem build --verbose *.gemspec gem push --verbose *.gem env: - GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}} + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }} diff --git a/.gitignore b/.gitignore index 3358b34..5c5db6d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ log/*.log pkg/ spec/internal/db/*.sqlite3 +spec/internal/db/*.sqlite3-* spec/internal/log/*.log spec/internal/storage/ diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..ed49281 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1 @@ +{".":"2.0.1"} diff --git a/.rubocop.yml b/.rubocop.yml index ac548ea..ec9dbd1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,9 @@ -require: +plugins: - rubocop-performance # Performance optimization analysis - rubocop-rails # Rails-specific analysis AllCops: - TargetRubyVersion: 3.2 + TargetRubyVersion: 3.3 NewCops: enable Exclude: - 'gemfiles/*' diff --git a/Appraisals b/Appraisals index 5d275a7..22f81ff 100644 --- a/Appraisals +++ b/Appraisals @@ -1,13 +1,9 @@ # frozen_string_literal: true -appraise 'rails-6-1' do - gem 'rails', '~> 6.1.0' +appraise 'rails-8-0' do + gem 'rails', '>= 8.0', '< 8.1' end -appraise 'rails-7-0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7-1' do - gem 'rails', '~> 7.1.0' +appraise 'rails-8-1' do + gem 'rails', '>= 8.1', '< 8.2' end diff --git a/README.md b/README.md index a9a5557..4ab441a 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,10 @@ get :jwks, to: Keypairs::PublicKeysController.action(:index) ``` ## Releasing new version -Publishing a new version is handled by the publish workflow. This workflow publishes a GitHub release to rubygems and GitHub package registry with the version defined in the release. +Publishing a new version is handled by [release-please](https://github.com/googleapis/release-please). Whenever a PR is +merged, release-please will create/update a versioning PR. Once this versioning PR is approved and merged, a new version +of the gem will automatically be published to RubyGems and the GitHub package registry. The changelog will be updated +automatically. ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/Drieam/keypairs. diff --git a/gemfiles/rails_7_2.gemfile b/gemfiles/rails_7_2.gemfile deleted file mode 100644 index 92cc2b2..0000000 --- a/gemfiles/rails_7_2.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 7.2.0" - -gemspec path: "../" diff --git a/gemfiles/rails_8_0.gemfile b/gemfiles/rails_8_0.gemfile index 3b3765b..3100613 100644 --- a/gemfiles/rails_8_0.gemfile +++ b/gemfiles/rails_8_0.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "~> 8.0.0" +gem "rails", ">= 8.0", "< 8.1" gemspec path: "../" diff --git a/gemfiles/rails_7_1.gemfile b/gemfiles/rails_8_1.gemfile similarity index 74% rename from gemfiles/rails_7_1.gemfile rename to gemfiles/rails_8_1.gemfile index 35a0ba3..434ad83 100644 --- a/gemfiles/rails_7_1.gemfile +++ b/gemfiles/rails_8_1.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "~> 7.1.0" +gem "rails", ">= 8.1", "< 8.2" gemspec path: "../" diff --git a/keypairs.gemspec b/keypairs.gemspec index b3ba7b3..4684547 100644 --- a/keypairs.gemspec +++ b/keypairs.gemspec @@ -18,15 +18,16 @@ Gem::Specification.new do |spec| spec.description = spec.summary spec.license = 'MIT' - spec.required_ruby_version = '>= 3.2' + spec.required_ruby_version = '>= 3.3' spec.metadata['homepage_uri'] = spec.homepage spec.metadata['source_code_uri'] = 'https://github.com/Drieam/keypairs' spec.files = Dir['{app,db,lib}/**/*', 'LICENSE', 'README.md'] - spec.add_dependency 'actionpack', '>= 7.1', '< 9' # Depend on actionpack to share public keys - spec.add_dependency 'activerecord', '>= 7.1', '< 9' # Depend on activerecord as ORM + spec.add_dependency 'actionpack', '>= 8.0', '< 9' # Depend on actionpack to share public keys + spec.add_dependency 'activerecord', '>= 8.0', '< 9' # Depend on activerecord as ORM + spec.add_dependency 'json', '< 3.0' # json 3.0 has breaking changes spec.add_dependency 'jwt', '>= 2.5', '< 4' # Working with JSON Web Tokens spec.add_dependency 'lockbox', '>= 1.3', '< 3.0' # Encrypt and decrypt attributes diff --git a/lib/keypairs/version.rb b/lib/keypairs/version.rb index d354a9b..0083b24 100644 --- a/lib/keypairs/version.rb +++ b/lib/keypairs/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Keypairs - VERSION = '1.3.4.develop' + VERSION = '2.0.1' end diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..0bffd29 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,9 @@ +{ + "packages": { + ".": { + "release-type": "ruby", + "version-file": "lib/keypairs/version.rb", + "include-v-in-tag": false + } + } +} diff --git a/spec/internal/db/keypairs_test.sqlite3-shm b/spec/internal/db/keypairs_test.sqlite3-shm deleted file mode 100644 index 7560940..0000000 Binary files a/spec/internal/db/keypairs_test.sqlite3-shm and /dev/null differ diff --git a/spec/internal/db/keypairs_test.sqlite3-wal b/spec/internal/db/keypairs_test.sqlite3-wal deleted file mode 100644 index 0298dde..0000000 Binary files a/spec/internal/db/keypairs_test.sqlite3-wal and /dev/null differ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6e06149..d49bdce 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,10 +7,10 @@ Bundler.require(*Rails.groups) -Rails.application.config.cache_store = :null_store - # Load the parts from rails we need with combustion -Combustion.initialize! :active_record, :action_controller +Combustion.initialize! :active_record, :action_controller do + config.cache_store = :null_store +end require 'rspec/rails'