deploy-nightly icon indicating copy to clipboard operation
deploy-nightly copied to clipboard

Unsure how max_releases works

Open simontom opened this issue 5 years ago • 12 comments

Hi, I'm not sure how max_releases should work. You can find the test yml file on bottom. Trying to use that parameter to remove older artifacts with custom names. When I used asset_name: "${{ env.NEW_APK_NAME }}-$$.txt" it worked BUT it removed older artifacts somehow ambiguously (I was never sure which one is going to be deleted).

Now it does not work. Artifacts just stack up and not get deleted at all.

Dummy night-builds URL of my test yml file using deploy-nightly

simontom avatar Mar 01 '20 16:03 simontom

releases are sorted by created_at date and the oldest releases are being thrown out if they match the given pattern. As you are using an environment variable for the filename (resolved and fixed for deploy-nightly then) it doesn't know which other releases it can delete because it can only delete stuff if it differs in the $$ part but not anywhere else in the filename

WebFreak001 avatar Mar 01 '20 20:03 WebFreak001

Well, even tho' I used the name from ur example it got deleted ambiguously I'd say. But you say "orted by created_at date" which means it does not depend on the time the artifact was added to release. However, I'm thinking why it cannot distinguish there are more artifacts and it should delete some? Well, if I just add "$$" as postfix for asset_name it should work, right? ..or is there something else I can do about it? This Action is probably the best so far I found for what I was looking for.

Edit: Ummm, OKay, now I see the code which handles cleaning old assets. I think that something like "search_pattern" or "common_prefix" or whatever like this would be awsome to have for these situations.

simontom avatar Mar 01 '20 20:03 simontom

Hey, I tried to make some changes and so.

You can see here: https://github.com/simontom/deploy-nightly

Using this yml: https://github.com/simontom/AndroidRecyclerViewSwipeToDeleteWithUndo/edit/master/.github/workflows/create-pre-release2.yml

BUT it always ends with following error: ##[error]Empty value for parameter 'name': undefined in here https://github.com/simontom/AndroidRecyclerViewSwipeToDeleteWithUndo/runs/480862586?check_suite_focus=true

simontom avatar Mar 02 '20 22:03 simontom

you removed the name parameter from the upload request so github doesn't know about the new assetName parameter you added: https://github.com/simontom/deploy-nightly/commit/67e4ab33d48ea25884d3aa69d39748227c92cdcf#diff-168726dbe96b3ce427e7fedce31bb0bcR97

you need to use name instead of assetName (name: assetName now)

WebFreak001 avatar Mar 03 '20 10:03 WebFreak001

Great eye! Thanks a bunch. I'm gonna try. It was pretty late already. & if you don't mind I can make PR after I try it works.

simontom avatar Mar 03 '20 17:03 simontom

the refactoring is good, I'm not satisfied with how the API looks though.

I don't think I would use your code as-is but if you are fine with your code you can keep on using it from your account without problems. I would probably go for a more flexible approach of having some kind of variable interpreter for the filename for the final API which also supports manual date formatting, commit hash, environment variables, etc.

WebFreak001 avatar Mar 06 '20 12:03 WebFreak001

Oh, OKay, sounds interesting! I'll keep my solution so far. And maybe use yours in the future. ;)

Thanks a bunch for you time and help.

simontom avatar Mar 06 '20 19:03 simontom

Hello! I am having, I think, a similar issue. My repo is https://github.com/MarginallyClever/Robot-Overlord-App

    - name: Build installation package
      shell: bash
      run: |
        set -x
        set -o pipefail
        APP_VERSION=$(ls -1 target/package/RobotOverlord-*-with-dependencies.jar | sed "s/.*RobotOverlord-\([^-]*\)-with-dependencies.jar/\1/") &&
        sed -i.bak "s/\(--app-version\).*/\1 $APP_VERSION/" src/main/package/jpackage.cfg &&
        jpackage "@src/main/package/jpackage.cfg" "@src/main/package/jpackage-${{matrix.os}}.cfg" --main-jar "RobotOverlord-$APP_VERSION-with-dependencies.jar" &&
        ls &&
        BINARY=$(find . -maxdepth 1 -iname 'robotoverlord*' | grep -E '(msi$|dmg$|deb$)' | sed "s,./,," | head -1) &&
        BINARY_NIGHTLY=$(echo $BINARY | sed 's/\(.*\)\.\(.*\)/\1-nightly-$$.\2/') &&
        echo "BINARY=$BINARY" | tee -a $GITHUB_ENV &&
        echo "BINARY_NIGHTLY=$BINARY_NIGHTLY" | tee -a $GITHUB_ENV

    - name: Deploy installation release
      if: github.repository == 'MarginallyClever/Robot-Overlord-App' && github.ref == 'refs/heads/master'
      uses: WebFreak001/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # automatically provided by github actions
      with:
        upload_url: ${{ env.UPLOAD_URL }}
        release_id: ${{ env.RELEASE_ID }}
        asset_path: ${{ env.BINARY }} # path to archive to upload
        asset_name: ${{ env.BINARY_NIGHTLY }} # name to upload the release as, use $$ to insert date (YYYYMMDD) and 6 letter commit hash
        asset_content_type: application/zip # required by GitHub API
        max_releases: 3 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted

This matrix runs three different nightlies, depending on the target platform. It never deletes the old nightly builds. Please tell me what I'm doing wrong and maybe how to fix it?

Super grateful for this Action, thank you for all your hard work.

i-make-robots avatar Jan 14 '24 21:01 i-make-robots

same issue here as above - nightly builds with different filenames are treated as different release lists.

So

RobotOverlord-2.107.1-nightly-$$.msi

will not delete old files that start with RobotOverlord-2.106.1-nightly-

A more flexible solution than the $$ is not yet implemented in deploy-nightly.

WebFreak001 avatar Jan 16 '24 14:01 WebFreak001

ah. I would be fine with "keep the 6 newest (by creation time)".

i-make-robots avatar Jan 16 '24 16:01 i-make-robots

that's something I don't want like that in this extension since it's intended to be used like "keep the 6 newest for each platform"

Leaving the version number out of the nightly release is currently supported, but a dynamic name like you have it isn't yet

WebFreak001 avatar Jan 16 '24 16:01 WebFreak001

I'm open to changing my system to something that works for you. a commit number isn't obvious to my users, while a version number is.

i-make-robots avatar Jan 16 '24 16:01 i-make-robots