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

Enhancement: a template for GitHub releases #61

Closed
nedbat opened this issue Sep 19, 2022 · 7 comments
Closed

Enhancement: a template for GitHub releases #61

nedbat opened this issue Sep 19, 2022 · 7 comments

Comments

@nedbat
Copy link
Owner

nedbat commented Sep 19, 2022

I'd like to add some text to the top of the release, like:

To install this, use `python -m pip {project}=={version}.
The PyPI page is here: https://pypi.org/project/{project}/{version}.

This could be a template applied to the markdown generated from the changelog.

@kevinmatthes
Copy link

I have an idea for the implementation of this feature but I am not quite how to test whether it works as it should. I would like to present you the idea anyway in order to discuss whether this suggestion would fit the requirements of the new feature requested. In the following, the template file will be named "preamble" as it is some text preceding the actual content.

First of all, the preamble should be a new option to configure. That way, users are free to choose to use a local preamble or, for instance, another one stored centrally in one of their submodules. I thought of something like

# src/scriv/config.py, ll. 197
    # The default preamble text to insert.
    preamble = attr.ib(
        type=str,
        default="preamble.${config:format}",
        metadata={
            "doc": """\
                This is the file storing the default text to be inserted before
                the actual changelog entries.
                """,
        }
    )

for the implementation of the new option. Users could then alter the path as required.

I would like to suggest to add the content of the preamble to the changelog, as well, since the installation instructions might change with every release. For Python projects, this can happen because the respective project is continued in another repository, see bump2version for an example; for any other projects, there might be major changes to the build routine.

Adding the preamble to the changelog, at first, would also simplify local tests, in my opinion. The configuration option would be required in both cases and moving the (invocation of the) business logic to another source file is a simple change once it works appropriately. Since the release logic reads out the changelog, the preamble would be added in each case.

In general, @nedbat, what do you think about this suggestion?

References

@nedbat
Copy link
Owner Author

nedbat commented Oct 21, 2022

I like the idea of a template for releases, and possibly also for the changelog as a whole. But I would make two changes to your design:

  1. I would make the template be a full template, not a preamble. The generated content (that is, today's content) would be provided as a variable. That way, the template could provide text before and after the content. In essence, the default release template would be simply:
{{ content }}
  1. If we have a template for the changelog, it should be separate from the template for releases. They have different audiences and needs. I haven't thought of what I would use a changelog template for, so I'm less sure that it's a useful thing.

@regisb
Copy link

regisb commented Jan 10, 2023

I'm also interested in having a template for GitHub release descriptions. For the record, this is how I generate GitHub release descriptions in Tutor: https://github.com/overhangio/tutor/blob/b903c69fac95e797532288d4e6f60530faf1db94/Makefile#L93.

And here is the GitHub description template (really just a preamble): https://raw.githubusercontent.com/overhangio/tutor/master/docs/_release_description.md

This little song-and-dance is a little tricky. For instance, it requires that I manually copy-paste the changelog to the commit message and title. I could avoid that with a GitHub description template. Alternatively, this workflow could be simplified if I just had a scriv print-changelog command.

@nedbat
Copy link
Owner Author

nedbat commented Jan 15, 2023

@regisb what do you want scriv print-changelog to do? How would it help with the flow?

@regisb
Copy link

regisb commented Jan 16, 2023

@regisb what do you want scriv print-changelog to do? How would it help with the flow?

Currently, I create GitHub releases in a GitHub action with the gh release create command. (workflow source)

I do not use scriv github-release because I want a custom release description.

The solution I found to generate the GitHub release description is to store the release changelog in the release git message. (with copy-paste, see release instructions). Then, I output the full GitHub description to stdout by running (source):

sed "s/TUTOR_VERSION/v15.0.1/g" docs/_release_description.md
git log -1 --pretty=format:%b

I could avoid storing the changelog in the git message if I had a scriv print-changelog command.

I am aware that this feature is only tangentially related to the issue at hand here. The reason that I am mentioning it is that it should (I think) be a quick win that is simpler to implement than the GitHub release templating.

@nedbat
Copy link
Owner Author

nedbat commented Jan 16, 2023

I've implemented the release templating in commit 3c55b26.

@nedbat nedbat closed this as completed Jan 16, 2023
@nedbat
Copy link
Owner Author

nedbat commented Jan 16, 2023

This is now released as part of scriv 1.1.0.

regisb added a commit to overhangio/tutor that referenced this issue Jan 17, 2023
In scriv 1.1.0 the GitHub release description can be templated:
nedbat/scriv#61
https://github.com/nedbat/scriv/releases/tag/1.1.0

This means that we can finally get rid of our ugly scripts to generate the
release description \o/
regisb added a commit to overhangio/tutor that referenced this issue Jan 17, 2023
In scriv 1.1.0 the GitHub release description can be templated:
nedbat/scriv#61
https://github.com/nedbat/scriv/releases/tag/1.1.0

This means that we can finally get rid of our ugly scripts to generate the
release description \o/
regisb added a commit to overhangio/tutor that referenced this issue Jan 17, 2023
In scriv 1.1.0 the GitHub release description can be templated:
nedbat/scriv#61
https://github.com/nedbat/scriv/releases/tag/1.1.0

This means that we can finally get rid of our ugly scripts to generate the
release description \o/
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

No branches or pull requests

3 participants