fastlane-plugin-nordalp_app_publish 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/nordalp_app_publish/actions/nordalp_app_publish_action.rb +95 -83
- data/lib/fastlane/plugin/nordalp_app_publish/helper/nordalp_app_publish_helper.rb +60 -70
- data/lib/fastlane/plugin/nordalp_app_publish/version.rb +5 -5
- data/lib/fastlane/plugin/nordalp_app_publish.rb +16 -16
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ae3b926dfb8c35cb52069f251079ddd581cee3ebc4cd8ea1b63e618686ddc13
|
|
4
|
+
data.tar.gz: 92ef57ca05bf5be16865d1ce1a92f8b9ce44274455edc4fbde6da3aeb733ed4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 221bb820fd68f26244389321694e8b713d5b90872fe80ad513138d6c8a1e3390a2e4c0ca6ad726136004b4ff80bb97e50914fce65e25e243025394b7742b7d15
|
|
7
|
+
data.tar.gz: 54a659e9b490fdd604a01ff35e1d3717840ecd384b82c1f5889baf1469bf26d64428665128440c0653acc0bb1fea253f4c5d4e365bbe59796250fe87c9bf90bf
|
|
@@ -1,83 +1,95 @@
|
|
|
1
|
-
require 'fastlane/action'
|
|
2
|
-
|
|
3
|
-
require 'redcarpet'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def self.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
require 'fastlane/action'
|
|
2
|
+
require 'fastlane_core'
|
|
3
|
+
require 'redcarpet'
|
|
4
|
+
|
|
5
|
+
require_relative '../helper/nordalp_app_publish_helper'
|
|
6
|
+
|
|
7
|
+
module Fastlane
|
|
8
|
+
module Actions
|
|
9
|
+
# Fastlane Plugin action class
|
|
10
|
+
class NordalpAppPublishAction < Action
|
|
11
|
+
# rubocop:disable Require/MissingRequireStatement
|
|
12
|
+
def self.run(params)
|
|
13
|
+
UI.message("Upload to #{params[:url]} using #{params[:token]}")
|
|
14
|
+
changelog = Helper::NordalpAppPublishHelper.read_first_changelog_entry('CHANGELOG.md')
|
|
15
|
+
UI.message("Changelog for #{changelog[:version]} @ #{changelog[:date]}")
|
|
16
|
+
|
|
17
|
+
jsons = lane_context[SharedValues::GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS]
|
|
18
|
+
links = lane_context[:S3_ALL_FILE_URL]
|
|
19
|
+
if jsons.length == links.length
|
|
20
|
+
# Markdown renderer to convert changelog to HTML
|
|
21
|
+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true)
|
|
22
|
+
|
|
23
|
+
jsons.each_with_index do |element, index|
|
|
24
|
+
# Read app data from json-output file
|
|
25
|
+
json_string = File.read(element)
|
|
26
|
+
data_hash = JSON.parse(json_string)
|
|
27
|
+
application_id = data_hash['applicationId']
|
|
28
|
+
version_code = data_hash['elements'][0]['versionCode']
|
|
29
|
+
version_name = data_hash['elements'][0]['versionName']
|
|
30
|
+
|
|
31
|
+
# Send data to CMS
|
|
32
|
+
# The CMS will discard any submissions with an application_id that does not yet have a record
|
|
33
|
+
post_data = {
|
|
34
|
+
changelog: {
|
|
35
|
+
version: changelog[:version],
|
|
36
|
+
date: changelog[:date],
|
|
37
|
+
# The Changelog expects the
|
|
38
|
+
text: markdown
|
|
39
|
+
.render(changelog[:text])
|
|
40
|
+
.gsub('<h3>', '<h5>')
|
|
41
|
+
.gsub('</h3>', '</h5>')
|
|
42
|
+
},
|
|
43
|
+
application_id: application_id,
|
|
44
|
+
link: links[index],
|
|
45
|
+
version_code: version_code,
|
|
46
|
+
version_name: version_name
|
|
47
|
+
}
|
|
48
|
+
result = Helper::NordalpAppPublishHelper.post_app(params[:url], params[:token], post_data)
|
|
49
|
+
UI.message("Sent #{application_id} with result #{result}")
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
UI.message('Number of items not equal in json and link arrays!')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
# rubocop:enable Require/MissingRequireStatement
|
|
56
|
+
|
|
57
|
+
def self.description
|
|
58
|
+
'Publish an app update to Nordalp website'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.authors
|
|
62
|
+
['ov3rk1ll']
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.return_value
|
|
66
|
+
# Optional
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.details
|
|
70
|
+
# Optional:
|
|
71
|
+
''
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.available_options
|
|
75
|
+
[
|
|
76
|
+
FastlaneCore::ConfigItem.new(key: :token,
|
|
77
|
+
env_name: 'NORDALP_APP_PUBLISH_TOKEN',
|
|
78
|
+
description: 'Access token for CMS',
|
|
79
|
+
optional: false,
|
|
80
|
+
type: String),
|
|
81
|
+
FastlaneCore::ConfigItem.new(key: :url,
|
|
82
|
+
env_name: 'NORDALP_APP_PUBLISH_URL',
|
|
83
|
+
description: 'URL for CMS flow',
|
|
84
|
+
optional: true,
|
|
85
|
+
default_value: 'https://cms.nordalp.de/flows/trigger/d6c99c78-63cf-4701-a297-aeee079ad8da',
|
|
86
|
+
type: String)
|
|
87
|
+
]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.is_supported?(platform)
|
|
91
|
+
[:android].include?(platform)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -1,70 +1,60 @@
|
|
|
1
|
-
require 'fastlane_core/ui/ui'
|
|
2
|
-
require 'httparty'
|
|
3
|
-
|
|
4
|
-
module Fastlane
|
|
5
|
-
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
|
6
|
-
|
|
7
|
-
module Helper
|
|
8
|
-
class NordalpAppPublishHelper
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
code: response.code,
|
|
62
|
-
body: response.parsed_response # Accesses the parsed JSON response body
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
rescue StandardError => e
|
|
66
|
-
return { error: "An error occurred: #{e.message}" }
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
module Fastlane
|
|
5
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
|
6
|
+
|
|
7
|
+
module Helper
|
|
8
|
+
class NordalpAppPublishHelper
|
|
9
|
+
def self.read_first_changelog_entry(filename)
|
|
10
|
+
return { error: "File not found: #{filename}" } unless File.exist?(filename)
|
|
11
|
+
|
|
12
|
+
# Read the entire file content
|
|
13
|
+
content = File.read(filename)
|
|
14
|
+
|
|
15
|
+
# Regular expression to match the first H2 version entry
|
|
16
|
+
version_regex = /^##\s+(\[([^\]]+)\]\(([^)]+)\)|[^(\r?\n]+)\s*\(([^)]+)\)\s*\r?\n(.*?)(?=\r?\n## |\z)/im
|
|
17
|
+
match = content.match(version_regex)
|
|
18
|
+
|
|
19
|
+
unless match
|
|
20
|
+
return { error: 'No version entries found matching the expected format (## [version](link) (date))' }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The version name is captured in Group 2 if it's a link, or Group 1 if it's plain text.
|
|
24
|
+
version_name = match[2] || match[1]&.strip
|
|
25
|
+
date = match[4]
|
|
26
|
+
text = match[5].strip
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
version: version_name,
|
|
30
|
+
date: date,
|
|
31
|
+
text: text
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.post_app(url_string, token_string, data_hash)
|
|
36
|
+
response = HTTParty.post(
|
|
37
|
+
url_string,
|
|
38
|
+
{
|
|
39
|
+
# HTTParty automatically converts the body (a Hash) to JSON
|
|
40
|
+
# and sets the Content-Type header to application/json
|
|
41
|
+
body: data_hash.to_json,
|
|
42
|
+
headers: {
|
|
43
|
+
'Authorization' => "Bearer #{token_string}",
|
|
44
|
+
'Content-Type' => 'application/json',
|
|
45
|
+
'Accept' => 'application/json'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# HTTParty can optionally parse the response body if it's JSON
|
|
51
|
+
{
|
|
52
|
+
code: response.code,
|
|
53
|
+
body: response.parsed_response # Accesses the parsed JSON response body
|
|
54
|
+
}
|
|
55
|
+
rescue StandardError => e
|
|
56
|
+
{ error: "An error occurred: #{e.message}" }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module Fastlane
|
|
2
|
-
module NordalpAppPublish
|
|
3
|
-
VERSION =
|
|
4
|
-
end
|
|
5
|
-
end
|
|
1
|
+
module Fastlane
|
|
2
|
+
module NordalpAppPublish
|
|
3
|
+
VERSION = '0.2.1'
|
|
4
|
+
end
|
|
5
|
+
end
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
require 'fastlane/plugin/nordalp_app_publish/version'
|
|
2
|
-
|
|
3
|
-
module Fastlane
|
|
4
|
-
module NordalpAppPublish
|
|
5
|
-
# Return all .rb files inside the "actions" and "helper" directory
|
|
6
|
-
def self.all_classes
|
|
7
|
-
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# By default we want to import all available actions and helpers
|
|
13
|
-
# A plugin can contain any number of actions and plugins
|
|
14
|
-
Fastlane::NordalpAppPublish.all_classes.each do |current|
|
|
15
|
-
require current
|
|
16
|
-
end
|
|
1
|
+
require 'fastlane/plugin/nordalp_app_publish/version'
|
|
2
|
+
|
|
3
|
+
module Fastlane
|
|
4
|
+
module NordalpAppPublish
|
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
|
6
|
+
def self.all_classes
|
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# By default we want to import all available actions and helpers
|
|
13
|
+
# A plugin can contain any number of actions and plugins
|
|
14
|
+
Fastlane::NordalpAppPublish.all_classes.each do |current|
|
|
15
|
+
require current
|
|
16
|
+
end
|