Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towncrier fixes #97

Merged
merged 5 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.d/96.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix project urls in Towncrier configuration.
8 changes: 2 additions & 6 deletions changelog.d/_template.md.jinja
Original file line number Diff line number Diff line change
@@ -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() %}
Expand All @@ -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) -}}
Expand Down
7 changes: 1 addition & 6 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 1 addition & 20 deletions fastlane/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# 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
Expand Down Expand Up @@ -43,21 +41,4 @@ def self.update_topmost_section(version:, additional_entries:)
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