Skip to content

Commit 4343826

Browse files
committed
Add next_rc_version action
1 parent ff59c8c commit 4343826

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module Fastlane
2+
module Actions
3+
class NextRcVersionAction < Action
4+
def self.run(params)
5+
require 'octokit'
6+
require 'git'
7+
require_relative '../../helper/version_helper'
8+
9+
client = Octokit::Client.new(access_token: params[:access_token])
10+
client.auto_paginate = true
11+
12+
helper = Fastlane::Helper::VersionHelper.new(
13+
github_client: client,
14+
git: Git.open(Dir.pwd)
15+
)
16+
17+
version = Fastlane::Helper::Version.create(params[:version])
18+
next_version = helper.next_rc_for_version(version, repository: params[:project])
19+
20+
UI.message "Next RC Version is #{next_version.rc}"
21+
22+
next_version
23+
end
24+
25+
#####################################################
26+
# @!group Documentation
27+
#####################################################
28+
29+
def self.description
30+
'Return the next RC Version for this branch'
31+
end
32+
33+
def self.available_options
34+
[
35+
FastlaneCore::ConfigItem.new(
36+
key: :access_token,
37+
env_name: 'GITHUB_TOKEN',
38+
description: 'The GitHub token to use when querying GitHub',
39+
type: String,
40+
sensitive: true
41+
),
42+
FastlaneCore::ConfigItem.new(
43+
key: :version,
44+
description: 'The current version',
45+
type: String,
46+
verify_block: proc { |v| UI.user_error!("Invalid version number: #{v}") if Fastlane::Helper::Version.create(v).nil? }
47+
),
48+
FastlaneCore::ConfigItem.new(
49+
key: :project,
50+
description: 'The project slug (ex: `wordpress-mobile/wordpress-ios`)',
51+
type: String
52+
),
53+
FastlaneCore::ConfigItem.new(
54+
key: :project_root,
55+
env_name: 'PROJECT_ROOT_FOLDER',
56+
description: 'The project root folder (that contains the .git directory)',
57+
type: String,
58+
default_value: Dir.pwd,
59+
verify_block: proc { |v| UI.user_error!("Directory does not exist: #{v}") unless File.directory? v }
60+
),
61+
]
62+
end
63+
64+
def self.authors
65+
['Automattic']
66+
end
67+
68+
def self.is_supported?(platform)
69+
true
70+
end
71+
end
72+
end
73+
end

0 commit comments

Comments
 (0)