Skip to content

Commit

Permalink
fix(actions): Generazione changelog (#52)
Browse files Browse the repository at this point in the history
Risolti alcuni problemi dell'action che effettua la Release in
automatico.

- Migliorato il file di configurazione per la generazione dei changelog
per le Release: ora viene aggiunto il tag all'autore del commit. In
questo modo nella release viene creata (in automatico) la sezione
'Contributors'.
- Sistemato un problema per il quale veniva mostrato tutto il corpo dei
commit nella sezione 'Commits'. Questo era dovuto al fatto che i commit
non 'conventional' non hanno la distinzione tra corpo e header del
commit. Ora viene mostrata solo la prima riga dei commit non
convenzionali.

#patch
  • Loading branch information
ncvescera authored Aug 14, 2023
2 parents cec6e89 + 332de65 commit 028938c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,23 @@ jobs:
with:
fetch-depth: 0

- name: Generate changelog
uses: orhun/git-cliff-action@v2
id: git-cliff
with:
config: .github/workflows/configs/conf.toml
args: -vv --latest --unreleased --strip header --tag v${{needs.tag.outputs.newtag}}
- name: Install jq
run: sudo apt-get install -y jq

- name: Install git-cliff 🏔
run: |
export version=1.2.0
wget "https://github.com/orhun/git-cliff/releases/download/v${version}/git-cliff-${version}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvzf git-cliff-*.tar.gz
cp "git-cliff-${version}/git-cliff" /usr/local/bin/
- name: Generate a changelog
run: git-cliff -vv --latest --unreleased --strip header --config .github/workflows/conf.toml --tag v${{needs.tag.outputs.newtag}} -o log.md
env:
OUTPUT: CHANGES.md
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cat Changelog
run: cat ${{ steps.git-cliff.outputs.changelog }}
run: cat log.md

- name: Create Release
uses: actions/create-release@v1
Expand All @@ -51,5 +57,5 @@ jobs:
with:
tag_name: "v${{needs.tag.outputs.newtag}}"
release_name: "v${{needs.tag.outputs.newtag}}"
body: ${{ steps.git-cliff.outputs.content }}
body_path: log.md

9 changes: 5 additions & 4 deletions .github/workflows/configs/conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ github_repo_link }}/commit/{{ commit.id }})) by {{ commit.author.name }}\
- {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ github_repo_link }}/commit/{{ commit.id }})) \
{% endfor %}
{% endfor %}\n
Expand All @@ -40,9 +40,10 @@ filter_unconventional = false
split_commits = false
# regex for parsing and grouping commits

# commit_preprocessors = [
# {pattern = "username", replace_command="gh api -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' /repos/ncvescera/provaactions/commits/$COMMIT_SHA | jq -r .author.login"},
# ]
commit_preprocessors = [
{pattern = ".*", replace_command="echo -n \"$(head -1 $@) @$(gh api -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' /repos/Typing-Monkeys/AppuntiUniversita/commits/$COMMIT_SHA | jq -r .author.login)\""}
]

commit_parsers = [
{ message = "^feat", group = "Features 🚀"},
{ message = "^fix", group = "Fixes 🔨"},
Expand Down

0 comments on commit 028938c

Please sign in to comment.