From a42735c86581879fc43b2e1b5730ecc9ef04134a Mon Sep 17 00:00:00 2001 From: orhun Date: Thu, 24 Jun 2021 14:51:04 +0300 Subject: [PATCH] docs(readme): add the advanced example --- README.md | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 111d9b1..457175a 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ This action generates a changelog based on your Git history using [git-cliff](ht ### Examples +#### Simple + The following example fetches the whole Git history (`fetch-depth: 0`), generates a changelog in `./CHANGELOG.md`, and prints it out. ```yml @@ -28,7 +30,7 @@ The following example fetches the whole Git history (`fetch-depth: 0`), generate fetch-depth: 0 - name: Generate a changelog - uses: orhun/git-cliff-action@v1.0.0 + uses: orhun/git-cliff-action@v1 id: git-cliff with: config: cliff.toml @@ -40,6 +42,46 @@ The following example fetches the whole Git history (`fetch-depth: 0`), generate run: cat "${{ steps.git-cliff.outputs.changelog }}" ``` +#### Advanced + +The following example generates a changelog for the latest pushed tag and sets it as the body of the release. + +It uses [svenstaro/upload-release-action](https://github.com/svenstaro/upload-release-action) for uploading the release assets. + +```yml +- name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + +- name: Generate a changelog + uses: orhun/git-cliff-action@v1 + id: git-cliff + with: + config: cliff.toml + args: -vv --latest --strip header + env: + OUTPUT: CHANGES.md + +- name: Set the release body + id: release + shell: bash + run: | + r=$(cat ${{ steps.git-cliff.outputs.changelog }}) + r="${r//'%'/'%25'}" # Multiline escape sequences for % + r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n' + r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r' + echo "::set-output name=RELEASE_BODY::$r" + +- name: Upload the binary releases + uses: svenstaro/upload-release-action@v2 + with: + file: binary_release.zip + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + body: ${{ steps.release.outputs.RELEASE_BODY }} +``` + ## Credits This action is based on [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) and uses [git-cliff](https://github.com/orhun/git-cliff).