extract-release-notes icon indicating copy to clipboard operation
extract-release-notes copied to clipboard

Some chars need to be escaped

Open Goooler opened this issue 1 year ago • 3 comments

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 avatar Jun 30 '24 10:06 Goooler

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

Goooler avatar Jul 01 '24 01:07 Goooler

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 avatar Jul 01 '24 10:07 Goooler

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

Goooler avatar Jul 05 '24 00:07 Goooler