Skip to content

Commit

Permalink
Merge pull request #1 from KrauseFx/master
Browse files Browse the repository at this point in the history
upstream
  • Loading branch information
coreyfloyd committed Apr 12, 2015
2 parents 5b5330a + 5af0140 commit 897567e
Show file tree
Hide file tree
Showing 54 changed files with 541 additions and 144 deletions.
26 changes: 25 additions & 1 deletion bin/fastlane
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,34 @@ class FastlaneApplication
end
end

command :actions do |c|
c.syntax = 'fastlane actions'
c.description = 'Lists all available fastlane actions'

c.action do |_args, _options|
require 'fastlane/actions_list'
Fastlane::ActionsList.run(_args.first)
end
end

command :action do |c|
c.syntax = 'fastlane action [tool_name]'
c.description = 'Shows more information for a specific command'
c.action do |_args, _options|
require 'fastlane/actions_list'
Fastlane::ActionsList.run(_args.first)
end
end

default_command :run

run!
end
end

FastlaneApplication.new.run
begin
FastlaneCore::UpdateChecker.start_looking_for_update('fastlane')
FastlaneApplication.new.run
ensure
FastlaneCore::UpdateChecker.show_update_status('fastlane', Fastlane::VERSION)
end
11 changes: 9 additions & 2 deletions docs/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ This will register iOS devices with the Developer Portal so that you can include

This is an optimistic action, in that it will only ever add new devices to the member center, and never remove devices. If a device which has already been registered within the member center is not passed to this action, it will be left alone in the member center and continue to work.

If you're a member of multiple teams, you don't need to explicitly specify the team ID. In this case the action will try to get the team ID from ENV['CUPERTINO_TEAM_ID'], or ENV['FASTLANE_TEAM_ID'], in that order. So if you've specified the team ID using the team_id action, this action will automatically pick it up.
If you're a member of multiple teams, you don't need to explicitly specify the team ID. In this case the action will try to get the team ID from `ENV['CUPERTINO_TEAM_ID']`, or `ENV['FASTLANE_TEAM_ID']`, in that order. So if you've specified the team ID using the team_id action, this action will automatically pick it up.

The action will connect to the Apple Developer Portal using the username you specified in your `Appfile` with `apple_id`, but you can override it using the `username` option, or by setting the env variable ENV['CUPERTINO_USERNAME'].
The action will connect to the Apple Developer Portal using the username you specified in your `Appfile` with `apple_id`, but you can override it using the `username` option, or by setting the env variable `ENV['CUPERTINO_USERNAME']`.

```ruby
# Simply provide a list of devices as a Hash
Expand Down Expand Up @@ -499,6 +499,13 @@ Also useful for putting in your `error` block, to bring things back to a pristin
```ruby
reset_git_repo
reset_git_repo :force # If you don't care about warnings and are absolutely sure that you want to discard all changes. This will reset the repo even if you have valuable uncommitted changes, so use with care!

# You can also specify a list of files that should be resetted.
reset_git_repo(
force: true,
files: [
"./file.txt"
])
```

## Notifications
Expand Down
4 changes: 4 additions & 0 deletions docs/Advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ app_identifier "net.sunapps.1.beta"
apple_id "felix@krausefx.com"
team_id "Q2CBPJ58CC"
```
## Skip update check when launching `fastlane`
You can set the environment variable `FASTLANE_SKIP_UPDATE_CHECK` to skip the update check.
2 changes: 1 addition & 1 deletion docs/Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Additionally, to an Xcode installation, you also need the Xcode command line too

You don't have to use [homebrew](http://brew.sh/) to install the dependencies, but it is the easiest way to get started.

If you don't have [homebrew](http://brew.sh/) already installed, follow the guide on the [bottom of the official page](http://brew.sh/). The just make sure it's up to date.
If you don't have [homebrew](http://brew.sh/) already installed, follow the guide on the [bottom of the official page](http://brew.sh/). This just makes sure it's up to date.

brew doctor && brew update

Expand Down
28 changes: 15 additions & 13 deletions fastlane.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,26 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency 'nokogiri', '~> 1.6.5' # generating JUnit reports for Jenkins
spec.add_dependency 'shenzhen', '~> 0.12.1' # to upload to Hockey and Crashlytics
spec.add_dependency 'nokogiri', '~> 1.6' # generating JUnit reports for Jenkins
spec.add_dependency 'shenzhen', '~> 0.12' # to upload to Hockey and Crashlytics
spec.add_dependency 'slack-notifier', '~> 1.0' # Slack notifications
spec.add_dependency 'aws-sdk', '~> 1.0' # Upload ipa files to S3
spec.add_dependency 'xcodeproj', '~> 0.20' # Needed for commit_version_bump action
spec.add_dependency 'xcpretty', '~> 0.1' # prettify xcodebuild output
spec.add_dependency 'cupertino', '~> 1.3', '>= 1.3.1' # for registering iOS devices with the Apple Developer Center
spec.add_dependency 'fastlane_core', '>= 0.4.0' # all shared code and dependencies

spec.add_dependency 'deliver', '>= 0.7.13'
spec.add_dependency 'snapshot', '>= 0.4.0'
spec.add_dependency 'frameit', '>= 0.2.3'
spec.add_dependency 'pem', '>= 0.3.8'
spec.add_dependency 'sigh', '>= 0.4.5'
spec.add_dependency 'produce', '>= 0.1.6'
spec.add_dependency 'cert', '>= 0.1.3'

spec.add_dependency 'terminal-notifier', '~> 1.6.2'
spec.add_dependency 'terminal-notifier', '~> 1.6.2' # Mac OS X notifications
spec.add_dependency 'terminal-table', '~> 1.4.5' # Actions documentation

spec.add_dependency 'fastlane_core', '>= 0.5.2' # all shared code and dependencies

# All the fastlane tools
spec.add_dependency 'deliver', '>= 0.9.1'
spec.add_dependency 'snapshot', '>= 0.6.1'
spec.add_dependency 'frameit', '>= 1.0.0'
spec.add_dependency 'pem', '>= 0.4.0'
spec.add_dependency 'sigh', '>= 0.4.8'
spec.add_dependency 'produce', '>= 0.2.0'
spec.add_dependency 'cert', '>= 0.1.4'

# Development only
spec.add_development_dependency 'bundler'
Expand Down
2 changes: 1 addition & 1 deletion lib/assets/custom_action_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module SharedValues
[[NAME_UP]]_CUSTOM_VALUE = :[[NAME_UP]]_CUSTOM_VALUE
end

class [[NAME_CLASS]]
class [[NAME_CLASS]] < Action
def self.run(params)
puts "My Ruby Code!"
# puts "Parameter: #{params.first}"
Expand Down
6 changes: 1 addition & 5 deletions lib/fastlane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
require 'fastlane/fastlane_folder'
require 'fastlane/junit_generator'
require 'fastlane/lane_manager'
require 'fastlane/action'
require 'fastlane/actions/actions_helper'

require 'fastlane_core'

# Third Party code
require 'colored'

module Fastlane
Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore

FastlaneCore::UpdateChecker.verify_latest_version('fastlane', Fastlane::VERSION)

Fastlane::Actions.load_default_actions

if Fastlane::FastlaneFolder.path
Expand Down
33 changes: 33 additions & 0 deletions lib/fastlane/action.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Fastlane
class Action
def self.run(params)

end

def self.description
"No description provided".red
end

def self.available_options
# Return an array of 2-3 element arrays, like:
# [
# ['app_identifier', 'This value is responsible for X', 'ENVIRONMENT_VARIABLE'],
# ['app_identifier', 'This value is responsible for X']
# ]
# Take a look at sigh.rb if you're using the config manager of fastlane
nil
end

def self.output
# Return the keys you provide on the shared area
# [
# ['IPA_OUTPUT_PATH', 'The path to the newly generated ipa file']
# ]
nil
end

def self.author
"KrauseFx"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
All the methods, available for the lanes should be created here.

```fastlane``` will automatically detect the files in this folder
`fastlane` will automatically detect the files in this folder
8 changes: 8 additions & 0 deletions lib/fastlane/actions/actions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ def self.sh_no_action(command)
result
end

# Returns the current git branch - can be replaced using the environment variable `GIT_BRANCH`
def self.git_branch
return ENV['GIT_BRANCH'] if ENV['GIT_BRANCH'].to_s.length > 0 # set by Jenkins
s = `git rev-parse --abbrev-ref HEAD`
return s.to_s.strip if s.to_s.length > 0
nil
end

def self.load_default_actions
Dir[File.expand_path '*.rb', File.dirname(__FILE__)].each do |file|
require file
Expand Down
19 changes: 18 additions & 1 deletion lib/fastlane/actions/add_git_tag.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fastlane
module Actions
# Adds a git tag to the current commit
class AddGitTagAction
class AddGitTagAction < Action
def self.run(params)
params = params.first

Expand All @@ -17,6 +17,23 @@ def self.run(params)
Helper.log.info 'Adding git tag "#{tag}" 🎯.'
Actions.sh("git tag #{tag}")
end

def self.description
"This will add a git tag to the current branch"
end

def self.available_options
[
['tag', 'Define your own tag text. This will replace all other parameters.'],
['grouping', 'Is used to keep your tags organised under one "folder". Defaults to "builds"'],
['prefix', 'Anything you want to put in front of the version number (e.g. "v").'],
['build_number', 'The build number. Defaults to the result of increment_build_number if you\'re using it']
]
end

def self.author
"lmirosevic"
end
end
end
end
56 changes: 38 additions & 18 deletions lib/fastlane/actions/cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,58 @@ module SharedValues
CERT_CERTIFICATE_ID = :CERT_CERTIFICATE_ID
end

class CertAction
class CertAction < Action
def self.run(params)
require 'cert'
require 'cert/options'

return if Helper.test?

Dir.chdir(FastlaneFolder.path || Dir.pwd) do
# This should be executed in the fastlane folder
FastlaneCore::UpdateChecker.start_looking_for_update('cert')

values = params.first
unless values.kind_of?Hash
# Old syntax
values = {}
params.each do |val|
values[val] = true
begin
Dir.chdir(FastlaneFolder.path || Dir.pwd) do
# This should be executed in the fastlane folder

values = params.first
unless values.kind_of?Hash
# Old syntax
values = {}
params.each do |val|
values[val] = true
end
end
end

Cert.config = FastlaneCore::Configuration.create(Cert::Options.available_options, (values || {}))
Cert.config = FastlaneCore::Configuration.create(Cert::Options.available_options, (values || {}))

Cert::CertRunner.run
cert_file_path = ENV["CER_FILE_PATH"]
certificate_id = ENV["CER_CERTIFICATE_ID"]
Actions.lane_context[SharedValues::CERT_FILE_PATH] = cert_file_path
Actions.lane_context[SharedValues::CERT_CERTIFICATE_ID] = certificate_id
Cert::CertRunner.run
cert_file_path = ENV["CER_FILE_PATH"]
certificate_id = ENV["CER_CERTIFICATE_ID"]
Actions.lane_context[SharedValues::CERT_FILE_PATH] = cert_file_path
Actions.lane_context[SharedValues::CERT_CERTIFICATE_ID] = certificate_id

Helper.log.info("Use signing certificate '#{certificate_id}' from now on!".green)
Helper.log.info("Use signing certificate '#{certificate_id}' from now on!".green)

ENV["SIGH_CERTIFICATE_ID"] = certificate_id
ENV["SIGH_CERTIFICATE_ID"] = certificate_id
end
ensure
FastlaneCore::UpdateChecker.show_update_status('cert', Cert::VERSION)
end
end

def self.description
"Fetch or generate the latest available code signing identity"
end

def self.available_options
require 'cert'
require 'cert/options'
Cert::Options.available_options
end

def self.author
"KrauseFx"
end
end
end
end
10 changes: 9 additions & 1 deletion lib/fastlane/actions/clean_build_artifacts.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fastlane
module Actions
class CleanBuildArtifactsAction
class CleanBuildArtifactsAction < Action
def self.run(_params)
[
Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH],
Expand All @@ -10,6 +10,14 @@ def self.run(_params)

Helper.log.info 'Cleaned up build artifacts 🐙'.green
end

def self.description
"Deletes files created as result of running ipa or sigh"
end

def self.author
"lmirosevic"
end
end
end
end
8 changes: 6 additions & 2 deletions lib/fastlane/actions/commit_version_bump.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fastlane
module Actions
# Commits the current changes in the repo as a version bump, checking to make sure only files which contain version information have been changed.
class CommitVersionBumpAction
class CommitVersionBumpAction < Action
def self.run(params)
require 'xcodeproj'
require 'pathname'
Expand Down Expand Up @@ -59,7 +59,11 @@ def self.run(params)

# check if the files changed are the ones we expected to change (these should be only the files that have version info in them)
changed_files_as_expected = (Set.new(git_dirty_files) == Set.new(expected_changed_files))
raise "Found unexpected uncommited changes in the working directory. Expected these files to have changed: #{expected_changed_files}. But found these actual changes: #{git_dirty_files}. Make sure you have cleaned up the build artifacts and are only left with the changed version files at this stage in your lane, and don't touch the working directory while your lane is running.".red unless changed_files_as_expected
unless changed_files_as_expected
unless params[:force]
raise "Found unexpected uncommited changes in the working directory. Expected these files to have changed: #{expected_changed_files}. But found these actual changes: #{git_dirty_files}. Make sure you have cleaned up the build artifacts and are only left with the changed version files at this stage in your lane, and don't touch the working directory while your lane is running. You can also use the :force to not care about this.".red
end
end

# get the absolute paths to the files
git_add_paths = expected_changed_files.map { |path| File.expand_path(File.join(repo_pathname, path)) }
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/actions/crashlytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def command(_param)

module Fastlane
module Actions
class CrashlyticsAction
class CrashlyticsAction < Action
def self.run(params)
require 'shenzhen'
require 'shenzhen/plugins/crashlytics'
Expand Down

0 comments on commit 897567e

Please sign in to comment.