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

chore: use towncrier for CHANGELOG #2149

Merged
merged 1 commit into from
Oct 7, 2023
Merged

Conversation

SteveLauC
Copy link
Member

@SteveLauC SteveLauC commented Oct 3, 2023

What does this PR do

This PR adopts the CHANGELOG mode used by saltstack/salt to make our change log less conflict-prone

Still WIP, will add a document here on how it fits our release workflow

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

@SteveLauC SteveLauC marked this pull request as draft October 3, 2023 15:36
@asomers
Copy link
Member

asomers commented Oct 3, 2023

Looks like a good start. How does one execute the towncrier?

@SteveLauC
Copy link
Member Author

SteveLauC commented Oct 4, 2023

Doc on how it fits into our workflow

For maintainers

How it works

The basic idea here is:

  1. every PR would create a new file as its change log under the changelog
    directory
  2. When we are going to create a new release, concatenate the change logs
    under the changelog directory, and prepend it to CHANGELOG.md

Automated concatenation and prepending

The step 2 of the last section will be automated with tool
towncrier

  1. To install towncrier

    $ pip install towncrier
  2. Basic usage

    Since nix is not a Python project, towncrier needs us to explictly tell it
    the version number of the next release.

    $ cd nix
    $ towncrier build --version=<VERSION>
    

    The best way to try this would be testing it in my fork:

    $ git clone https://github.com/SteveLauC/nix.git
    $ cd nix
    $ git checkout towncrier
    // CHANGELOG.md, before involving `towncrier`
    
    All notable changes to this project will be documented in this file.
    This project adheres to [Semantic Versioning](https://semver.org/).
    
    # Change Log
    
    
    ## [0.27.1] - 2023-08-28
    
    $ ls changelog
    1946.fixed.md  2103.added.md    2119.fixed.md    2136.changed.md  2139.changed.md  2142.added.md
    2074.added.md  2119.changed.md  2134.changed.md  2137.changed.md  2141.fixed.md    2144.changed.md
    
    # Here, I assume our next release would be 0.28.0
    $ towncrier build --version 0.28.0
    
    Loading template...
    Finding news fragments...
    Rendering news fragments...
    Writing to newsfile...
    Staging newsfile...
    I want to remove the following files:
    /tmp/nix/changelog/2144.changed.md
    /tmp/nix/changelog/2142.added.md
    /tmp/nix/changelog/2141.fixed.md
    /tmp/nix/changelog/2139.changed.md
    /tmp/nix/changelog/2137.changed.md
    /tmp/nix/changelog/2136.changed.md
    /tmp/nix/changelog/2134.changed.md
    /tmp/nix/changelog/2119.fixed.md
    /tmp/nix/changelog/2119.changed.md
    /tmp/nix/changelog/2103.added.md
    /tmp/nix/changelog/2074.added.md
    /tmp/nix/changelog/1946.fixed.md
    Is it okay if I remove those files? [Y/n]: Y
    Removing news fragments...
    Done!

    You can see that it is asking me if it is ok to remove the old files,
    and yes, it is fine and exactly what we want.

    towncrier build --version=<VERSION> --yes would assume this yes
    answer and is thus suitable for scripts.

    Let's check out our CHANGELOG.md, change log for 0.28.0 has been added!

    All notable changes to this project will be documented in this file.
    This project adheres to [Semantic Versioning](https://semver.org/).
    
    # Change Log
    
    ## [0.28.0] - 2023-10-04
    
    
    ### Added
    
    - Added `Ipv6HopLimit` to `::nix::sys::socket::ControlMessage` for Linux,
      MacOS, FreeBSD, DragonflyBSD, Android, iOS and Haiku.
      ([#2074](https://github.com/nix-rust/nix/pull/2074))
    - ...
    
    ### Changed
    
    - ...
    
    ### Fixed
    
    - ...
    
    ## [0.27.1] - 2023-08-28
    

    and the changelog directory has been cleared:

    $ ls -a changelog
    .  ..  .keep
    

When to involve towncrier

Probably we should do it in the PR that bumps our version in the
Cargo.toml

Retire cargo-release for altering CHANGELOG.md version and date

Before this, we are using cargo-release to replacing

[Unreleased] - ReleaseDate

with a specific version and date

We no longer need this with towncrier, it will do this for us as seen in the
above demo.

For contributors

For how to add a change log for a PR, see CONTRIBUTING.md.

@SteveLauC SteveLauC changed the title WIP: chore: one changelog for each PR chore: one changelog for each PR Oct 4, 2023
@SteveLauC SteveLauC changed the title chore: one changelog for each PR chore: use towncrier for CHANGELOG Oct 4, 2023
@SteveLauC SteveLauC marked this pull request as ready for review October 4, 2023 02:41
@SteveLauC SteveLauC requested a review from asomers October 4, 2023 02:42
@SteveLauC SteveLauC mentioned this pull request Oct 4, 2023
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

Looks good! But ironically, you have a merge conflict in CHANGELOG.md.

@SteveLauC SteveLauC merged commit b28132b into nix-rust:master Oct 7, 2023
1 of 35 checks passed
@SteveLauC SteveLauC deleted the towncrier branch October 7, 2023 01:39
@SteveLauC
Copy link
Member Author

Merged this PR directly into master without all the CI checks since there are no code changes

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

Successfully merging this pull request may close these issues.

2 participants