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

Replace Towncrier with GitHub releases + labels. #2966

Merged
merged 5 commits into from
Jun 25, 2024
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
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### Pull Request Checklist

- [ ] I read the [contributing guide](https://github.com/element-hq/element-ios/blob/develop/CONTRIBUTING.md)
- [ ] Pull request contains a [changelog file](https://github.com/matrix-org/matrix-ios-sdk/blob/develop/CONTRIBUTING.md#changelog) in ./changelog.d
- [ ] Pull request includes a [sign off](https://github.com/matrix-org/matrix-ios-sdk/blob/develop/CONTRIBUTING.md#sign-off)
- [ ] I read the [contributing guide](https://github.com/element-hq/element-ios/blob/develop/CONTRIBUTING.md).
- [ ] Pull request contains a [changelog label](https://github.com/element-hq/element-x-ios/blob/develop/CONTRIBUTING.md#changelog).
- [ ] Pull request includes a [sign off](https://github.com/matrix-org/matrix-ios-sdk/blob/develop/CONTRIBUTING.md#sign-off).

**UI changes have been tested with:**
- [ ] iPhone and iPad simulators in portrait and landscape orientations.
Expand Down
31 changes: 31 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
changelog:
categories:
- title: ✨ Features
labels:
- pr-feature
- title: 🙌 Improvements
labels:
- pr-change
- title: 🐛 Bugfixes
labels:
- pr-bugfix
- title: ⚠️ API Changes
labels:
- pr-api
- title: 🗣 Translations
labels:
- pr-i18n
- title: 🧱 Build
labels:
- pr-build
- title: 📄 Documentation
labels:
- pr-doc
- title: 🚧 In development 🚧
labels:
- pr-wip

- title: Others
labels:
- pr-misc
- "*"
50 changes: 1 addition & 49 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,55 +99,7 @@ New screen flows are currently using the MVVM-Coordinator pattern. Please refer

## Changelog

All changes, even minor ones, need a corresponding changelog / newsfragment
entry. These are managed by [Towncrier](https://github.com/twisted/towncrier).

To create a changelog entry, make a new file in the `changelog.d` directory
named in the format of `ElementXiOSIssueNumber.type`. The type can be one of the
following:

- `feature` for a new feature
- `change` for updates to an existing feature
- `bugfix` for bug fix
- `api` for an api break
- `i18n` for translations
- `build` for changes related to build, tools, CI/CD
- `doc` for updates to the documentation
- `wip` for anything that isn't ready to ship and will be enabled at a later date
- `misc` for other changes

This file will become part of our [changelog](CHANGES.md) at the next
release, so the content of the file should be a short description of your
change in the same style as the rest of the changelog. The file must only
contain one line. It can contain Markdown formatting. It should start with the
area of the change (screen, module, ...) and end with a full stop (.) or an
exclamation mark (!) for consistency.

Adding credits to the changelog is encouraged, we value your
contributions and would like to have you shouted out in the release notes!

For example, a fix for an issue #1234 would have its changelog entry in
`changelog.d/1234.bugfix`, and contain content like:

> Voice Messages: Fix a crash when sending a voice message. Contributed by
> Jane Matrix.

If there are multiple pull requests involved in a single bugfix/feature/etc,
then the content for each `changelog.d` file should be the same. Towncrier will
merge the matching files together into a single changelog entry when we come to
release.

There are exceptions on the `ElementXiOSIssueNumber.type` entry format. Even if
it is not encouraged, you can use:

- `pr-[PRNumber].type` for a PR with no related issue
- `x-nolink-[AnyNumber].type` for a PR with a change entry that will not have a link automatically appended. It must be used for internal project update only. `AnyNumber` should be a value that does not clash with existing files.

To preview the changelog for pending changelog entries, use:

```bash
$ towncrier build --draft --version 1.2.3
```
Our [changelog](CHANGES.md) is automatically generated by GitHub, based on the PR title that you use when opening the issue. The changelog can be categorised by applying on of the [`pr-` labels](https://github.com/element-hq/element-x-ios/labels?q=pr-) to your PR. The mapping of Label → Section can be found in the [release.yml](.github/release.yml) file. The contribution will be automatically credited to your GitHub username.

## Coding style

Expand Down
19 changes: 11 additions & 8 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ SwiftLint.lint(inline: true)

let danger = Danger()

// All of the new and modified files together.
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles

// Warn when there is a big PR
if (danger.github.pullRequest.additions ?? 0) > 1000 {
warn("This pull request seems relatively large. Please consider splitting it into multiple smaller ones.")
Expand All @@ -15,14 +18,6 @@ if danger.github.pullRequest.body?.isEmpty ?? true {
warn("Please provide a description for this PR.")
}

// Request a changelog for each app change
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
let changelogFiles = editedFiles.filter { $0.hasPrefix("changelog.d/") }

if editedFiles.count > 0, changelogFiles.isEmpty {
warn("Please add a changelog.")
}

// Check for a ticket number
if let ticketNumberRegex = try? NSRegularExpression(pattern: "#\\d+") {
let missingTicketNumber = !danger.git.commits.filter {
Expand Down Expand Up @@ -84,3 +79,11 @@ let hasPngs = !editedFiles.filter { $0.lowercased().contains(".xcassets") && $0.
if hasPngs {
warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.")
}

if danger.github.pullRequest.title.hasSuffix("…") {
fail("Please provide a complete title that can be used as a changelog entry.")
}

if danger.github.issue.labels.filter({ $0.name.hasPrefix("pr-") }).count != 1 {
fail("Please add a `pr-` label to categorise the changelog entry.")
}
54 changes: 0 additions & 54 deletions changelog.d/_template.md.jinja

This file was deleted.

4 changes: 0 additions & 4 deletions ci_scripts/ci_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ install_xcode_cloud_brew_dependencies () {
fi
}

install_xcode_cloud_python_dependencies () {
pip3 install towncrier # Install towncrier for generating changelogs
}

setup_github_actions_environment() {
unset HOMEBREW_NO_INSTALL_FROM_API
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
Expand Down
2 changes: 0 additions & 2 deletions ci_scripts/ci_post_xcodebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ bundle exec fastlane upload_dsyms_to_sentry dsym_path:"$CI_ARCHIVE_PATH/dSYMs"
generate_what_to_test_notes

if [ "$CI_WORKFLOW" = "Release" ]; then
install_xcode_cloud_python_dependencies

bundle exec fastlane release_to_github
bundle exec fastlane prepare_next_release
elif [ "$CI_WORKFLOW" = "Nightly" ]; then
Expand Down
45 changes: 16 additions & 29 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'yaml'
require 'semantic'
require_relative 'changelog'

before_all do
xcversion(version: "15.2")
Expand Down Expand Up @@ -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})
![QR code](#{diawi_qr_code_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
Expand Down Expand Up @@ -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?
Expand Down
75 changes: 0 additions & 75 deletions fastlane/changelog.rb

This file was deleted.

Loading
Loading