rajatjindal / krew-release-bot

bot to bump version of plugin in krew-index on new releases
Apache License 2.0
47 stars 17 forks source link

Add support for ignoring prereleases #54

Closed marccampbell closed 3 years ago

marccampbell commented 3 years ago

This is a feature request.

The bot should be able to not push to krew on prerelease tags.

Goreleaser has a setting that can optionally make the GitHub release a prerelease based on either a parameter or the tag name. Right now, the bot doesn't have matching logic, and the Goreleaser action doesn't have an output to determine if it was a prerelease. There are ways to handle this today, but all of them have some drawbacks:

  1. Use a separate workflow I don't need to use a separate workflow for goreleaser, so making the krew-release-bot a separate workflow is difficult.

  2. Add an if step to the workflow, something roughly like:

      - name: Check Tag
        id: check-tag
        run: |
          if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
              echo ::set-output name=match::true
          fi
      - name: Build
        if: steps.check-tag.outputs.match == 'true'
        run: |
          echo "Tag is a match"

That's a little tricky because that regex in the example is super raw. We could look at the goreleaser source to get the right pattern, and that solves it for the case where goreleaser.yml has prerelease: auto.

I propose a cleaner solution, where the krew-release-bot can query the release, and if it's a prerelease, it won't execute. There could be a variable in the action to always release, even on prereleases, if necessary. But I believe that the default should be for the krew-release-bot to ignore prerelease tags.

rajatjindal commented 3 years ago

Hi @marccampbell

thanks for opening this feature request.

my understanding is we dont make PR for pre-releases already.

https://github.com/rajatjindal/krew-release-bot/blob/master/pkg/source/actions/action_runner.go#L59

can you point me to an execution which is a pre-release and opened PR, i can try to debug why that happened.

marccampbell commented 3 years ago

Thanks! I was afraid to test it out and get a krew release on my pre-release tag. This is great.