mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Replace Towncrier with GitHub releases + labels. (#2966)
* Set up GitHub generated release notes. * Remove Towncrier from the release script. * Add changelog failures for Labels with Danger and stop requesting a changelog file. * Update changelog documentation.
This commit is contained in:
+16
-29
@@ -1,6 +1,5 @@
|
||||
require 'yaml'
|
||||
require 'semantic'
|
||||
require_relative 'changelog'
|
||||
|
||||
before_all do
|
||||
xcversion(version: "15.2")
|
||||
@@ -208,35 +207,30 @@ lane :release_to_github do
|
||||
api_token = ENV["GITHUB_TOKEN"]
|
||||
UI.user_error!("Invalid GitHub API token.") unless !api_token.to_s.empty?
|
||||
|
||||
# Get the Diawi link from Diawi action shared value
|
||||
diawi_link = lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI]
|
||||
|
||||
release_version = get_version_number(target: "ElementX")
|
||||
|
||||
changes = export_version_changes(version: release_version)
|
||||
|
||||
description = ""
|
||||
if diawi_link.nil?
|
||||
description = "#{changes}"
|
||||
else
|
||||
# Generate the Diawi QR code file link
|
||||
diawi_app_id = URI(diawi_link).path.split('/').last
|
||||
diawi_qr_code_link = "https://www.diawi.com/qrcode/link/#{diawi_app_id}"
|
||||
|
||||
"[iOS AdHoc Release - Diawi Link](#{diawi_link})
|
||||

|
||||
#{changes}"
|
||||
end
|
||||
|
||||
github_release = set_github_release(
|
||||
repository_name: "element-hq/element-x-ios",
|
||||
api_token: api_token,
|
||||
name: release_version,
|
||||
tag_name: release_version,
|
||||
is_generate_release_notes: false,
|
||||
description: description
|
||||
is_generate_release_notes: true,
|
||||
)
|
||||
|
||||
|
||||
release_date = Date.today.strftime("%Y-%m-%d")
|
||||
generated_notes = github_release["body"].gsub(/<!-- .*? -->/, '').gsub("### ", "\n").gsub("## ", "### ")
|
||||
UI.user_error!("The generated release notes are missing!") unless !generated_notes.to_s.empty?
|
||||
|
||||
# Prepend the new release notes to the CHANGES.md file
|
||||
changes_file = "../CHANGES.md"
|
||||
File.open(changes_file, "r+") do |file|
|
||||
content = file.read
|
||||
file.rewind
|
||||
file.write("## Changes in #{release_version} (#{release_date})#{generated_notes}\n\n#{content}")
|
||||
end
|
||||
|
||||
# The changelog will be committed when prepare_next_release is called.
|
||||
sh("git add #{changes_file}")
|
||||
end
|
||||
|
||||
lane :prepare_next_release do
|
||||
@@ -366,13 +360,6 @@ private_lane :bump_build_number do
|
||||
increment_build_number(build_number: build_number)
|
||||
end
|
||||
|
||||
private_lane :export_version_changes do |options|
|
||||
Dir.chdir("..") do
|
||||
Changelog.update_topmost_section(version: options[:version], additional_entries: {})
|
||||
Changelog.extract_first_section
|
||||
end
|
||||
end
|
||||
|
||||
private_lane :update_app_icon do |options|
|
||||
caption_text = options[:caption_text]
|
||||
UI.user_error!("Invalid caption text.") unless !caption_text.to_s.empty?
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#
|
||||
# Copyright 2020 New Vector Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "tempfile"
|
||||
require "fileutils"
|
||||
require "date"
|
||||
|
||||
# Helper methods to handle updates of the Changelog file
|
||||
#
|
||||
module Changelog
|
||||
CHANGES_SEPARATOR_REGEX = /^\#\#\ Changes/.freeze
|
||||
FILE = "CHANGES.md"
|
||||
|
||||
# Update the topmost section of the changelog to put version+date in title + add entry for dependency updates
|
||||
#
|
||||
# @param [String] version The version that we are releasing to use in the new title of the first section
|
||||
# @param [Hash<String, Array<String>>] additional_entries
|
||||
# List of lines/entries to add under the each subsection of the first section
|
||||
# The keys of the hash are the name of the subsections, without trailing`:`, e.g. "Improvements".
|
||||
# The values are the list of lines to add to that subsection
|
||||
# (the ` * ` bullet point will be added automatically for each line)
|
||||
#
|
||||
def self.update_topmost_section(version:, additional_entries:)
|
||||
|
||||
# Create temporary towncrier changelog entries for additional entries
|
||||
# Use a low index to make them appear first
|
||||
# Those additional entries are basically dependency updates
|
||||
entry_count = 0
|
||||
additional_entries.each do |subsection, entries|
|
||||
entries.each do |entry|
|
||||
file = "changelog.d/x-nolink-#{entry_count}.#{subsection}"
|
||||
File.write(file, "#{entry}")
|
||||
Git.add!(files: file)
|
||||
Git.commit!(message: "changelog.d: #{entry}", add_all: true)
|
||||
entry_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
# Let towncrier update the change
|
||||
system("towncrier", "build", "--version", "#{version}", "--yes")
|
||||
end
|
||||
|
||||
# Returns the first section of the Changelog, corresponding to the changes in the latest version
|
||||
#
|
||||
def self.extract_first_section
|
||||
lines = []
|
||||
File.open(FILE, "r") do |file|
|
||||
section_index = 0
|
||||
file.each_line do |line|
|
||||
is_separator_line = (line.chomp =~ CHANGES_SEPARATOR_REGEX)
|
||||
section_index += 1 if is_separator_line
|
||||
break if section_index >= 2
|
||||
|
||||
lines.append(line) if section_index == 1
|
||||
end
|
||||
end
|
||||
lines[0..-2].join # Remove last line (title of section 2)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user