Sha256: e091a50a23ac6c47b5a2760aefd23b95c7bbd3d0fd0130a9d6a8bc453ad15cfa

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require "milestoner"

module Gemsmith
  module Rake
    # Provides gem release functionality. Meant to be wrapped in Rake tasks.
    class Release
      def initialize gem_spec_path = Dir.glob("#{Dir.pwd}/*.gemspec").first,
                     bundler: Bundler,
                     publisher: Milestoner::Publisher.new,
                     shell: Bundler::UI::Shell.new

        @gem_spec_path = gem_spec_path
        @publisher = publisher
        @shell = shell
        @gem_spec = bundler.load_gemspec gem_spec_path.to_s
      rescue Errno::ENOENT
        @shell.error "Invalid gemspec file path: #{@gem_spec_path}."
      end

      def version_number
        gem_spec.version.version
      end

      def version_label
        "v#{version_number}"
      end

      def gem_file_name
        "#{gem_spec.name}-#{version_number}.gem"
      end

      def publish
        publisher.publish version_number, sign: true
      rescue Milestoner::Errors::Base => error
        shell.error error.message
      end

      private

      attr_reader :gem_spec_path, :gem_spec, :publisher, :shell
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemsmith-7.2.0 lib/gemsmith/rake/release.rb
gemsmith-7.1.0 lib/gemsmith/rake/release.rb
gemsmith-7.0.0 lib/gemsmith/rake/release.rb