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 a script for automating releases #647

Merged
merged 6 commits into from
Nov 26, 2024
Merged

Conversation

AlexWaygood
Copy link
Member

Summary

This adds a script to automate the changes to various different files that need to be made in order to cut a new ruff-vscode release. This is one of the many things you need to do as part of the Ruff minor release process, which I'd like to make less time-consuming.

The script does the following things:

  • Bumps the version of this package in pyproject.toml and package.json
  • Bumps the ruff and ruff-lsp dependency pins this project has in pyproject.toml to the latest versions
  • Makes any necessary edits to the README
  • Adds a draft changelog entry
  • Updates the package's lockfiles
  • Optionally commits the changes to a new branch

Test Plan

I checked out 51bc650 and ran uv run --python=3.7 release.py. The changes the script made were almost identical to 6ac401c (the latest commit we had preparing a new release).

I also ran the following command to make sure the script type-checked with strict settings:

uvx --with=types-requests --with=tomli --with=tomlkit --with=packaging --with=rich-argparse mypy release.py --strict --warn-unreachable --enable-error-code=possibly-undefined --enable-error-code=redundant-expr --enable-error-code=truthy-bool

@AlexWaygood AlexWaygood added the internal An internal refactor or improvement label Nov 26, 2024
@AlexWaygood
Copy link
Member Author

AlexWaygood commented Nov 26, 2024

I just spotted that we already have a scripts directory with some scripts that do some of these things... but they were undocumented in CONTRIBUTING.md (I had no idea they existed until just now), and were out of date (they still used pip compile from pip-tools, but this project now uses uv). The script I'm adding here is more comprehensive, anyway (those scripts didn't update the changelog or the README) :-)

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

I haven't reviewed the script in detail. I'm sure it works.

I suggest that we add CLI options for all new versions to support future patch releases, preview releases, and any unforseen scenario

CONTRIBUTING.md Show resolved Hide resolved
scripts/release.py Outdated Show resolved Hide resolved
existing_vscode_version = pyproject_toml["project"]["version"]

major, minor, micro = Version(existing_vscode_version).release
new_vscode_version = Version(f"{major}.{minor + 2}.{micro}")
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, how would we do a patch release or release a preview version (which we've done a few times in the past)?

Copy link
Member Author

Choose a reason for hiding this comment

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

My idea of this script was to cover the common workflow rather than all possible workflows. I can add a CLI flag for this if you want, but I worry that the complexity it will add to the script won't be worth the time it will save us

Copy link
Member

Choose a reason for hiding this comment

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

The problem I see is that this PR removes the documentation on how to do a release manually when not using the script. To me, that means it's now the only way of doing a release.

That's why I think we should either revert the documentation changes or extend the script. I'm worried about reverting the documentation because it probably will get outdated with future changes to this script which then is even worse: You end up with incomplete/incorrect instructions

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. Okay, I'll add the CLI flags.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added more flags in 37b2935, and tested them using uv run --python=3.7 scripts/release.py --new-version=2024.600.0 --new-ruff=0.6.0. It did everything I expected it to.

Also, it didn't end up being much more code at all, so I think it was worth it -- thanks for persuading me!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding it and thanks for automating the steps!

else:
changelog_entry_middle = ""

changelog_entry = textwrap.dedent(f"""\
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need the \.

Isn't it nice how Ruff wraps the multiline string? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a very common practice when using textwrap.dedent() in combination with triple-quoted strings, or it's easy to end up with a dedented string where the first line has odd indentation https://grep.app/search?q=textwrap.dedent%28%22%22%22%5C&filter[lang][0]=Python

Isn't it nice how Ruff wraps the multiline string? :)

I'm... actually not a massive fan of that formatting choice 🙈 but I don't care enough to argue about it 😆

Copy link
Member

@MichaReiser MichaReiser Nov 26, 2024

Choose a reason for hiding this comment

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

I brought it up because it's a ruff specific style :)

@AlexWaygood
Copy link
Member Author

Thanks for the review!

@AlexWaygood AlexWaygood changed the title Add a script for automating the release Add a script for automating releases Nov 26, 2024
@AlexWaygood AlexWaygood merged commit 69a76b0 into main Nov 26, 2024
6 checks passed
@AlexWaygood AlexWaygood deleted the alex/release-automation branch November 26, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants