Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

[Feature] Add release body templated from changelog #64

Open
zhongjiajie opened this issue Apr 27, 2020 · 5 comments
Open

[Feature] Add release body templated from changelog #64

zhongjiajie opened this issue Apr 27, 2020 · 5 comments

Comments

@zhongjiajie
Copy link

Firstly, it's really a great action! but it could be better.
For now create-release body only support plain text, but more of repository have file mark the latest commit after last release, such as CHANGELOG.md, I think it's awesome when we support read some file as templated and to create release body. I think a while, maybe we could support two way.

  • One is render the whole file pass to parameter, which should provide the file type, like below
  body_render_type:  markdown # rst and markdown support 
  body_render_path:  ./CHANGELOG.md
  • Other is render the specific section in the file, which should provide the file type, like below
  body_render_type:  markdown # rst and markdown support 
  body_render_path:  ./CHANGELOG.md
  body_render_section:  section you want to release here

I think it would useful, at least in my situation, wait for others opinion.

@MichelDiz
Copy link

I'm not particularly sure about using CHANGELOG.md. Many repos tend to maintain a gigantic CHANGELOG.md with all the changes piled up (crowded) since the first version. I don't know how useful that would be. Unless you maintain versioning by a path. e.g. /v1.3.1/CHANGELOG.md

@zhongjiajie
Copy link
Author

I think changelog could help project users more easier get the different between each version, Especially some of them already used in their produce but find some bug or feature their expect, and them could check the changelog to judge which version them should upgrade.

@dlime
Copy link

dlime commented May 29, 2020

I'm not particularly sure about using CHANGELOG.md. Many repos tend to maintain a gigantic CHANGELOG.md with all the changes piled up (crowded) since the first version. I don't know how useful that would be. Unless you maintain versioning by a path. e.g. /v1.3.1/CHANGELOG.md

Nevertheless you sure don't want to modify the workflow.yaml everytime you release

@tobiasfaust
Copy link

you can do that with a trick by yourself

example:

- name: set Environment Variables
      id: set_env_var
      run: |
         VERSION=$(sed 's/[^0-9|.]//g' _Release.h)  # zb. 2.4.2
         if [ $REPOSITORY = "master" ]; then IS_PRE='false'; else IS_PRE='true'; fi
         if [ $REPOSITORY = "master" ]; then POSTFIX=''    ; else POSTFIX='PRE';    fi
         RELEASEBODY=$(awk -v RS='Release ' '/'$VERSION':(.*)/ {print $0}' ChangeLog.h)
         RELEASEBODY="${RELEASEBODY//'%'/'%25'}"
         RELEASEBODY="${RELEASEBODY//$'\n'/'%0A'}"
         RELEASEBODY="${RELEASEBODY//$'\r'/'%0D'}"       
         echo "::set-output name=version::${VERSION}"
         echo "::set-output name=IS_PRERELEASE::${IS_PRE}"
         echo "::set-output name=RELEASENAME_POSTFIX::${POSTFIX}"
         echo "::set-output name=RELEASEBODY::${RELEASEBODY}"
         echo "::set-env name=body::${RELEASEBODY}"
      env:
        REPOSITORY: ${{ github.event.repository.name }}
    
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 
      with:
        tag_name: v.${{ steps.set_env_var.outputs.version }}
        release_name: Release ${{ steps.set_env_var.outputs.version }} ${{ steps.set_env_var.outputs.RELEASENAME_POSTFIX }}
        body: |
            ${{ steps.set_env_var.outputs.RELEASEBODY }}
        draft: false
        prerelease: ${{ steps.set_env_var.outputs.IS_PRERELEASE }}

and ChangeLog contains like this:

Release 2.4.3:  
	- abc
        - def

Release 2.4.2:  
	- xyz
	- def

Release 2.4.1:  
	- xxxx

and _Release.h contaions this:
#define Release "2.4.2"

Finally it looks like this:

 Create Release

    GITHUB_TOKEN: ***
Run actions/create-release@v1
  with:
    tag_name: v.2.4.2
    release_name: Release 2.4.2 PRE
    body: 2.4.2:  
	- xyz
	- def
  
    draft: false
    prerelease: true
  env:
    body: 2.4.2:  
	- xyz
	- def
    GITHUB_TOKEN: ***

@mec07
Copy link

mec07 commented Aug 26, 2020

I just found this issue, but I've already made a PR to do more or less this. #89
It sets the tag and body from the changelog.
It keeps the markdown formatting of the body from the changelog. I didn't think it was necessary to expose a parameter to convert it from markdown to plain text, but that wouldn't be too hard.

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

No branches or pull requests

5 participants