Upload assets when we create the release #25
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we create the github release, upload the assets at the same time, so that github is responsible for apply the latest flag to the release and only applies latest when all assets are uploaded. Right now there is a delay between when the release is created and when the assets are available, which causes the "install latest" script to fail for a short period of time after a release is created. I looked into managing the latest flag ourselves, so that we can flip it after we upload the assets but gh is doing a lot of logic around if it's the most recent and highest semver tag, and I'd like to not replicate that logic.
In the past I have seen create release fail when uploading assets during release creation, which is why it was originally split into two steps. Now that the code is checking for the existence of the release and re-uploading assets, that shouldn't be a problem. If a release fails while uploading, it won't have latest applied yet to it and we can kick the build to retry the upload to the release. I am also ensuring that the release isn't still marked as a draft when we retry uploading the assets. If asset upload fails during release creation, the release is left in draft and the draft flag needs to be removed once we finish uploading the assets during retry.
I have also turned on automatic release note creation so that we don't need to do that manually after the release is finished.
This is the groundwork for getporter/porter#2723. It won't go live until we update our go.mod in each repository that uses this package though.