Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Change the label prefix to use a dash #28

Merged
merged 3 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ Leaving this input out will disable uploading to PyPI.
### Update version
Based on which of the following labels are applied to a PR, update the version number:

- `impact:breaking` to bump the major version
- `impact:feature` to bump the minor version
- `impact:bugfix` to bump the micro version
- `impact:post-release` to bump the `post` version
- `impact:project` to make no change
- `impact-breaking` to bump the major version
- `impact-feature` to bump the minor version
- `impact-bugfix` to bump the micro version
- `impact-post-release` to add/bump the `post` version
- `impact-project` to make no change

Supported build tools:
- [Poetry](https://pypi.org/project/poetry/)
Expand Down Expand Up @@ -127,6 +127,3 @@ Input:

### Create a release on GitHub
Finally, when everything is live, create a release on GitHub to both tag the release in the repository and store the artifacts uploaded to PyPI. The name of the release is the version prepended by `v` and the body of the release is the changelog entry.

#### TODO
- [Upload release artifacts](https://developer.github.com/v3/repos/releases/#upload-a-release-asset)
28 changes: 14 additions & 14 deletions release_often/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ def update_version():
gidgethub.actions.command("debug", f"Current/old version is {current_version}")
new_version = version.bump_by_label(gidgethub.actions.event(), current_version)
gidgethub.actions.command("debug", f"New version is {new_version}")
new_contents = build_tool.change_version(
file_contents, current_version, new_version
)
try:
new_contents = build_tool.change_version(
file_contents, current_version, new_version
)
except ValueError as exc:
# Bump label is missing.
error(str(exc))
version_file.write_text(new_contents, encoding="utf-8")
return new_version

Expand Down Expand Up @@ -95,18 +99,10 @@ def upload(output_dir, pypi_token):
)


async def make_release(releases_url, version, changelog_entry, oauth_token):
async with httpx.AsyncClient() as client:
gh = gidgethub.httpx.GitHubAPI(
client, "brettcannon/release_often", oauth_token=oauth_token
)
return await release.create(gh, releases_url, version, changelog_entry)


def create_release(version, changelog_entry, oauth_token):
async def create_release(gh, version, changelog_entry):
event = gidgethub.actions.event()
releases_url = event["repository"]["releases_url"]
return trio.run(make_release, releases_url, version, changelog_entry, oauth_token)
return await release.create(gh, releases_url, version, changelog_entry)


if __name__ == "__main__":
Expand All @@ -124,4 +120,8 @@ def create_release(version, changelog_entry, oauth_token):
gidgethub.actions.command(
"debug", "PyPI uploading skipped; no API token provided"
)
upload_url = create_release(new_version, changelog_entry, args.github_token)
async with httpx.AsyncClient() as client:
gh = gidgethub.httpx.GitHubAPI(
client, "brettcannon/release_often", oauth_token=args.github_token
)
trio.run(create_release, gh, new_version, changelog_entry)
15 changes: 9 additions & 6 deletions release_often/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
from . import flit, poetry


LABEL_PREFIX = "impact-"


@enum.unique
class BumpLevel(enum.Enum):
major = "impact:breaking"
minor = "impact:feature"
micro = "impact:bugfix"
post = "impact:post-release"
internal = "impact:project"
major = f"{LABEL_PREFIX}breaking"
minor = f"{LABEL_PREFIX}feature"
micro = f"{LABEL_PREFIX}bugfix"
post = f"{LABEL_PREFIX}release"
internal = f"{LABEL_PREFIX}project"


def bump(version, bump_by):
Expand Down Expand Up @@ -57,4 +60,4 @@ def bump_by_label(event, old_version):
else:
return bump(old_version, level)
else:
raise ValueError("'impact' label missing")
raise ValueError(f"{LABEL_PREFIX!r} label missing")
2 changes: 1 addition & 1 deletion tests/data/merged_PR.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"name": "skip news"
},
{
"name": "impact:breaking"
"name": "impact-breaking"
}
],
"milestone": null,
Expand Down