Skip to content

Commit 7df7954

Browse files
committed
Add limit option
1 parent de93969 commit 7df7954

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
Nothing right now.
1111

12+
## [1.3.0] - 2020-09-07
13+
14+
- Added a `--limit` option to only sync recent versions by default in a GitHub Action
15+
1216
## [1.2.0] - 2020-09-06
1317

1418
- Allows changelog content for a version to be empty, while still creating a GitHub Release for the tag.

action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ inputs:
1111
github_token:
1212
description: "A GitHub token that can create and modify releases"
1313
required: true
14+
limit:
15+
description: 'Limit syncing to the latest X versions'
16+
default: 5
1417
runs:
1518
using: docker
1619
image: Dockerfile
17-
args:
18-
- --changelog ${{ inputs.changelog }}
1920
env:
21+
CR_CHANGELOG: ${{ inputs.changelog }}
2022
CR_TAG_PREFIX: ${{ inputs.tag_prefix }}
2123
CR_NO_TAG_PREFIX: ${{ inputs.tag_prefix == '' }}
24+
CR_LIMIT: ${{ inputs.limit }}
2225
GITHUB_TOKEN: ${{ inputs.github_token }}

changerelease/cli.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def cli():
2020
default="CHANGELOG.md",
2121
type=click.Path(exists=True, file_okay=True, dir_okay=False),
2222
show_default=True,
23+
envvar="CR_CHANGELOG",
2324
)
2425
@click.option("--tag-prefix", default="v", show_default=True, envvar="CR_TAG_PREFIX")
2526
@click.option("--no-tag-prefix", default=False, is_flag=True, envvar="CR_NO_TAG_PREFIX")
@@ -29,8 +30,9 @@ def cli():
2930
envvar="GITHUB_API_URL",
3031
default="https://api.github.com",
3132
)
33+
@click.option("--limit", default=-1, envvar="CR_LIMIT")
3234
@click.option("--token", envvar="GITHUB_TOKEN", required=True)
33-
def sync(changelog, tag_prefix, no_tag_prefix, repo, api_url, token):
35+
def sync(changelog, tag_prefix, no_tag_prefix, repo, api_url, limit, token):
3436
if no_tag_prefix:
3537
tag_prefix = ""
3638

@@ -48,7 +50,12 @@ def sync(changelog, tag_prefix, no_tag_prefix, repo, api_url, token):
4850

4951
results = []
5052

51-
for version in cl.versions:
53+
versions = cl.versions
54+
if limit > -1:
55+
click.echo(f"Limiting to {limit} of {len(versions)} versions")
56+
versions = versions[:limit]
57+
58+
for version in versions:
5259
click.secho(f"\nSyncing version {version}", bold=True)
5360
version_contents = cl.parse_version_content(version)
5461

0 commit comments

Comments
 (0)