fastlane-plugin-wpmreleasetoolkit 15.1.0 → 15.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f47aea4602fae982122ed3c370c7cbc3330ebe242781ff4abffb4498016f384c
4
- data.tar.gz: e4526ac1fcbb27ece5e15fc8a11ea60d453c2bbd1ab34a8f1c88040f590e31f8
3
+ metadata.gz: 821f365e32e08a05230fbc5ae16760f128ff39eca6b8b8c99459751bc6299120
4
+ data.tar.gz: f67252ac27be73b6d8d0f54c8679d11d5c71a1f52042caa8ab97362451ff8abe
5
5
  SHA512:
6
- metadata.gz: 297833bfc56d46af40b9771485fe42cc5b2e54c910ddf92ea2701e50088bb4015176ed988544e593128569e3f410093cb0421976b32167e4c9755c423fc44c0d
7
- data.tar.gz: 39d1cd8e4a1cc8fde878d10538cc5a49cb6b2fa58ad2f2a80fb3d1c2ea4fa830c8e4803f7052fdbd243619b4dcc60a150f4b522504f218327dd4145f3b15dee5
6
+ metadata.gz: 214447b137397d1b1ed813320370eb6a2e06c15d6a7a9d8d28d063d55b9c7dd39c751d6700d537d253e222808ac132c179eec87ee893db87c430323dabee8d9a
7
+ data.tar.gz: 9eb8cef1bb2a5cd5fc96df1aa7aa5500ebc2f9eb49beb6dd345da1011741b1d823c2fc76fdc8faf14c66f94673c6b77bd526fcf2c8a470da590731756e70d6af
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/action'
4
+ require_relative 'get_prs_between_tags'
5
+ require_relative '../../helper/release_notes_helper'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class GenerateReleaseNotesFileAction < Action
10
+ def self.run(params)
11
+ UI.user_error!('An explicit previous_tag is required to generate release notes') if params[:previous_tag].to_s.empty?
12
+ version = params[:version]
13
+ UI.user_error!('Expected a numeric release version') unless version.match?(/\A\d+(?:\.\d+){0,2}\z/)
14
+
15
+ path = params[:release_notes_file_path]
16
+ contents = File.read(path)
17
+ format = params[:format]
18
+ options = params.values.except(*custom_options.map(&:key))
19
+ markdown = other_action.get_prs_between_tags(**options, fail_on_error: true)
20
+ section = Helper::ReleaseNotesHelper.format_section(version: version, markdown: markdown, format: format)
21
+ updated = Helper::ReleaseNotesHelper.update_section(contents: contents, version: version, section: section, format: format)
22
+
23
+ if params[:dry_run]
24
+ UI.message(section)
25
+ else
26
+ File.write(path, updated)
27
+ end
28
+ section
29
+ end
30
+
31
+ def self.description
32
+ 'Write generated GitHub notes to a release notes or Markdown changelog version section'
33
+ end
34
+
35
+ def self.details
36
+ <<~DETAILS
37
+ Inserts or replaces one version section using get_prs_between_tags, preserving other versions and header comments.
38
+ Defaults to the underlined version headings used in RELEASE-NOTES.txt.
39
+ Use format: :changelog and release_notes_file_path: 'CHANGELOG.md' for numeric ## version headings.
40
+ Changelog output nests generated headings beneath the version and preserves Trunk/Unreleased sections.
41
+ The existing file must contain at least one version section in the selected format.
42
+ Keeps authors, contributors, and links. Does not promote Unreleased entries or edit other versions.
43
+ Use configuration_file_path to exclude or group PRs by GitHub labels; no title markers are needed.
44
+ For a separate report, such as release testing, call get_prs_between_tags with its own configuration_file_path.
45
+ Requires an explicit previous_tag and a published target_commitish if tag_name does not exist.
46
+ Use dry_run to preview without writing. Does not commit changes.
47
+ DETAILS
48
+ end
49
+
50
+ def self.available_options
51
+ GetPrsBetweenTagsAction.available_options.reject { |option| option.key == :fail_on_error } + custom_options
52
+ end
53
+
54
+ def self.custom_options
55
+ [
56
+ FastlaneCore::ConfigItem.new(key: :version, description: 'Numeric version heading in the output file', type: String),
57
+ FastlaneCore::ConfigItem.new(key: :release_notes_file_path, description: 'Existing release notes file', type: String, default_value: 'RELEASE-NOTES.txt'),
58
+ FastlaneCore::ConfigItem.new(key: :format,
59
+ description: 'Version section format: :release_notes or :changelog',
60
+ type: Symbol,
61
+ default_value: :release_notes,
62
+ verify_block: proc do |value|
63
+ UI.user_error!('format must be :release_notes or :changelog') unless %i[release_notes changelog].include?(value)
64
+ end),
65
+ FastlaneCore::ConfigItem.new(key: :dry_run, description: 'Preview the section without writing the file', type: Boolean, default_value: false),
66
+ ]
67
+ end
68
+
69
+ private_class_method :custom_options
70
+
71
+ def self.return_value
72
+ 'The generated version section'
73
+ end
74
+
75
+ def self.authors
76
+ ['Automattic']
77
+ end
78
+
79
+ def self.is_supported?(platform)
80
+ true
81
+ end
82
+ end
83
+ end
84
+ end
@@ -5,6 +5,7 @@ require 'net/http'
5
5
  require 'uri'
6
6
  require 'json'
7
7
  require_relative '../../helper/apps_cdn_helper'
8
+ require_relative '../../helper/macos/sparkle_helper'
8
9
 
9
10
  module Fastlane
10
11
  module Actions
@@ -71,6 +72,7 @@ module Fastlane
71
72
  post_status: params[:post_status], # Optional: may be nil
72
73
  release_notes: params[:release_notes], # Optional: may be nil
73
74
  sha: params[:sha], # Optional: may be nil
75
+ ed_signature: params[:ed_signature], # Optional: may be nil
74
76
  error_on_duplicate: params[:error_on_duplicate] # defaults to false
75
77
  }.compact
76
78
  request_body, content_type = build_multipart_request(parameters: parameters, file_path: file_path)
@@ -311,6 +313,15 @@ module Fastlane
311
313
  optional: true,
312
314
  type: String
313
315
  ),
316
+ FastlaneCore::ConfigItem.new(
317
+ key: :ed_signature,
318
+ description: 'The base64 EdDSA signature of the uploaded archive, as returned by macos_sign_update',
319
+ optional: true,
320
+ type: String,
321
+ verify_block: proc do |value|
322
+ Helper::SparkleHelper.validate_ed_signature!(value)
323
+ end
324
+ ),
314
325
  FastlaneCore::ConfigItem.new(
315
326
  key: :error_on_duplicate,
316
327
  description: 'If true, the action will error if a build matching the same metadata already exists. If false, any potential existing build matching the same metadata will be updated to replace the build with the new file',
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/action'
4
+ require_relative '../../helper/macos/sparkle_helper'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class MacosSignUpdateAction < Action
9
+ def self.run(params)
10
+ Helper::SparkleHelper.sign_update(
11
+ archive_path: params[:archive_path],
12
+ signing_tool: params[:signing_tool],
13
+ private_key: params[:private_key],
14
+ public_key: params[:public_key]
15
+ )
16
+ end
17
+
18
+ def self.available_options
19
+ [
20
+ FastlaneCore::ConfigItem.new(
21
+ key: :archive_path,
22
+ description: 'The final Sparkle update archive (the zip or dmg users download) to sign, after code signing, notarizing and stapling',
23
+ type: String,
24
+ verify_block: proc do |value|
25
+ UI.user_error!("Archive not found at '#{value}'") unless File.file?(value)
26
+ end
27
+ ),
28
+ FastlaneCore::ConfigItem.new(
29
+ key: :signing_tool,
30
+ description: 'The sign_update executable from the app\'s resolved Sparkle release',
31
+ type: String,
32
+ verify_block: proc do |value|
33
+ UI.user_error!("Sparkle signing tool is not executable at '#{value}'") unless File.file?(value) && File.executable?(value)
34
+ end
35
+ ),
36
+ FastlaneCore::ConfigItem.new(
37
+ key: :public_key,
38
+ description: 'The SUPublicEDKey value embedded in the app being released',
39
+ type: String,
40
+ verify_block: proc do |value|
41
+ Helper::SparkleHelper.validate_public_key!(value)
42
+ end
43
+ ),
44
+ FastlaneCore::ConfigItem.new(
45
+ key: :private_key,
46
+ env_name: 'SPARKLE_PRIVATE_KEY',
47
+ description: 'The exported Sparkle private key (required)',
48
+ type: String,
49
+ sensitive: true,
50
+ # Validate inside the helper: ConfigItem logs invalid values even when marked sensitive.
51
+ # Optional here also avoids prompting for a missing key in unattended release jobs.
52
+ optional: true
53
+ ),
54
+ ]
55
+ end
56
+
57
+ def self.description
58
+ 'Sign the final Sparkle update archive with EdDSA'
59
+ end
60
+
61
+ def self.details
62
+ 'Pass the sign_update executable from the same Sparkle release used by the app. The private key is sent through standard input and the signature is verified against the app\'s public key. Upload the archive without modifying it after signing.'
63
+ end
64
+
65
+ def self.return_value
66
+ 'The canonical base64 EdDSA signature'
67
+ end
68
+
69
+ def self.authors
70
+ ['Automattic']
71
+ end
72
+
73
+ def self.is_supported?(platform)
74
+ platform == :mac
75
+ end
76
+
77
+ def self.example_code
78
+ [
79
+ 'signature = macos_sign_update(
80
+ archive_path: "build/App.zip",
81
+ signing_tool: "build/SourcePackages/artifacts/sparkle/Sparkle/bin/sign_update",
82
+ public_key: get_info_plist_value(path: "App/Info.plist", key: "SUPublicEDKey")
83
+ )
84
+ # Pass signature as ed_signature to upload_build_to_apps_cdn.',
85
+ ]
86
+ end
87
+ end
88
+ end
89
+ end
@@ -311,7 +311,7 @@ module Fastlane
311
311
  tag_name: tag_name,
312
312
  target_commitish: target_commitish, # Only used if no git tag named `tag_name` exists yet
313
313
  previous_tag_name: previous_tag,
314
- config_file_path: config_file_path
314
+ configuration_file_path: config_file_path
315
315
  )
316
316
  res.body
317
317
  end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'open3'
5
+ require 'openssl'
6
+
7
+ module Fastlane
8
+ module Helper
9
+ module SparkleHelper
10
+ # Signs the final archive using the sign_update executable from the app's resolved Sparkle release.
11
+ # Capture output directly: sign_update can echo invalid keys in its diagnostics, and Action.sh logs output.
12
+ #
13
+ # @return [String] the canonical base64 EdDSA signature
14
+ def self.sign_update(archive_path:, signing_tool:, private_key:, public_key:)
15
+ key = private_key.to_s.strip
16
+ UI.user_error!('A Sparkle private key is required; set SPARKLE_PRIVATE_KEY or private_key') if key.empty?
17
+ unless canonical_base64?(key, lengths: [32, 96])
18
+ UI.user_error!('Sparkle private key must be base64 for a 32-byte seed or a 96-byte legacy key')
19
+ end
20
+
21
+ archive_path = File.expand_path(archive_path)
22
+ signing_tool = File.expand_path(signing_tool)
23
+ stdout, _stderr, status = Open3.capture3(
24
+ { 'SPARKLE_PRIVATE_KEY' => nil }, signing_tool, '-p', '--ed-key-file', '-', archive_path,
25
+ stdin_data: "#{key}\n"
26
+ )
27
+ UI.user_error!('Sparkle sign_update failed; check the signing tool and private key') unless status.success?
28
+
29
+ signature = stdout.strip
30
+ validate_ed_signature!(signature)
31
+ verify_signature!(signature: signature, public_key: public_key, archive_path: archive_path)
32
+ signature
33
+ rescue SystemCallError, IOError
34
+ # Do not retain a potentially sensitive exception as the cause in verbose error reports.
35
+ raise FastlaneCore::Interface::FastlaneError.new, 'Unable to run Sparkle sign_update or read the archive', cause: nil
36
+ end
37
+
38
+ # Verify against the public key embedded in the app, so a wrong CI key cannot publish an unusable update.
39
+ def self.verify_signature!(signature:, public_key:, archive_path:)
40
+ validate_public_key!(public_key)
41
+ # SubjectPublicKeyInfo for Ed25519: AlgorithmIdentifier (OID 1.3.101.112) and a 32-byte public key.
42
+ key = OpenSSL::PKey.read(['302a300506032b6570032100'].pack('H*') + Base64.strict_decode64(public_key))
43
+ return if key.verify(nil, Base64.strict_decode64(signature), File.binread(archive_path))
44
+
45
+ UI.user_error!("Sparkle signature does not verify against the app's public key and archive")
46
+ rescue OpenSSL::PKey::PKeyError
47
+ UI.user_error!("Unable to verify the Sparkle signature with the app's public key")
48
+ end
49
+
50
+ def self.validate_public_key!(value)
51
+ return if canonical_base64?(value, lengths: [32])
52
+
53
+ UI.user_error!('Sparkle public key must be canonical base64 for exactly 32 bytes')
54
+ end
55
+
56
+ # Validate a signature without accepting whitespace, URL-safe encoding, or noncanonical padding.
57
+ def self.validate_ed_signature!(value)
58
+ return if canonical_base64?(value, lengths: [64])
59
+
60
+ UI.user_error!('EdDSA signature must be canonical base64 for exactly 64 bytes')
61
+ end
62
+
63
+ def self.canonical_base64?(value, lengths:)
64
+ return false unless value.is_a?(String)
65
+
66
+ decoded = Base64.strict_decode64(value)
67
+ lengths.include?(decoded.bytesize) && Base64.strict_encode64(decoded) == value
68
+ rescue ArgumentError
69
+ false
70
+ end
71
+ end
72
+ end
73
+ end
@@ -3,6 +3,101 @@
3
3
  module Fastlane
4
4
  module Helper
5
5
  module ReleaseNotesHelper
6
+ VERSION_HEADING = /^\d+(?:\.\d+){0,2}\r?\n[-=]+(?:\r?\n|\z)/
7
+
8
+ # Render a version section, nesting generated Markdown headings in changelog output.
9
+ def self.format_section(version:, markdown:, format: :release_notes)
10
+ return "#{version}\n-----\n#{markdown.rstrip}\n\n" unless format == :changelog
11
+
12
+ headings = markdown_headings(markdown)
13
+ shift = [3 - (headings.map(&:last).min || 3), 0].max
14
+ markdown = markdown.dup
15
+ headings.reverse_each do |offset, level|
16
+ markdown.insert(markdown.index('#', offset), '#' * [shift, 6 - level].min)
17
+ end
18
+ "## #{version}\n\n#{markdown.rstrip}\n\n"
19
+ end
20
+
21
+ # Insert or replace one version, preserving other sections and line endings.
22
+ # @param [String] contents Existing release notes or changelog contents.
23
+ # @param [String] version The section to replace or insert.
24
+ # @param [String] section The generated version section.
25
+ # @param [Symbol] format Version heading format: :release_notes or :changelog.
26
+ # @return [String] Updated file contents.
27
+ def self.update_section(contents:, version:, section:, format: :release_notes)
28
+ if format == :changelog
29
+ offsets = markdown_headings(contents).select { |_, level| level <= 2 }.map(&:first)
30
+ sections = [0, *offsets, contents.length].uniq.each_cons(2).map { |start, finish| contents[start...finish] }
31
+ versions = sections.map { |part| part.lines.first[/\A {0,3}##[ \t]+(\d+(?:\.\d+){0,2})[ \t]*\r?\n?\z/, 1] }
32
+ else
33
+ sections = contents.split(/(?=#{VERSION_HEADING})/)
34
+ versions = sections.map { |part| part.lines.first.chomp if part.match?(VERSION_HEADING) }
35
+ end
36
+ first_version = versions.index { |value| value }
37
+ UI.user_error!('No version headings found in the release notes file') unless first_version
38
+ UI.user_error!("Duplicate release notes sections for #{version}") if versions.count(version) > 1
39
+
40
+ newline = contents.include?("\r\n") ? "\r\n" : "\n"
41
+ section = section.gsub(/\r?\n/, newline)
42
+ index = versions.index(version)
43
+ if index
44
+ sections[index] = section
45
+ else
46
+ sections.insert(first_version, section)
47
+ end
48
+ sections.join
49
+ end
50
+
51
+ # Return line offsets and levels of ATX headings, ignoring code fences and HTML comments.
52
+ def self.markdown_headings(contents)
53
+ headings = []
54
+ fence = nil
55
+ html_comment = false
56
+ offset = 0
57
+ contents.each_line do |line|
58
+ if fence
59
+ fence = nil if line.match?(/\A {0,3}#{Regexp.escape(fence[0])}{#{fence.length},}[ \t]*\r?\n?\z/)
60
+ elsif !html_comment && (match = line.match(/\A {0,3}(`{3,}(?!.*`)|~{3,})/))
61
+ fence = match[1]
62
+ else
63
+ if !html_comment && (match = line.match(/\A {0,3}(\#{1,6})(?:[ \t]+|\r?\n?\z)/))
64
+ headings << [offset, match[1].length]
65
+ end
66
+ html_comment = html_comment_open?(line, open: html_comment) unless !html_comment && line.match?(/\A(?: {4}| {0,3}\t)/)
67
+ end
68
+ offset += line.length
69
+ end
70
+ UI.user_error!('Unterminated code fence in Markdown release notes') if fence
71
+ UI.user_error!('Unterminated HTML comment in Markdown release notes') if html_comment
72
+ headings
73
+ end
74
+ private_class_method :markdown_headings
75
+
76
+ # Track comment delimiters in order, skipping matched inline code spans.
77
+ def self.html_comment_open?(line, open:)
78
+ cursor = 0
79
+ loop do
80
+ if open
81
+ closing = line.index('-->', cursor)
82
+ return true unless closing
83
+
84
+ cursor = closing + 3
85
+ open = false
86
+ else
87
+ marker = line.match(/<!--|`+/, cursor)
88
+ return false unless marker
89
+
90
+ cursor = marker.end(0)
91
+ if marker[0] == '<!--'
92
+ open = true
93
+ elsif (closing = line.match(/(?<!`)#{Regexp.escape(marker[0])}(?!`)/, cursor))
94
+ cursor = closing.end(0)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ private_class_method :html_comment_open?
100
+
6
101
  # Update the release notes file (typycally RELEASE-NOTES.txt) to add a new entry.
7
102
  #
8
103
  # @param [String] path The path to the release notes text file.
@@ -3,6 +3,6 @@
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
5
  NAME = 'fastlane-plugin-wpmreleasetoolkit'
6
- VERSION = '15.1.0'
6
+ VERSION = '15.3.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.1.0
4
+ version: 15.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
@@ -300,6 +300,7 @@ files:
300
300
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/find_or_create_pull_request_action.rb
301
301
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/find_previous_tag.rb
302
302
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/firebase_login.rb
303
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/generate_release_notes_file.rb
303
304
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb
304
305
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb
305
306
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb
@@ -333,6 +334,7 @@ files:
333
334
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_send_app_size_metrics.rb
334
335
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb
335
336
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb
337
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/macos/macos_sign_update.rb
336
338
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/macos/macos_verify_code_signing.rb
337
339
  - lib/fastlane/plugin/wpmreleasetoolkit/env_manager/env_manager.rb
338
340
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_emulator_helper.rb
@@ -357,6 +359,7 @@ files:
357
359
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb
358
360
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_strings_file_validation_helper.rb
359
361
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb
362
+ - lib/fastlane/plugin/wpmreleasetoolkit/helper/macos/sparkle_helper.rb
360
363
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/po_file_generator.rb
361
364
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb
362
365
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb