Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark GitHub Release as draft if tag doesn't exist #16

Open
MattSturgeon opened this issue Apr 4, 2024 · 5 comments
Open

Mark GitHub Release as draft if tag doesn't exist #16

MattSturgeon opened this issue Apr 4, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@MattSturgeon
Copy link
Contributor

While working on #15 I came to the conclusion that createTag=false and draft=true are kinda incompatible. Or at least unintuitive.

I realised while working on MinecraftFreecam/Freecam#195 that it'd be useful to mark a release as a draft only when the tag doesn't exist yet.

I'm not sure the best API for this. Maybe some options would become enums, but with boolean and String overloaded setters?

@hypherionmc
Copy link
Member

Sorry, been busy with work stuff. Meant to answer you earlier on the PR comment.

that it'd be useful to mark a release as a draft only when the tag doesn't exist yet.

This was actually our original behavior. The release was only marked as a draft, if it didn't exist when the upload started. That way all the artifact uploads could finish, before the release was "made public"

We could either as you suggested, rename it for clarity, or, move it to an enum/boolean

@MattSturgeon
Copy link
Contributor Author

This was actually our original behavior. The release was only marked as a draft, if it didn't exist when the upload started. That way all the artifact uploads could finish, before the release was "made public"

Sorry for being unclear. The draft option controls what happens to the release after uploading the artifacts, not when creating the release.

So, regardless of what you set github.draft to, the release will always start off as a draft (unless the release already exists).

This issue is about keeping the release as a draft if the tag didn't exist (not release), although I suppose it may also be useful to also have the keep-as-draft-if-release-didn't-exist option too...

@MattSturgeon
Copy link
Contributor Author

MattSturgeon commented Apr 4, 2024

I wonder if the best way to approach this would be a custom predicate?

We could pass a context object to a markDraft predicate with properties such as:

  • wasDraft
  • tagExists
  • releaseExists

And use the return value in releaseUpdater.draft()?

The default predicate could just be (ctx) -> false to maintain the previous behaviour.

@hypherionmc
Copy link
Member

I wonder if the best way to approach this would be a custom predicate?

We could pass a context object to a markDraft predicate with properties such as:

* wasDraft

* tagExists

* releaseExists

And use the return value in releaseUpdater.draft()?

This sounds like a good compromise. To make it easier to implement, this could be tied to an Enum. That way you could pass in the enum, or a string, similar to ReleaseType, ModLoader etc

@MattSturgeon
Copy link
Contributor Author

MattSturgeon commented Apr 4, 2024

To make it easier to implement, this could be tied to an Enum.

An enum of default predicates?

Not sure it'd make implementation easier, but it would make common use-cases simpler.

enum GHDraftPredicate {
    NEVER(ctx -> false),
    ALWAYS(ctx -> true),
    NEW_TAG(ctx -> !ctx.existingTag);
    // etc

    // Predicate field
    @Getter
    private Predicate<ReleaseContext> predicate;

    // Example factory
    static GHDraftPredicate valueOf(boolean val) {
        return val ? ALWAYS : NEVER;
    }

    // Constructor, factories, etc omitted for clarity
}

The draft option would then have overloaded setters accepting Predicate<ReleaseContext>, GHDraftPredicate or anything that can be handled by the enum's factories (string, boolean)

@hypherionmc hypherionmc added the enhancement New feature or request label Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants