diff --git a/README.md b/README.md index cbb24e0..063c9da 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# release plugin +# release fastlane plugin -[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-release) +[![License](https://img.shields.io/github/license/Coledunsby/fastlane-plugin-release.svg)](https://github.com/Coledunsby/fastlane-plugin-release/blob/master/LICENSE) +[![Gem](https://img.shields.io/gem/v/fastlane-plugin-release.svg?style=flat)](http://rubygems.org/gems/fastlane-plugin-release) +[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-podspec_dependency_versioning) ## Getting Started @@ -12,27 +14,26 @@ fastlane add_plugin release ## About release -Automates the steps to create a new release for a project. - -**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here. - -## Example - -Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`. - -**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary) - -## Run tests for this plugin - -To run both the tests, and code style validation, run - -``` -rake -``` - -To automatically fix many of the styling issues, use -``` -rubocop -a +Extends fastlane release actions. Automates the steps to create a new release for a framework. + +## Actions + +### make_release + +```ruby +make_release( + allow_warnings: true, # Allow warnings during pod push; optional; default = true + bump_build: false, # Increments the build number; optional; default = false + ensure_git_branch: "master", # The branch that should be checked for; optional; default = "master" + ensure_git_status_clean: true, # Raises an exception if there are uncommitted git changes; optional; default = true + podspec: "Nitrous.podspec", # The path of the podspec; mandatory + podspec_repo: "coledunsby", # The podspec repo; optional; default = "Trunk" + sources: [...], # The sources of repos you want the pod spec to lint with; optional; default = ["https://github.com/CocoaPods/Specs"] + tag_prefix: "v/", # A prefix to be added to the version tag (e.g. "v/"); optional; default = "" + version: "2.0.2", # Change to a specific version. Cannot be used in conjuction with version_bump_type; optional; default = nil + version_bump_type: "patch", # The type of this version bump. Available: patch, minor, major; optional; default = "patch" + xcodeproj: "Nitrous.xcodeproj" # The path of the xcode project; mandatory +) ``` ## Issues and Feedback diff --git a/fastlane-plugin-release.gemspec b/fastlane-plugin-release.gemspec index 701b96f..e05f074 100644 --- a/fastlane-plugin-release.gemspec +++ b/fastlane-plugin-release.gemspec @@ -11,18 +11,13 @@ Gem::Specification.new do |spec| spec.email = 'coledunsby@gmail.com' spec.summary = 'Automates the steps to create a new release for a project.' - # spec.homepage = "https://github.com//fastlane-plugin-release" + spec.homepage = "https://github.com/Coledunsby/fastlane-plugin-release" spec.license = "MIT" spec.files = Dir["lib/**/*"] + %w(README.md LICENSE) spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - # Don't add a dependency to fastlane or fastlane_re - # since this would cause a circular dependency - - # spec.add_dependency 'your-dependency', '~> 1.0.0' - spec.add_development_dependency('pry') spec.add_development_dependency('bundler') spec.add_development_dependency('rspec') diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 9f08314..56fe278 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,3 +1,3 @@ lane :test do - release + make_release end diff --git a/lib/fastlane/plugin/release.rb b/lib/fastlane/plugin/release.rb index 7bec39c..b654f97 100644 --- a/lib/fastlane/plugin/release.rb +++ b/lib/fastlane/plugin/release.rb @@ -1,16 +1,13 @@ require 'fastlane/plugin/release/version' module Fastlane - module Release - # Return all .rb files inside the "actions" and "helper" directory - def self.all_classes - Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))] + module Release + def self.all_classes + Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))] + end end - end end -# By default we want to import all available actions and helpers -# A plugin can contain any number of actions and plugins Fastlane::Release.all_classes.each do |current| - require current + require current end diff --git a/lib/fastlane/plugin/release/actions/make_release_action.rb b/lib/fastlane/plugin/release/actions/make_release_action.rb new file mode 100644 index 0000000..0a34d0a --- /dev/null +++ b/lib/fastlane/plugin/release/actions/make_release_action.rb @@ -0,0 +1,164 @@ +require 'fastlane/action' +require_relative '../helper/make_release_helper' + +module Fastlane + + module Actions + + class MakeReleaseAction < Action + + def self.run(params) + + other_action.ensure_git_branch(branch: params[:ensure_git_branch]) + other_action.ensure_git_status_clean if params[:ensure_git_status_clean] + + xcodeproj = File.expand_path(params[:xcodeproj]) + podspec = File.expand_path(params[:podspec]) + version = params[:version] + + if version.nil? + version = other_action.version_bump_podspec(path: podspec, bump_type: params[:version_bump_type]) + else + other_action.version_bump_podspec(path: podspec, version_number: version) + end + + other_action.increment_version_number(version_number: version, xcodeproj: xcodeproj) + other_action.increment_build_number(xcodeproj: xcodeproj) if params[:bump_build] + other_action.commit_version_bump(include: [params[:podspec]]) + other_action.add_git_tag(tag: params[:tag_prefix] + version) + other_action.push_to_git_remote + + other_action.pod_push( + path: podspec, + repo: params[:podspec_repo], + allow_warnings: params[:allow_warnings], + sources: params[:sources] + ) + + version + + end + + def self.description + "Automates the steps to create a new release for a framework." + end + + def self.authors + ["Cole Dunsby"] + end + + def self.return_value + "The new version" + end + + def self.details + "Automates the steps to create a new release for a framework." + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new( + key: :allow_warnings, + env_name: "ALLOW_WARNINGS", + default_value: true, + description: "Allow warnings during pod push", + optional: true, + type: Boolean + ), + FastlaneCore::ConfigItem.new( + key: :bump_build, + env_name: "BUMP_BUILD", + default_value: false, + description: "Will increment build number if enabled", + optional: true, + type: Boolean + ), + FastlaneCore::ConfigItem.new( + key: :ensure_git_branch, + env_name: "ENSURE_GIT_BRANCH", + default_value: "master", + description: "The branch that should be checked for. String that can be either the full name of the branch or a regex to match", + optional: true, + type: String + ), + FastlaneCore::ConfigItem.new( + key: :ensure_git_status_clean, + env_name: "ENSURE_GIT_STATUS_CLEAN", + default_value: true, + description: "Raises an exception if there are uncommitted git changes", + optional: true, + type: Boolean + ), + FastlaneCore::ConfigItem.new( + key: :podspec, + env_name: "PODSPEC", + description: "The path of the podspec file to update", + optional: false, + type: String, + verify_block: proc do |value| + UI.user_error!("Could not find podspec at path '#{File.expand_path(value)}'") if !File.exist?(value) + end + ), + FastlaneCore::ConfigItem.new( + key: :podspec_repo, + env_name: "PODSPEC_REPO", + default_value: "Trunk", + description: "The repo you want to push. Pushes to Trunk by default", + optional: true, + type: String + ), + FastlaneCore::ConfigItem.new( + key: :sources, + env_name: "SOURCES", + default_value: ["https://github.com/CocoaPods/Specs"], + description: "The sources of repos you want the pod spec to lint with, separated by commas", + optional: true, + type: Array + ), + FastlaneCore::ConfigItem.new( + key: :tag_prefix, + env_name: "TAG_PREFIX", + default_value: "", + description: "A prefix to be added to the version tag (e.g \"v/\")", + optional: true, + type: String + ), + FastlaneCore::ConfigItem.new( + key: :version, + env_name: "VERSION", + conflicting_options: [:version_bump_type], + description: "Change to a specific version. This will replace the bump type value", + optional: true, + type: String + ), + FastlaneCore::ConfigItem.new( + key: :version_bump_type, + env_name: "VERSION_BUMP_TYPE", + conflicting_options: [:version], + default_value: "patch", + description: "The type of this version bump. Available: patch, minor, major", + optional: true, + type: String, + verify_block: proc do |value| + UI.user_error!("Available values are 'patch', 'minor' and 'major'") unless ['patch', 'minor', 'major'].include?(value) + end + ), + FastlaneCore::ConfigItem.new( + key: :xcodeproj, + env_name: "XCODEPROJ", + description: "The path of the xcode project to update", + optional: false, + type: String, + verify_block: proc do |value| + UI.user_error!("Could not find xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) + end + ) + ] + end + + def self.is_supported?(platform) + [:ios, :mac].include?(platform) + end + end + end +end diff --git a/lib/fastlane/plugin/release/actions/release_action.rb b/lib/fastlane/plugin/release/actions/release_action.rb deleted file mode 100644 index 8f29994..0000000 --- a/lib/fastlane/plugin/release/actions/release_action.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'fastlane/action' -require_relative '../helper/release_helper' - -module Fastlane - module Actions - class ReleaseAction < Action - def self.run(params) - UI.message("The release plugin is working!") - end - - def self.description - "Automates the steps to create a new release for a project." - end - - def self.authors - ["Cole Dunsby"] - end - - def self.return_value - # If your method provides a return value, you can describe here what it does - end - - def self.details - # Optional: - "Automates the steps to create a new release for a project." - end - - def self.available_options - [ - # FastlaneCore::ConfigItem.new(key: :your_option, - # env_name: "RELEASE_YOUR_OPTION", - # description: "A description of your option", - # optional: false, - # type: String) - ] - end - - def self.is_supported?(platform) - # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) - # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform - # - # [:ios, :mac, :android].include?(platform) - true - end - end - end -end diff --git a/lib/fastlane/plugin/release/helper/make_release_helper.rb b/lib/fastlane/plugin/release/helper/make_release_helper.rb new file mode 100644 index 0000000..d9bc0c6 --- /dev/null +++ b/lib/fastlane/plugin/release/helper/make_release_helper.rb @@ -0,0 +1,12 @@ +require 'fastlane_core/ui/ui' + +module Fastlane + + UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") + + module Helper + class MakeReleaseHelper + + end + end +end diff --git a/lib/fastlane/plugin/release/helper/release_helper.rb b/lib/fastlane/plugin/release/helper/release_helper.rb deleted file mode 100644 index 42f9a89..0000000 --- a/lib/fastlane/plugin/release/helper/release_helper.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'fastlane_core/ui/ui' - -module Fastlane - UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") - - module Helper - class ReleaseHelper - # class methods that you define here become available in your action - # as `Helper::ReleaseHelper.your_method` - # - def self.show_message - UI.message("Hello from the release plugin helper!") - end - end - end -end diff --git a/lib/fastlane/plugin/release/version.rb b/lib/fastlane/plugin/release/version.rb index 0a92c06..83316cb 100644 --- a/lib/fastlane/plugin/release/version.rb +++ b/lib/fastlane/plugin/release/version.rb @@ -1,5 +1,5 @@ module Fastlane - module Release - VERSION = "0.1.0" - end + module Release + VERSION = "0.1.0" + end end diff --git a/spec/release_action_spec.rb b/spec/release_action_spec.rb index 560d6eb..1554b2e 100644 --- a/spec/release_action_spec.rb +++ b/spec/release_action_spec.rb @@ -1,9 +1,9 @@ -describe Fastlane::Actions::ReleaseAction do +describe Fastlane::Actions::MakeReleaseAction do describe '#run' do it 'prints a message' do expect(Fastlane::UI).to receive(:message).with("The release plugin is working!") - Fastlane::Actions::ReleaseAction.run(nil) + Fastlane::Actions::MakeReleaseAction.run(nil) end end end