Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using release drafter in combination with goreleaser #207

Closed
arminc opened this issue May 31, 2020 · 18 comments
Closed

Using release drafter in combination with goreleaser #207

arminc opened this issue May 31, 2020 · 18 comments

Comments

@arminc
Copy link

arminc commented May 31, 2020

I am using https://github.com/marketplace/actions/release-drafter to create a draft release for every PR. When I do a release with goreleaser with changelog skip to true it creates a new release instead of using the draft.
I was wondering if this should work and if so how? If not then it means I either need to accept I can only use goreleasers commits or maybe try to use https://github.com/buchanae/github-release-notes as input? Any other solutions or examples where people use PR for notes with goreleaser?

@crazy-max
Copy link
Member

Hi @arminc, do you have a link to your repo?

@arminc
Copy link
Author

arminc commented May 31, 2020

@crazy-max
Copy link
Member

crazy-max commented May 31, 2020

@arminc I think it's a release-drafter constraint and you should also apply this step in your release.yml workflow. Something like that:

    - name: Run GoReleaser
      uses: goreleaser/goreleaser-action@v1
      with:
        version: latest
        args: release --rm-dist
      env:
        GITHUB_TOKEN: ${{ secrets.TOKEN_REPO }}
    - name: Publish Release Notes
      uses: release-drafter/release-drafter@v5
      with:
        publish: true
      env:
        GITHUB_TOKEN: ${{ secrets.TOKEN_REPO }}

See also release-drafter/release-drafter#424 (comment)

@arminc
Copy link
Author

arminc commented May 31, 2020

I have tried it out but it doesn't seem to work out. I will do some more testing or open an issue with release-drafter.
I find it interesting that goreleaser doesn't "recognize" or do anything with the draft. When I was using the travis-ci deploy provider for github it actually "converted or used, not sure which it was" the draft to make it a proper release with binaries included. I am not sure what they were doing that is why I assumed it had to do something with goreleaser.

@arminc
Copy link
Author

arminc commented May 31, 2020

@crazy-max Thanks for the quick help. As you can see in this issue release-drafter/release-drafter#542 release drafter currently can't do a publish. In my opinion that kind of makes sense. Shouldn't it be goreleasers job to use a draft if it is already there?

@jetersen
Copy link

jetersen commented Jun 1, 2020

release-drafter/release-drafter/pull/546 should greatly improve the experience.

You can even write something like this after the PR is merged:

name: Release Drafter

on:
  push:
    branches:
      - master
    tags:
      - v*
    release:
      types: [deleted]

jobs:
  update_release_draft:
    runs-on: ubuntu-latest
    steps:
      - name: Draft Release
        uses: release-drafter/release-drafter@v5
        with:
          publish: ${{ contains(github.ref, "ref/tags") }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

With the following below it will allow you to publish on tags and automatically redraft and republish any deleted releases.

on:
  push:
    tags:
      - v*
    release:
      types: [deleted]

@crazy-max
Copy link
Member

Hi @jetersen thanks for the tips! We will wait for the validation of this PR ;)

@crazy-max
Copy link
Member

@jetersen As release-drafter/release-drafter/pull/546 is merged it should be ok now?

@arminc
Copy link
Author

arminc commented Jun 10, 2020

The combination still isn't working. What happens now is goreleaser creates the release with the assets, then release-drafter sees there has been a release and then releases a new version which is not what you want.
You can see what happens here: https://github.com/arminc/k8s-platform-lcm/runs/758988731?check_suite_focus=true
with the source code here https://github.com/arminc/k8s-platform-lcm/blob/9f016cbf64fe4213a37163318371aebf5bc765e6/.github/workflows/release.yml

I tried adding version to the release-drafter but it's not picking it up?

Basically what needs to happen is that either goreleaser takes the draft and uses that to release if one is available or release-drafter needs to be able to update release instead of creating a new one, to make this work.

@jetersen
Copy link

@arminc as I mentioned you will properly need to flip the order.

@arminc
Copy link
Author

arminc commented Jun 10, 2020

Will try that now

@jetersen
Copy link

though looking into goreleaser it would look like it will create the release.

However we could in release-drafter easily fox so that it would not bump the version if version is specified. I think this is done because the "last release" is using same version and we automatically bump the version.

@jetersen
Copy link

Seems you were successful: https://github.com/arminc/k8s-platform-lcm/releases/tag/0.11.0

@arminc
Copy link
Author

arminc commented Jun 10, 2020

Yes, with realease-drafter having created a draft 0.11.0, then a release happens where release-drafter actually creates the 0.11.0 release (only with the publish flag, not forcing the version). Then gorelease runs and adds the assets. So it seems it works now :)

@jetersen
Copy link

You properly want to use $RESOLVED_VERSION so you can use labels to bump the version number.
See the use case here: https://github.com/release-drafter/release-drafter/blob/master/.github/release-drafter.yml

  
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
  - title: '🚀 Features'
    labels:
      - 'feature'
      - 'enhancement'
  - title: '🐛 Bug Fixes'
    labels:
      - 'fix'
      - 'bugfix'
      - 'bug'
  - title: '🧰 Maintenance'
    labels: 
      - 'chore'
      - 'documentation'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
  ## Changes
  $CHANGES

@jetersen
Copy link

Though not sure how that works with tags now that I think about it 🤔

@arminc
Copy link
Author

arminc commented Jun 10, 2020

I will need to look into that, haven't read about the difference NEXT_MINOR_VERSION and RESOLVED_VERSION.
Having said that, @crazy-max this issue is solved

@crazy-max
Copy link
Member

@arminc Great glad you figure it out! And thanks @jetersen :)

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

No branches or pull requests

3 participants