Towncrier fixes (#97)

This commit is contained in:
ismailgulek 2022-06-27 20:41:00 +03:00 committed by GitHub
parent 36c34503fc
commit cc14f1f567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 32 deletions

2
.gitignore vendored
View File

@ -29,6 +29,8 @@ fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
towncrier.toml.tmp
version_changes.md
build
Tools/Scripts/element-android

1
changelog.d/96.misc Normal file
View File

@ -0,0 +1 @@
Fix project urls in Towncrier configuration.

View File

@ -1,7 +1,6 @@
{# iOS Repositories #}
{%- set gh_sdk = "https://github.com/matrix-org/matrix-ios-sdk" -%}
{%- set gh_kit = "https://github.com/matrix-org/matrix-ios-kit" -%}
{%- set gh_element = "https://github.com/vector-im/element-ios" -%}
{%- set gh_sdk = "https://github.com/matrix-org/matrix-rust-sdk" -%}
{%- set gh_element = "https://github.com/vector-im/element-x-ios" -%}
## {{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
{% for section, _ in sections.items() %}
@ -18,9 +17,6 @@
{%- if value.startswith("sdk-") %}
{%- set gh_issue = value.replace("sdk-", "") -%}
{{- links.append( "[#%s](%s/issues/%s)" | format(gh_issue, gh_sdk, gh_issue) ) | default("", True) -}}
{%- elif value.startswith("kit-") %}
{%- set gh_issue = value.replace("kit-", "") -%}
{{- links.append( "[#%s](%s/issues/%s)" | format(gh_issue, gh_kit, gh_issue) ) | default("", True) -}}
{%- elif value.startswith("#") %}
{%- set gh_issue = value.replace("#", "") -%}
{{- links.append( "[#%s](%s/issues/%s)" | format(gh_issue, gh_element, gh_issue) ) | default("", True) -}}

View File

@ -101,13 +101,8 @@ end
private_lane :export_version_changes do |options|
Dir.chdir("..") do
sh("sed -i '.tmp' 's/CHANGES.md/version_changes.md/g' towncrier.toml")
Changelog.update_topmost_section(version: options[:version], additional_entries: {})
changelog = Changelog.extract_first_section
# Pushing them directly into the $GITHUB_ENV results in errors
# https://trstringer.com/github-actions-multiline-strings/
# String substitution and here documents failed too
sh("echo '#{changelog}' >> version_changes.md")
end
end

View File

@ -11,9 +11,7 @@ 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
@ -43,21 +41,4 @@ module Changelog
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