Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Unable to cleanup releases #44

Closed
ryan-dyer-sp opened this issue Mar 29, 2024 · 6 comments · Fixed by #47
Closed

Unable to cleanup releases #44

ryan-dyer-sp opened this issue Mar 29, 2024 · 6 comments · Fixed by #47

Comments

@ryan-dyer-sp
Copy link

ryan-dyer-sp commented Mar 29, 2024

I have a repo with ~10 releases and no pre-releases. The tags and titles of the releases are the same and follow the format v<major>.<minor>.<patch> (semver). My config is as such:

    - uses: dev-drprasad/delete-older-releases@v0.3.3
      with:
        keep_latest: 5
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Output shows:


Run dev-drprasad/delete-older-releases@v0.3.3
  with:
    keep_latest: 5
    keep_min_download_counts: 0
    delete_expired_data: 0
    delete_prerelease_only: false
    github_rest_api_url: api.github.com
  env:
    GITHUB_TOKEN: ***
💬  no `repo` name given. fall-ing back to this repo
🌶  given `keep_min_download_counts` is 0, this will not enable the download count removal rule
🌶  given `delete_expired_data` is  0
😕  no active releases found. exiting...

I have content: write permissions on the GHA with an earlier step creating new releases with each push.

What am I missing? Thanks!

@mjjonone
Copy link

I had the same problem recently, but I ran it before without reporting an error.

@thadguidry
Copy link
Collaborator

thadguidry commented Apr 1, 2024

This seems to be a possible bug in the Releases API where for some reason, the assets: object is returning an empty array? Weird! We have a check on that and rely on it to first filter out any Releases without Assets as seen in our source:

if (deletePatternStr) {
return !item.draft && item.assets.length > 0 && item.tag_name.match(deletePattern);
} else {
return !item.draft && item.assets.length > 0;

What is weird is that even our own releases show they have no assets now!?!?:
image

But yet we clearly do have Release Assets:
image

I have opened a bug report discussion for GitHub API team to look into it. Stay Tuned and perhaps upvote on that bug report. (also double-check with one of your release id's against the API URL like I did above, to see if you get assets returned or not; let me know here.)

@shihyuho
Copy link

shihyuho commented Apr 1, 2024

I was wondering what the purpose is of checking assets.length. Or can we set a variable to determine whether we should check assets?

@thadguidry
Copy link
Collaborator

thadguidry commented Apr 1, 2024

@shihyuho It's used to basically ensure that we can get Active Releases (those with Assets?) in order to get their Download Counts to filter against the parameter input keep_min_download_counts - See PR #27 and files changed. In order to check download counts, we had to ensure the data filtered had assets (and thus download counts within those). Regardless, it's a bug somewhere on GitHub API where it is no longer showing the assets through the API responses, even when there are clearly assets on any particular release id as I demonstrated above.

@thadguidry
Copy link
Collaborator

thadguidry commented Apr 1, 2024

Hmm, actually maybe our code needs to be improved in that section to iterate through release ids, build a map using the List Release Assets instead?

But then why does the List Release example response show Assets already being displayed inline with each release, as if the List Release Assets method isn't even needed? (And it used to work and show Release Assets inline when Listing Releases, and our code indeed worked that way).

PR's welcome!

@ryan-dyer-sp
Copy link
Author

From looking at your json @thadguidry, it appears that perhaps github broke assets into 3 unique fields. All releases have the source code available in two different zip files. Those appear to be represented by the two fields tarball_url and zipball_url. Then assets would be specifically for additional "custom" assets that get added to the release. We dont have custom assets as we're using this for tagging our repo and providing release notes for the changes. The repo itself is the asset thats consumed by other things. IMO it sounds like assets doesnt need to be checked. I dont fully understand this concept/term of "Active Releases". Its not a github thing itself. If this is based on downloaded assets, we will never have an asset be downloaded. Not the custom assets or either of the tarball URLs. We simply want our releases page cleaned up after so many iterations.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants