|
| 1 | +[remote] |
| 2 | +# Strictly don't connect to the internet to generate the changelog. |
| 3 | +offline = false |
| 4 | + |
| 5 | +[remote.github] |
| 6 | +owner = "seedcase-project" |
| 7 | +repo = "template-python-package" |
| 8 | + |
| 9 | +[changelog] |
| 10 | +# A Tera template to be rendered for each release in the changelog. |
| 11 | +header = """ |
| 12 | +# Changelog |
| 13 | +
|
| 14 | +Since we follow |
| 15 | +[Conventional Commits](https://decisions.seedcase-project.org/why-conventional-commits/) |
| 16 | +when writing commit messages, we're able to automatically create formal |
| 17 | +"releases" of the template based on the commit messages. Releases in the |
| 18 | +context of template are when changes occur to the `template/` files or |
| 19 | +to the `copier.yaml` files. The releases are also published to Zenodo |
| 20 | +for easier discovery, archival, and citation purposes. We use |
| 21 | +[Cocogitto](https://decisions.seedcase-project.org/why-semantic-release-with-cocogitto/) |
| 22 | +to be able to automatically create these releases, which uses |
| 23 | +[SemVar](https://semverdoc.org) as the version numbering scheme, |
| 24 | +and [Git Cliff](https://decisions.seedcase-project.org/why-changelog-with-git-cliff/) |
| 25 | +to generate the changelog based on the commit messages. |
| 26 | +
|
| 27 | +Because releases are created based on commit messages, a new release is |
| 28 | +created quite often---sometimes several times in a day. This also means |
| 29 | +that any individual release will not have many changes within it. Below |
| 30 | +is a list of the releases we've made so far, along with what was changed |
| 31 | +within each release. |
| 32 | +
|
| 33 | +Commits from bots, like `dependabot` or `pre-commit-ci`, are not included in |
| 34 | +the changelog. |
| 35 | +""" |
| 36 | + |
| 37 | +body = """ |
| 38 | +{%- macro remote_url() -%} |
| 39 | + https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} |
| 40 | +{%- endmacro -%} |
| 41 | +
|
| 42 | +{% macro print_commit(commit) -%} |
| 43 | + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ |
| 44 | + {% if commit.breaking %}**breaking** {% endif %}\ |
| 45 | + {{ commit.message | upper_first }} \ |
| 46 | + {% if commit.remote.username %} by \ |
| 47 | + {% if commit.remote.username is containing("[bot]") %} |
| 48 | + `@{{ commit.remote.username }}`\ |
| 49 | + {% else %}\ |
| 50 | + [`@{{ commit.remote.username }}`](https://github.com/{{ commit.remote.username }})\ |
| 51 | + {% endif %}\ |
| 52 | + {% endif %} \ |
| 53 | + ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\ |
| 54 | +{% endmacro -%} |
| 55 | +
|
| 56 | +{% if version %}\ |
| 57 | + {% if previous.version %}\ |
| 58 | + ## [{{ version | trim_start_matches(pat="v") }}]\ |
| 59 | + ({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} |
| 60 | + {% else %}\ |
| 61 | + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} |
| 62 | + {% endif %}\ |
| 63 | +{% else %}\ |
| 64 | + ## [unreleased] |
| 65 | +{% endif %}\ |
| 66 | +
|
| 67 | +{% for group, commits in commits | group_by(attribute="group") %} |
| 68 | + ### {{ group | striptags | trim | upper_first }} |
| 69 | + {% for commit in commits |
| 70 | + | filter(attribute="scope") |
| 71 | + | sort(attribute="scope") %} |
| 72 | + {{ self::print_commit(commit=commit) }} |
| 73 | + {%- endfor %} |
| 74 | + {% for commit in commits %} |
| 75 | + {%- if not commit.scope -%} |
| 76 | + {{ self::print_commit(commit=commit) }} |
| 77 | + {% endif -%} |
| 78 | + {% endfor -%} |
| 79 | +{% endfor -%} |
| 80 | +
|
| 81 | +{%- if github -%} |
| 82 | +{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} |
| 83 | + ### ❤️ New contributors |
| 84 | +{% endif %}\ |
| 85 | +{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} |
| 86 | + {% if contributor.username is containing("[bot]") %} |
| 87 | + - `@{{ contributor.username }}` started making automated contributions\ |
| 88 | + {% else %}\ |
| 89 | + - [`@{{ contributor.username }}`](https://github.com/{{ contributor.username }}) made their first contribution |
| 90 | + {%- if contributor.pr_number %} in \ |
| 91 | + [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }})\ |
| 92 | + {%- endif %} |
| 93 | + {%- endif %}\ |
| 94 | +{%- endfor -%} |
| 95 | +{%- endif %} |
| 96 | +
|
| 97 | +""" |
| 98 | + |
| 99 | +# Remove leading and trailing whitespaces from the changelog's body. |
| 100 | +trim = true |
| 101 | +output = "CHANGELOG.md" |
| 102 | + |
| 103 | +[git] |
| 104 | +commit_preprocessors = [ |
| 105 | + # Replace pull request numbers with links to GitHub. |
| 106 | + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "[#${2}](https://github.com/seedcase-project/template-python-package/pull/${2})" }, |
| 107 | + # Check spelling of the commit message using https://github.com/crate-ci/typos. |
| 108 | + # If the spelling is incorrect, it will be fixed automatically. |
| 109 | + { pattern = '.*', replace_command = 'uvx typos --write-changes -' }, |
| 110 | + # Remove gitmoji, both actual UTF emoji and :emoji: |
| 111 | + { pattern = ' *(:\w+:|[\p{Emoji_Presentation}\p{Extended_Pictographic}](?:\u{FE0F})?\u{200D}?) *', replace = "" }, |
| 112 | +] |
| 113 | + |
| 114 | +commit_parsers = [ |
| 115 | + # Don't include commits from bots. |
| 116 | + { field = "author.name", pattern = ".*(dependabot|github-actions|pre-commit-ci).*", skip = true }, |
| 117 | + # Don't include the version update commits. |
| 118 | + { message = ".*update version", skip = true }, |
| 119 | + { message = "^feat", group = "<!-- 0 -->✨ Features" }, |
| 120 | + { message = "^fix", group = "<!-- 1 -->🐛 Fixes" }, |
| 121 | + { message = "^refactor", group = "<!-- 2 -->♻️ Refactor" }, |
| 122 | + { message = "^docs", group = "<!-- 3 -->📝 Documentation" }, |
| 123 | + { message = "^perf", group = "<!-- 4 -->⚡ Performance" }, |
| 124 | + { message = "^style", group = "<!-- 5 -->💄 Styling" }, |
| 125 | + { message = "^test", group = "<!-- 6 -->🧪 Tests" }, |
| 126 | + { message = "^ci", group = "<!-- 7 -->👷 CI/CD" }, |
| 127 | + { message = "^chore|^build", group = "<!-- 8 -->👩💻 Miscellaneous" }, |
| 128 | + { message = "^revert", group = "<!-- 9 -->⏪ Revert" }, |
| 129 | + { message = ".*", skip = true }, |
| 130 | +] |
0 commit comments