Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,14 @@ jobs:
- name: "create working branch for previous major release (${{ env.LATEST_VERSION }})"
if: ( env.RELEASE_KIND == 'major' )
run: |
# save a branch so that we can easily create PR for that version when we want to fix something
git checkout "v${{ env.LATEST_VERSION }}"
export BRANCH_NAME=$(echo "${{ env.LATEST_VERSION }}" | sed 's/^\([0-9]*\).*/v\1/')
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
# create branch of version
- name: prepare project version ${{ env.RELEASE_REF }} ${{ env.LATEST_VERSION }} -> ${{ env.NEW_VERSION }}
run: |
# jump back for the case that we switched to a tag
git checkout "${{ env.RELEASE_REF }}"
# install pontos
python3 -m pip install pontos
#poetry install
#poetry shell
pontos-version update ${{ env.NEW_VERSION }}
if git diff --exit-code --quiet; then
echo "There are no modified files, skipping."
Expand All @@ -131,32 +125,35 @@ jobs:
git push origin ${{ env.RELEASE_REF }}
fi

- run: mkdir assets/
- run: mkdir -p assets/

# Install git-cliff using Greenbone's UV action
- name: Install git-cliff
uses: greenbone/actions/uv@v3
with:
install: git-cliff

# Generate changelog with git-cliff and cliff.toml configuration
- name: Generate changelog with git-cliff
run: |
# Generate changelog from previous version to HEAD
git-cliff -v --strip header -o /tmp/changelog.md --config cliff.toml --tag "${{ env.NEW_VERSION }}" "v${{ env.LATEST_VERSION }}..HEAD"
# Fallback if changelog is empty
if [ ! -s "/tmp/changelog.md" ]; then
echo "No release notes. See commit history for details." > /tmp/changelog.md
fi

- name: release ${{ env.LATEST_VERSION }} -> ${{ env.NEW_VERSION }}
run: |
export PROJECT=$(echo "${{ github.repository }}" | sed 's/.*\///' )
pontos-changelog \
--current-version ${{ env.LATEST_VERSION }} \
--next-version ${{ env.NEW_VERSION }} \
--config changelog.toml \
--repository ${{ github.repository }} \
--versioning-scheme semver \
-o /tmp/changelog.md || true
# we would rather have empty release notes than no release
if [ ! -f "/tmp/changelog.md" ]; then
touch /tmp/changelog.md
fi
echo "${{ secrets.GREENBONE_BOT_TOKEN }}" | gh auth login --with-token
# lets see how smart it is
export nrn="v${{ env.NEW_VERSION }}"
export filename="$PROJECT-$nrn"
echo "${{ secrets.GREENBONE_BOT_TOKEN }}" | gh auth login --with-token
gh release create "$nrn" -F /tmp/changelog.md
mkdir -p assets
ls -las assets/
curl -Lo assets/$filename.zip https://github.com/${{ github.repository }}/archive/refs/tags/$nrn.zip
curl -Lo assets/$filename.tar.gz https://github.com/${{ github.repository }}/archive/refs/tags/$nrn.tar.gz
echo -e "${{ secrets.GPG_KEY }}" > private.pgp
echo ${{ secrets.GPG_PASSPHRASE }} | bash .github/sign-assets.sh private.pgp
rm assets/$filename.zip
rm assets/$filename.tar.gz
gh release upload $nrn assets/*
gh release upload $nrn assets/*
8 changes: 0 additions & 8 deletions changelog.toml

This file was deleted.

87 changes: 87 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[changelog]
# template for the changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}

{% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
## [Unreleased]
{% endif -%}

{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
{% if commit.remote.username %} by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }}){%- endif -%}
{% if commit.remote.pr_number %} in \
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
{% elif commit.id %} in \
[{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }})\
{%- endif -%}
{% endfor %}
{% endfor -%}
"""
# template for the changelog footer
footer = """
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}

{% for release in releases %}
{% if release.version -%}
{% if release.previous.version -%}
[{{ release.version | trim_start_matches(pat="v") }}]: \
{{ self::remote_url() }}/compare/{{ release.previous.version }}..{{ release.version }}
{% endif -%}
{% else -%}
[unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}..HEAD
{% endif -%}
{%- endfor -%}
"""
# remove the leading and trailing whitespace from the templates
trim = true

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not following the conventional commits format
filter_unconventional = false
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# remove issue numbers from commits
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^[a|A]dd", group = "<!-- 1 -->:sparkles: Added" },
{ message = "^[c|C]hange", group = "<!-- 2 -->:construction_worker: Changed" },
{ message = "^[f|F]ix", group = "<!-- 3 -->:bug: Bug Fixes" },
{ message = "^[r|R]emove", group = "<!-- 4 -->:fire: Removed" },
{ message = "^[d|D]rop", group = "<!-- 4 -->:fire: Removed" },
{ message = "^[d|D]oc", group = "<!-- 5 -->:books: Documentation" },
{ message = "^[t|T]est", group = "<!-- 6 -->:white_check_mark: Testing" },
{ message = "^[c|C]hore", group = "<!-- 7 -->:wrench: Miscellaneous" },
{ message = "^[c|C]i", group = "<!-- 7 -->️:wrench: Miscellaneous" },
{ message = "^[m|M]isc", group = "<!-- 7 -->:wrench: Miscellaneous" },
{ message = "^[d|D]eps", group = "<!-- 8 -->:ship: Dependencies" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
Loading