Skip to content

Commit

Permalink
first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Coledunsby committed Jul 5, 2018
1 parent 75ebdb5 commit 80725f3
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 106 deletions.
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
7 changes: 1 addition & 6 deletions fastlane-plugin-release.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ Gem::Specification.new do |spec|
spec.email = '[email protected]'

spec.summary = 'Automates the steps to create a new release for a project.'
# spec.homepage = "https://github.com/<GITHUB_USERNAME>/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')
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
lane :test do
release
make_release
end
13 changes: 5 additions & 8 deletions lib/fastlane/plugin/release.rb
Original file line number Diff line number Diff line change
@@ -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
164 changes: 164 additions & 0 deletions lib/fastlane/plugin/release/actions/make_release_action.rb
Original file line number Diff line number Diff line change
@@ -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
47 changes: 0 additions & 47 deletions lib/fastlane/plugin/release/actions/release_action.rb

This file was deleted.

12 changes: 12 additions & 0 deletions lib/fastlane/plugin/release/helper/make_release_helper.rb
Original file line number Diff line number Diff line change
@@ -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
16 changes: 0 additions & 16 deletions lib/fastlane/plugin/release/helper/release_helper.rb

This file was deleted.

6 changes: 3 additions & 3 deletions lib/fastlane/plugin/release/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module Release
VERSION = "0.1.0"
end
module Release
VERSION = "0.1.0"
end
end
4 changes: 2 additions & 2 deletions spec/release_action_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 80725f3

Please sign in to comment.