-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
150 additions
and
20 deletions.
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
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,73 @@ | ||
# PyMUSAS GitHub and PyPI Release Process | ||
|
||
**Reference** this guide has been adapted from the [AllenNLP release process guide](https://github.com/allenai/allennlp/blob/2cdb8742c8c8c3c38ace4bdfadbdc750a1aa2475/RELEASE_PROCESS.md), many thanks to the AllenNLP team for creating the original guide. | ||
|
||
This document describes the procedure for releasing new versions of the core library. | ||
|
||
> ❗️ This assumes you are using a clone of the main repo with the remote `origin` pointed | ||
to `[email protected]:UCREL/pymusas.git` (or the `HTTPS` equivalent). | ||
|
||
## Steps | ||
|
||
1. Set the environment variable `TAG`, which should be of the form `v{VERSION}`. | ||
|
||
For example, if the version of the release is `1.0.0`, you should set `TAG` to `v1.0.0`: | ||
|
||
```bash | ||
export TAG='v1.0.0' | ||
``` | ||
|
||
Or if you use `fish`: | ||
|
||
```fish | ||
set -x TAG 'v1.0.0' | ||
``` | ||
|
||
2. Update `pymusas/__init__.py` with the correct version and check that it matches the `TAG` environment variable you created in the first step. | ||
|
||
3. Update the `CHANGELOG.md` so that everything under the "Unreleased" section is now under a section corresponding to this release. | ||
|
||
4. Update the `CITATION.cff` file to refer to the right version and date of release. Validate the changes against the [citation file format (cff) schema](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md) you can run the following docker command (the docker image is around 257MB in size): | ||
|
||
``` bash | ||
docker run --rm -v $PWD:/app citationcff/cffconvert --validate | ||
``` | ||
|
||
For more information about CITATION.cff files see the [Citation File Format website](https://citation-file-format.github.io/). | ||
|
||
5. Check it with [twine](https://twine.readthedocs.io/en/latest/#twine-check). There is a make command that can do this, this command will install `build`, `twine`, and the latest version of `pip`: | ||
|
||
``` bash | ||
make check-twine | ||
``` | ||
|
||
6. Add these changes using Git manually (`git add`), then commit and push these changes with: | ||
|
||
``` | ||
git commit -m "Prepare for release $TAG" && git push | ||
``` | ||
|
||
7. Then add the tag in git to mark the release: | ||
|
||
``` | ||
git tag $TAG -m "Release $TAG" && git push --tags | ||
``` | ||
|
||
8. Find the tag you just pushed [on GitHub](https://github.com/UCREL/pymusas/tags), click edit, then copy over the output of: | ||
|
||
``` | ||
python scripts/release_notes.py | ||
``` | ||
|
||
9. Click "Publish Release". GitHub Actions will then handle the rest, including publishing the package to PyPI. | ||
|
||
|
||
## Fixing a failed release | ||
|
||
If for some reason the GitHub Actions release workflow failed with an error that needs to be fixed, you'll have to delete both the tag and corresponding release from GitHub. After you've pushed a fix, delete the tag from your local clone with | ||
|
||
```bash | ||
git tag -l | xargs git tag -d && git fetch -t | ||
``` | ||
|
||
Then repeat the steps above. |
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,71 @@ | ||
''' | ||
Reference: This script has been adapted from the AllenNLP repository: | ||
https://github.com/allenai/allennlp/blob/2cdb8742c8c8c3c38ace4bdfadbdc750a1aa2475/scripts/release_notes.py | ||
Prepares markdown release notes for GitHub releases. | ||
''' | ||
|
||
import os | ||
from typing import List | ||
|
||
import pymusas | ||
|
||
|
||
TAG = os.environ["TAG"] | ||
|
||
|
||
ADDED_HEADER = "### Added 🎉" | ||
CHANGED_HEADER = "### Changed ⚠️" | ||
FIXED_HEADER = "### Fixed ✅" | ||
REMOVED_HEADER = "### Removed 🗑" | ||
DEPRECATED_HEADER = "### Deprecated 👋" | ||
SECURITY_HEADER = "### Security 🔒" | ||
|
||
|
||
def get_change_log_notes() -> str: | ||
in_current_section = False | ||
current_section_notes: List[str] = [] | ||
with open("CHANGELOG.md") as changelog: | ||
for line in changelog: | ||
if line.startswith("## "): | ||
if line.startswith("## Unreleased"): | ||
continue | ||
if line.startswith(f"## [{TAG}]"): | ||
in_current_section = True | ||
continue | ||
break | ||
if in_current_section: | ||
if line.startswith("### Added"): | ||
line = ADDED_HEADER + "\n" | ||
elif line.startswith("### Changed"): | ||
line = CHANGED_HEADER + "\n" | ||
elif line.startswith("### Fixed"): | ||
line = FIXED_HEADER + "\n" | ||
elif line.startswith("### Removed"): | ||
line = REMOVED_HEADER + "\n" | ||
elif line.startswith("### Deprecated"): | ||
line = DEPRECATED_HEADER + "\n" | ||
elif line.startswith("### Security"): | ||
line = SECURITY_HEADER + "\n" | ||
current_section_notes.append(line) | ||
assert current_section_notes | ||
return "## What's new\n\n" + "".join(current_section_notes).strip() + "\n" | ||
|
||
|
||
def get_commit_history() -> str: | ||
stream = os.popen( | ||
f"git log $(git describe --always --tags --abbrev=0 {TAG}^^)..{TAG}^ --oneline" | ||
) | ||
commit_history = "## Commits\n\n" + stream.read() | ||
stream.close() | ||
return commit_history | ||
|
||
|
||
def main() -> None: | ||
assert TAG == f"v{pymusas.__version__}" | ||
print(get_change_log_notes()) | ||
print(get_commit_history()) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |