Created
February 20, 2019 11:04
-
-
Save rockname/d30829947f9d00bee2b8be61ab70f6db to your computer and use it in GitHub Desktop.
CarthageのライブラリをアップデートしてPullRequestを作成するFastlaneのlane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lane :update_carthage_libraries do |options| | |
| outdateds = "" | |
| Dir.chdir ".." do | |
| outdateds += sh("carthage", "outdated") | |
| end | |
| current_branch = git_branch | |
| outdateds.each_line do |line| | |
| if outdated = line.match(/^(.+?) "(.+?)\.(.+?)\.(.+?)" -> "(.+?)\.(.+?)\.(.+?)"/) then | |
| lib = outdated[1] | |
| old_major = outdated[2] | |
| old_minor = outdated[3] | |
| old_patch = outdated[4] | |
| new_major = outdated[5] | |
| new_minor = outdated[6] | |
| new_patch = outdated[7] | |
| if old_major != new_major || old_minor != new_minor || old_patch != new_patch then | |
| BRANCH_NAME = "update-library-#{lib}-" + Time.now.strftime("%Y%m%d%H%M") | |
| sh("git", "checkout", "-b", BRANCH_NAME) | |
| carthage( | |
| command: "update", | |
| dependencies: [lib], | |
| platform: "ios" | |
| ) | |
| git_add(path: ".") | |
| git_commit(path: ".", message: "Update Library #{lib}.") | |
| version = line.match(/"(.*?)" -> "(.*?)"/) | |
| old_version = version[1] | |
| new_version = version[2] | |
| diff = sh("git", "diff", "--", "../Cartfile.resolved") | |
| repo = diff.match(/-github "(.+?)"/)[1] | |
| body = "## #{repo}\n" | |
| body += "#{old_version} -> [#{new_version}](https://github.com/#{repo}/releases/tag/#{new_version})\n" | |
| body += "[compare](https://github.com/#{repo}/compare/#{old_version}...#{new_version})\n" | |
| sh("git", "push", "origin", BRANCH_NAME) | |
| create_pull_request( | |
| api_token: ENV["GITHUB_API_TOKEN"], | |
| repo: "YOUR_REPOSITORY_NAME", | |
| title: "[Auto generated] Update library #{lib}", | |
| body: body | |
| ) | |
| sh("git", "checkout", current_branch) | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment