From d3a9d8be1bfa56f3d7f4d0e563f332b9bbeea721 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Wed, 4 Oct 2023 10:06:54 +0200 Subject: [PATCH] Use bundler gem tasks instead of gem_release Now that we also have a solidus_admin that follows a different release track we need more control over what gems are released. `gem_release` has no such control available and simply has a configuration for recursing. Also all the features of `gem_relerase` regarding version numbers manipulation are no longer relevant as it all happens within GitHub Actions using dev_tools. Bundler gem tasks are now the standard for all our extensions and are a simpler, already available, tool that can be leveraged here as well. Redefine the release task skipping tag creation as it's handled by GitHub Actions. --- .gem_release.yml | 7 ------ Gemfile | 1 - Rakefile | 58 ++++++++++++------------------------------------ api/Rakefile | 1 + backend/Rakefile | 1 + core/Rakefile | 1 + sample/Rakefile | 1 + 7 files changed, 18 insertions(+), 52 deletions(-) delete mode 100644 .gem_release.yml diff --git a/.gem_release.yml b/.gem_release.yml deleted file mode 100644 index 5116ee46ded..00000000000 --- a/.gem_release.yml +++ /dev/null @@ -1,7 +0,0 @@ -bump: - recurse: false - file: 'core/lib/spree/core/version.rb' - message: Bump Solidus to %{version} - -release: - recurse: true diff --git a/Gemfile b/Gemfile index fa0a1cb1042..78a0b34c5ad 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,6 @@ group :utils do gem 'rubocop', '~> 0.75.0', require: false gem 'rubocop-performance', '~> 1.4', require: false gem 'rubocop-rails', '~> 2.3', require: false - gem 'gem-release', require: false end gem 'rspec_junit_formatter', require: false, group: :ci diff --git a/Rakefile b/Rakefile index 88f7bc8ea35..f352bc442ee 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'bundler' +require 'bundler/gem_tasks' task default: :spec @@ -52,54 +53,23 @@ task :clean do end end -namespace :gem do - def version - require_relative 'core/lib/spree/core/version' - Spree.solidus_version - end - - def for_each_gem - %w(core api backend frontend sample).each do |gem_name| - print_title(gem_name) - yield "pkg/solidus_#{gem_name}-#{version}.gem" - end - print_title - yield "pkg/solidus-#{version}.gem" - end - - desc "Build all solidus gems" - task :build do - pkgdir = File.expand_path('pkg', __dir__) - FileUtils.mkdir_p pkgdir - - %w(core api backend frontend sample).each do |gem_name| - Dir.chdir(gem_name) do - sh "gem build solidus_#{gem_name}.gemspec" - mv "solidus_#{gem_name}-#{version}.gem", pkgdir - end - end +SOLIDUS_GEM_NAMES = %w[core api backend sample] - print_title - sh "gem build solidus.gemspec" - mv "solidus-#{version}.gem", pkgdir - end - - desc "Install all solidus gems" - task install: :build do - for_each_gem do |gem_path| - Bundler.with_clean_env do - sh "gem install #{gem_path}" - end +%w[build install].each do |task_name| + desc "Run rake #{task} for each Solidus gem" + task task_name do + SOLIDUS_GEM_NAMES.each do |gem_name| + cd(gem_name) { sh "rake #{task_name}" } end end +end - desc "Release all gems to rubygems" - task release: :build do - sh "git tag -a -m \"Version #{version}\" v#{version}" - - for_each_gem do |gem_path| - sh "gem push '#{gem_path}'" - end +# We need to redefine release task to skip creating and pushing git tag +Rake::Task["release"].clear +desc "Build and push solidus gems to RubyGems" +task "release" => ["build", "release:guard_clean", "release:rubygem_push"] do + SOLIDUS_GEM_NAMES.each do |gem_name| + cd(gem_name) { sh "rake release:rubygem_push" } end end diff --git a/api/Rakefile b/api/Rakefile index 8d65355b382..5eafefdd818 100644 --- a/api/Rakefile +++ b/api/Rakefile @@ -5,6 +5,7 @@ require 'rake' require 'rake/testtask' require 'rspec/core/rake_task' require 'spree/testing_support/dummy_app/rake_tasks' +require 'bundler/gem_tasks' RSpec::Core::RakeTask.new task default: :spec diff --git a/backend/Rakefile b/backend/Rakefile index e81acac764f..54eddff77b2 100644 --- a/backend/Rakefile +++ b/backend/Rakefile @@ -4,6 +4,7 @@ require 'rubygems' require 'rake' require 'rake/testtask' require 'rspec/core/rake_task' +require 'bundler/gem_tasks' require 'solidus_backend' require 'spree/testing_support/dummy_app/rake_tasks' diff --git a/core/Rakefile b/core/Rakefile index 65434a4670b..65b6bf05c7b 100644 --- a/core/Rakefile +++ b/core/Rakefile @@ -5,6 +5,7 @@ require 'rake' require 'rake/testtask' require 'rspec/core/rake_task' require 'spree/testing_support/dummy_app/rake_tasks' +require 'bundler/gem_tasks' RSpec::Core::RakeTask.new task default: :spec diff --git a/sample/Rakefile b/sample/Rakefile index de23db05f96..c392cfd6396 100644 --- a/sample/Rakefile +++ b/sample/Rakefile @@ -4,6 +4,7 @@ require 'rake' require 'rake/testtask' require 'rspec/core/rake_task' require 'spree/testing_support/dummy_app/rake_tasks' +require 'bundler/gem_tasks' RSpec::Core::RakeTask.new task default: :spec