axodotdev / cargo-dist

📦 shippable application packaging
https://axodotdev.github.io/cargo-dist/
Apache License 2.0
1.32k stars 56 forks source link

Provide a way to create releases for pre-existing tags #1094

Open Shnatsel opened 1 month ago

Shnatsel commented 1 month ago

I am adding cargo dist to my project, cargo auditable. I would like to build binaries for the latest release, which was cut before I added cargo dist.

As per the documentation, this is not possible today:

TO BE EXTREMELY PEDANTIC: The workflow will trigger whenever Github sees that the git tag and the commit it refers to are part of the repo and the timestamp(?) of both(?) is after the commit that introduced the workflow's yml file. That last part is an absolute headache, and may require you to delete the tag both locally and on github if you created it before the workflow. Basically, setup cargo-dist before you start cutting releases!

I have experimented with this in a fork, and indeed deleting and recreating the tag does not trigger the release workflow.

Potential solution

At least on Github actions, it is possible to let the user manually invoke a workflow for a given tag. But the workflow has to explicitly support this: https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow

Allowing the workflows to be manually invoked for a specific tag would allow creating binary artifacts for pre-existing tags.

The potentially tricky bit is "what if a release already exists?", but that case needs to be handled by the workflows anyway because building binaries can fail due to a transient network error after a release has been created, and it needs to be able to recover from that regardless.

ashleygwilliams commented 1 month ago

hey! those docs were written before we had the dispatch_releases option, which takes a tag as an input. combined with our create_release option (which when set to false expects a release already exists).... i think this is actually achievable now! i will run a few tests.

Shnatsel commented 1 month ago

Thank you!

I admit I am confused by the documentation of dispatch-releases option.

Specifically, I do not understand how do I trigger it. Is it the usual "Actions > Release > Run workflow", or do I manually create a Github release, or both?

It also says...

Currently hosting is also disabled, but future versions may add some forms of hosting in this mode.

But I don't understand if that applies only to the dry-run tag or all workflows, and what "hosting" even means here - is it uploading binaries to Github releases, or somewhere else? Or is it something else entirely?

ashleygwilliams commented 1 month ago

Is it the usual "Actions > Release > Run workflow"

yes, it's this, and there's a prompt for you to enter the tag

re: hosting i believe that means that we can't host on our own infra using this pathway

here's an example of a user of this feature: https://github.com/astral-sh/uv/actions/workflows/release.yml (honestly i really think this is the way to go, as a lot of downstreams appreciate when tags are treated as immutable, and this workflow really enables that but making the tag a part of the final announce step instead of the initiator!)

ashleygwilliams commented 1 month ago

(appreciate you pointing out the docs being confusing though- i agree with you, and we should definitely improve them!!)