-
Notifications
You must be signed in to change notification settings - Fork 13
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 releasing guide and release script #59
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import re | ||
import subprocess | ||
|
||
|
||
def run_towncrier(tag): | ||
cmd = ("towncrier", "build", "--version", tag.strip("v")) | ||
|
||
return subprocess.call(cmd) | ||
|
||
|
||
def update_fallback_version_in_pyproject(tag, fname="pyproject.toml"): | ||
version = tag.strip("v").split(".") | ||
if len(version) < 3: | ||
version += ["0"] | ||
|
||
# Default to +1 on patch version | ||
major, minor, patch = version[0], version[1], int(version[2]) + 1 | ||
|
||
with open(fname, "r") as file: | ||
lines = file.readlines() | ||
|
||
pattern = "fallback_version" | ||
new_version = f"{major}.{minor}.{patch}.dev0" | ||
# Iterate through the lines and find the pattern | ||
for i, line in enumerate(lines): | ||
if re.search(pattern, line): | ||
lines[i] = f'{pattern} = "{new_version}"\n' | ||
break | ||
|
||
# Write the updated content back to the file | ||
with open(fname, "w") as file: | ||
file.writelines(lines) | ||
|
||
print( | ||
f"\nNew (fallback) dev version ({new_version}) written to `pyproject.toml`.\n" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Get tag argument | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("tag") | ||
args = parser.parse_args() | ||
tag = args.tag | ||
|
||
# Update release notes | ||
# towncrier is not used in this repository | ||
# run_towncrier(tag) | ||
|
||
# Update fallback version for setuptools_scm | ||
update_fallback_version_in_pyproject(tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
Cut a Release | ||
============= | ||
|
||
Create a PR to the `main` branch and go through the following steps: | ||
|
||
**Preparation** | ||
- Prepare the release by running the `prepare_release.py` python script (e.g. `python prepare_release.py 2.0.1`) , which will do the following: | ||
- update the `setuptools_scm` fallback version in `pyproject.toml`. | ||
- Check release notes | ||
- (optional) check conda-forge and wheels build. Pushing a tag to a fork will run the release workflow without uploading to pypi | ||
- Let that PR collect comments for a day to ensure that other maintainers are comfortable with releasing | ||
|
||
**Tag and release** | ||
:warning: this is a point of no return point :warning: | ||
- push tag (`vx.y.z`) to the upstream repository and the following will be triggered: | ||
- build of the wheels and their upload to pypi | ||
- creation of a Github Release | ||
|
||
**Post-release action** | ||
- Merge the PR | ||
|
||
Follow-up | ||
========= | ||
|
||
- Tidy up and close corresponding milestone | ||
- A PR to the conda-forge feedstock will be created by the conda-forge bot | ||
|
||
Additional information | ||
====================== | ||
|
||
The version is defined by ``setuptools_scm`` at build time when packaging HyperSpy. In an editable installation (when using ``pip install -e .``), the version is defined from the | ||
git repository. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not seem to be using towncrier so far
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for leaving the script as it is but commented out the call to this function in the
__main__
block.