Skip to content

Commit c1a0323

Browse files
committed
Add pre-release support
1 parent d0d886b commit c1a0323

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Nothing right now.
1111

1212
## [1.3.0] - 2020-09-07
1313

14+
- Added automatic pre-release detection
1415
- Added a `--limit` option to only sync recent versions by default in a GitHub Action
1516
- Added a `--remote-changelog` option so you don't have to have the CHANGELOG file (or cloned repo) to use changerelease
1617

@@ -33,6 +34,7 @@ Adds a `tag_prefix` option so that tags don't have to start with a "v". You can
3334
The first release! Includes the `sync` command which will sync your `CHANGELOG.md` to GitHub Release notes.
3435

3536
[Unreleased]: https://github.com/dropseed/changerelease/compare/v1.1.1...HEAD
37+
[1.3.0]: https://github.com/dropseed/changerelease/compare/v1.2.0...v1.3.0
3638
[1.2.0]: https://github.com/dropseed/changerelease/compare/v1.1.1...v1.2.0
3739
[1.1.1]: https://github.com/dropseed/changerelease/compare/v1.1.0...v1.1.1
3840
[1.1.0]: https://github.com/dropseed/changerelease/compare/v1.0.0...v1.1.0

changerelease/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ def sync(
7070
versions = versions[:limit]
7171

7272
for version in versions:
73-
click.secho(f"\nSyncing version {version}", bold=True)
74-
version_contents = cl.parse_version_content(version)
73+
release = Release(repo, tag_prefix, version, requests_session)
74+
suffix = " (pre-release)" if release.prerelease else ""
75+
click.secho(f"\nSyncing version {release.version}{suffix}", bold=True)
7576

77+
version_contents = cl.parse_version_content(version)
7678
click.echo(f"{outline}\n{version_contents or '(empty)'}\n{outline}")
77-
78-
release = Release(repo, tag_prefix, version, requests_session)
7979
message, synced = release.sync(version_contents)
8080

8181
click.secho(message, fg="green" if synced else "red")

changerelease/release.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import re
2+
3+
14
class Release:
25
def __init__(self, repo, tag_prefix, version, requests_session):
36
self.repo = repo
47
self.tag_prefix = tag_prefix
58
self.version = version
69
self.version_tag = tag_prefix + version
10+
self.prerelease = bool(re.match("v?\d+\.\d+\.\d+-.+", self.version))
711

812
self.requests_session = requests_session
913

@@ -40,7 +44,7 @@ def create(self, contents):
4044
"tag_name": self.version_tag,
4145
"name": self.version,
4246
"body": contents,
43-
# TODO prerelease if semver prerelease
47+
"prerelease": self.prerelease,
4448
},
4549
)
4650
response.raise_for_status()

0 commit comments

Comments
 (0)