Search code examples
gitgithubgithub-pagesgithub-apigithub-actions

Github UPDATE / OVERWRITE existing asset of a release


I have a asset in my latest release which I want to overwrite.
I am using Github Api to get upload url of latest release assets (username and token is optional here).

upload_url=$(curl -sL userName:token https://api.github.com/repos/actions/checkout/releases/latest | jq -r '.upload_url')

This can be used to upload asset to that url but if there is an existing asset with same name then it throws error.

So I want a way to update or delete that asset...
Github api has endpoints(update, delete) to do it but can you help me with these curl commands? how do I do it.


Solution

  • So I want a way to update or delete that asset...

    GitHub CLI gh 2.5.0 now has gh release delete-asset, from PR 4416 and issue 4258

    gh release delete-asset <tag> <asset-name> [flags]
    

    It wraps the appropriate GitHub API endpoint;

    DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}