ffurrer2 / extract-release-notes

A GitHub Action to extract release notes from a "Keep a Changelog" formatted changelog file
MIT License
64 stars 25 forks source link

Some chars need to be escaped #349

Open Goooler opened 3 months ago

Goooler commented 3 months ago

My changelog looks like this:

### Added
* In order to use `custom`, you must now use Gradle 8.0+.

I use this action to pick it and release it like:

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Extract release notes
        id: extract-release-notes
        uses: ffurrer2/extract-release-notes@v2
      - name: Create release
        run: gh release create --title ${{ github.ref_name }} --notes '${{ steps.extract-release-notes.outputs.release_notes }}'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

and the errors will show:

/home/runner/work/_temp/b424905f-a1d2-4aef-ba90-8f409d60cac5.sh: line 2: custom: command not found

in this case, I tried to write the output into a file and pick the file from GH CLI like:

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Extract release notes
        id: extract-release-notes
        uses: ffurrer2/extract-release-notes@v2
      - name: Write release note into a file
        run: echo "${{ steps.extract-release-notes.outputs.release_notes }}" > release_notes.txt
      - name: Create release
        run: gh release create --title ${{ github.ref_name }} --notes-file release_notes.txt
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The same error shown. I believe we have to escape "`" in my example and write it to a file:

echo "### Added\n* In order to use \`custom\`, you must now use Gradle 8.0+.\n" > note.txt

cat note.txt

### Added
* In order to use `custom`, you must now use Gradle 8.0+.
Goooler commented 3 months ago

I know why, must use single quotations ('') instead of double quotations ("") here.

Goooler commented 3 months ago

A new case:

### Added
- it's there

run

echo '### Added
- it's there' > note.txt
quote>

this ' could not be escaped except using double quotations.

Goooler commented 3 months ago

Workaround: using release_notes_file to save the note and gh release create ${{ github.ref_name }} --notes-file RELEASE_NOTES.md. Example:

https://github.com/Goooler/keep-a-changelog/blob/05bcaa22238adc5f9f904e2003761c4005365cdd/.github/workflows/release.yaml#L15-L20