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

Add changelog for preview changes #4251

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Add changelog for preview changes #4251

merged 1 commit into from
Jun 11, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jun 11, 2024

I tweaked rooster to allow sections to be overridden from the CLI so we can generate a separate preview changelog

See zanieb/rooster#43 for the rooster changes needed

I tested ./scripts/release.sh as well.

@zanieb zanieb added the preview Experimental behavior label Jun 11, 2024
@zanieb zanieb force-pushed the zb/preview-changelog branch 3 times, most recently from e1e80e1 to 7b2642a Compare June 11, 2024 20:57
@zanieb zanieb requested a review from charliermarsh June 11, 2024 20:57

<!-- No changes -->

## 0.1.40
Copy link
Member Author

@zanieb zanieb Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first version when we started to use the preview label I think

@zanieb zanieb force-pushed the zb/preview-changelog branch from 7b2642a to 60da9db Compare June 11, 2024 20:58
@zanieb zanieb marked this pull request as ready for review June 11, 2024 22:44
@charliermarsh charliermarsh merged commit daee30a into main Jun 11, 2024
64 checks passed
@charliermarsh charliermarsh deleted the zb/preview-changelog branch June 11, 2024 23:16
@orhun
Copy link
Contributor

orhun commented Jun 15, 2024

Hey, Arch maintainer of uv package here 👋🏼

I saw this PR while looking at the changes. I also work on a changelog generation tool called git-cliff and I was curious how easy it would be to generate the same changelog format with using git-cliff.

The result is the following:

# Changelog

## [0.2.10](https://github.com/astral-sh/uv/compare/0.2.9..0.2.10)

### Preview features

* Exclude preview items from changelog by @zanieb in [#4202](https://github.com/astral-sh/uv/pull/4202)
* Bump version to 0.2.10 by @zanieb in [#4201](https://github.com/astral-sh/uv/pull/4201)
* Clarify role of `--system` flag in README by @zanieb in [#4031](https://github.com/astral-sh/uv/pull/4031)
* Add `uv toolchain install` by @zanieb in [#4164](https://github.com/astral-sh/uv/pull/4164)
* Recreate project environment if `--python` or `requires-python` doesn't match by @konstin in [#3945](https://github.com/astral-sh/uv/pull/3945)
* Improve static metadata extraction for Poetry projects by @charliermarsh in [#4182](https://github.com/astral-sh/uv/pull/4182)
* Add `uv toolchain list` by @zanieb in [#4163](https://github.com/astral-sh/uv/pull/4163)
* Fetch managed toolchains in `uv run` by @zanieb in [#4143](https://github.com/astral-sh/uv/pull/4143)
* Implement `Toolchain::find_or_fetch` and use in `uv venv --preview` by @zanieb in [#4138](https://github.com/astral-sh/uv/pull/4138)
* Fix `>=` to `==` typo in `is_contained_by` docs by @charliermarsh in [#4196](https://github.com/astral-sh/uv/pull/4196)
* Document bytecode compilation in pip compatibility guide by @charliermarsh in [#4195](https://github.com/astral-sh/uv/pull/4195)
* Remove `PubGrubPackage` dependency from `ResolutionGraph` by @charliermarsh in [#4168](https://github.com/astral-sh/uv/pull/4168)
### <trimmed>

## New Contributors
* @Peiffap made their first contribution in [#4170](https://github.com/astral-sh/uv/pull/4170)

**Full Changelog**: https://github.com/astral-sh/uv/compare/0.2.9...0.2.10

<!-- generated by git-cliff -->

The obvious benefit is that you will have the links and usernames in the changelog along with the contributors list.

The config (if you are interested):

Details
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[remote.github]
owner = "astral-sh"
repo = "uv"

[changelog]
# changelog header
header = """
# Changelog
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
    {% if previous.version %}\
        ## [{{ version | trim_start_matches(pat="v") }}]\
          ({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }})
    {% else %}\
        ## [{{ version | trim_start_matches(pat="v") }}]
    {% endif %}\
{% else %}\
    ## [unreleased]
{% endif %}\

### Preview features

{% for commit in commits %}
  {% if commit.github.pr_title -%}
    {%- set commit_message = commit.github.pr_title -%}
  {%- else -%}
    {%- set commit_message = commit.message -%}
  {%- endif -%}
  * {{ commit_message | split(pat="\n") | first | trim }}\
    {% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
    {% if commit.github.pr_number %} in \
      [#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }}) \
    {%- endif %}
{%- endfor -%}

{%- if github -%}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
  {% raw %}\n{% endraw -%}
  ## New Contributors
{%- endif %}\
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
  * @{{ contributor.username }} made their first contribution
    {%- if contributor.pr_number %} in \
      [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
    {%- endif %}
{%- endfor -%}
{%- endif -%}

{% if version %}
    {% if previous.version %}
      **Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
    {% endif %}
{% else -%}
  {% raw %}\n{% endraw %}
{% endif %}

{%- macro remote_url() -%}
  https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# postprocessors
postprocessors = []

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = false
# filter out the commits that are not conventional
filter_unconventional = true
# regex for preprocessing the commit messages
commit_preprocessors = [
  # remove issue numbers from commits
  { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# regex for matching git tags
tag_pattern = "[0-9].*"
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"

Also you can take a look at https://github.com/ratatui-org/ratatui/blob/main/cliff.toml

Did this experiment and just wanted to share the results 🐻

Cheers!

@zanieb
Copy link
Member Author

zanieb commented Jun 15, 2024

Hi! Thanks maybe I'll take a look at it. We actually don't want the usernames / contributors in the changelog because we think it's too noisy. We are interested in populating the GitHub Release notes with the contributing users but I haven't had time to invest in the tooling.

Where do you do filtering based on the pull request label? I don't see it in the template you shared. Actually it looks like there isn't categorization based on pull request labels which is our main criteria.

@orhun
Copy link
Contributor

orhun commented Jun 16, 2024

Ah I see! Here is the updated version:

### bug & preview

* Fix relative and absolute path handling in lockfiles by @konstin in [#4266](https://github.com/astral-sh/uv/pull/4266)
* Respect workspace-wide `requires-python` in interpreter selection by @charliermarsh in [#4298](https://github.com/astral-sh/uv/pull/4298)
* Respect `requires-python` in `uv lock` by @zanieb in [#4282](https://github.com/astral-sh/uv/pull/4282)
* Use registry URL for fetching source distributions from lockfile by @charliermarsh in [#4280](https://github.com/astral-sh/uv/pull/4280)

### cli & preview

* Add `--force` option to `uv toolchain install` by @zanieb in [#4313](https://github.com/astral-sh/uv/pull/4313)

### configuration & preview

* Add `--no-build`, `--no-build-package`, and binary variants by @charliermarsh in [#4322](https://github.com/astral-sh/uv/pull/4322)
* Load configuration options from workspace root by @charliermarsh in [#4295](https://github.com/astral-sh/uv/pull/4295)
* Add persistent configuration for non-`pip` APIs by @charliermarsh in [#4294](https://github.com/astral-sh/uv/pull/4294)

### error messages & preview

* Omit project name from workspace errors by @charliermarsh in [#4299](https://github.com/astral-sh/uv/pull/4299)

### internal & cli

* Move project commands into their own subcommand struct by @charliermarsh in [#4261](https://github.com/astral-sh/uv/pull/4261)

### internal & configuration

* DRY up index argument parsing by @charliermarsh in [#4262](https://github.com/astral-sh/uv/pull/4262)

## New Contributors
* @ericmarkmartin made their first contribution in [#4336](https://github.com/astral-sh/uv/pull/4336)
* @hofbi made their first contribution in [#4315](https://github.com/astral-sh/uv/pull/4315)
* @funkybob made their first contribution in [#4302](https://github.com/astral-sh/uv/pull/4302)
* @brianmego made their first contribution in [#4301](https://github.com/astral-sh/uv/pull/4301)
* @ticosax made their first contribution in [#4269](https://github.com/astral-sh/uv/pull/4269)
Updated template

(I quickly put it together - it can be simplified & cleaned up a bit)

# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
    {% if previous.version %}\
        ## [{{ version | trim_start_matches(pat="v") }}]\
          ({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }})
    {% else %}\
        ## [{{ version | trim_start_matches(pat="v") }}]
    {% endif %}\
{% else %}\
    ## [unreleased]
{% endif %}\

{% for _groups, commits in commits | group_by(attribute="github.pr_labels") %}
  {%- set groups = _groups | trim_start_matches(pat="[") | trim_end_matches(pat="]") | trim | split(pat=",") -%}
  {%- set_global labels = [] -%}
  {%- for group in groups -%}
    {%- set_global label = group | trim_start_matches(pat='"') | trim_end_matches(pat='"') -%}
    {%- set_global labels = labels | concat(with=label) -%}
  {%- endfor -%}
  {% if labels | length > 1 %}

    ### {{ labels | join(sep=" & ") }}
      {% for commit in commits %}
        {% if commit.github.pr_title -%}
          {%- set commit_message = commit.github.pr_title -%}
        {%- else -%}
          {%- set commit_message = commit.message -%}
        {%- endif -%}
        * {{ commit_message | split(pat="\n") | first | trim }}\
          {% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
          {% if commit.github.pr_number %} in \
            [#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }}) \
          {%- endif %}
    {%- endfor %}
  {%- endif %}
{%- endfor -%}

{%- if github -%}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
  {% raw %}\n{% endraw -%}
  ## New Contributors
{%- endif %}\
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
  * @{{ contributor.username }} made their first contribution
    {%- if contributor.pr_number %} in \
      [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
    {%- endif %}
{%- endfor -%}
{%- endif -%}

{% if version %}
    {% if previous.version %}
      **Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
    {% endif %}
{% else -%}
  {% raw %}\n{% endraw %}
{% endif %}

{%- macro remote_url() -%}
  https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants