Skip to content

gh release list: Add a flag to include only drafts #8578

Description

@mertant

Describe the feature or problem you’d like to solve

As a CLI user, I want to find (and eventually delete) outdated release drafts. To this end, I want to use gh release list to find ONLY drafts.

Currently, the gh release list includes a flag --exclude-drafts to exclude draft releases. I need to do the inverse of this: exclude non-drafts.

Proposed solution

Add a new flag to gh release list, named for example --only-drafts. Its effect should be to filter out any release where isDraft is false.

Its behaviour should be equivalent to the current --exclude-drafts, in that the filter is applied before --limit, but the filtering condition should be the opposite.

Additional context

While it is currently technically possible to achieve the same result through the use of gh release view and jq, that would require N+1 commands rather than just the one. The single-command filtering seems like a relatively basic use case to extend gh release list with, especially seeing that the equal but opposite functionality is already implemented.

Another potential workaround currently is to grep the output for Draft, but that seems hacky and unreliable.

Activity

  1. mertant commented on Feb 1, 2024

    @mertant
    Author

    The --json option was added in #8474 / version 2.43.0. With that, it is now possible to use jq to filter out non-drafts:

    gh release list --json tagName,createdAt,isDraft --jq '.[] | select(.isDraft)'

    So we could consider this issue effectively resolved by that. The flag is not necessary (at least for my needs) since jq manipulation can achieve the same thing.

  2. williammartin commented on Feb 21, 2024

    @williammartin
    Member

    Hey @mertant, sorry for the slow response after Christmas. Some team changes and a large backlog.

    It sounds like you've got what you needed for now but I'm happy to leave this open for discovery to others who might need it, and then we can prioritise it based on that.

    Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-releaserelating to the gh release command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions