Skip to content

Commit

Permalink
new action for reading cocoapod specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Honza Dvorsky committed Sep 3, 2015
1 parent 634b676 commit f3961bb
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
4 changes: 1 addition & 3 deletions fastlane/Fastfile
Expand Up @@ -36,7 +36,7 @@ platform :mac do
sh "cd .. && github_changelog_generator -t $GITHUB_TOKEN && subl CHANGELOG.md"

# assume version from the podspec
version = JSON.parse(sh "cd .. && pod spec cat *.podspec")['source']['tag']
version = read_cocoapod_spec['source']['tag']

# ask for info
title = prompt(text: 'Release Title: ')
Expand Down Expand Up @@ -74,8 +74,6 @@ platform :mac do

end

#TODO: create a lane for releasing a new podspec

after_all do |lane|

if lane == :postbuild
Expand Down
64 changes: 64 additions & 0 deletions fastlane/actions/read_cocoapod_spec.rb
@@ -0,0 +1,64 @@
module Fastlane
module Actions
module SharedValues
READ_COCOAPOD_SPEC_JSON = :READ_COCOAPOD_SPEC_JSON
end

class ReadCocoapodSpecAction < Action
def self.run(params)
path = params[:path] || Dir['*.podspec*'].first

# will fail if cocoapods is not installed
require 'cocoapods-core'
spec = Pod::Spec.from_file(path).to_hash

Helper.log.info "Reading podspec from file #{path}".green

Actions.lane_context[SharedValues::READ_COCOAPOD_SPEC_JSON] = spec
return spec
end

#####################################################
# @!group Documentation
#####################################################

def self.description
"Loads a CocoaPods spec as JSON"
end

def self.details
[
"This can be used for only specifying a version string in your podspec",
"- and during your release process you'd read it from the podspec by running",
"`version = read_cocoapod_spec['version']` at the beginning of your lane"
].join("\n")
end

def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_READ_COCOAPOD_SPEC_PATH",
description: "(Optional) Path to the podspec to be read",
optional: true,
verify_block: proc do |value|
raise "File #{value} not found".red unless File.exists?(spec_path)
end)
]
end

def self.output
[
['READ_COCOAPOD_SPEC_JSON', 'Podspec JSON payload']
]
end

def self.authors
["czechboy0"]
end

def self.is_supported?(platform)
true
end
end
end
end

0 comments on commit f3961bb

Please sign in to comment.