Skip to content

Commit

Permalink
Merge pull request #27 from CallyCo-io/refactor/release-action
Browse files Browse the repository at this point in the history
Refactor release action
  • Loading branch information
techman83 authored Jun 11, 2024
2 parents 2f20da3 + c3ad6ba commit 4c55bd2
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
36 changes: 36 additions & 0 deletions .NOTES.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{#- macro: render_commit -#}
{%- macro render_commit(commit) -%}
- {{ commit.convention.subject|default(commit.subject) }} ([{{ commit.hash|truncate(7, True, '') }}]({{ commit.url }}) by {{ commit.author_name }}).
{%- if commit.text_refs.issues_not_in_subject %} Related issues/PRs: {% for issue in commit.text_refs.issues_not_in_subject -%}
{% if issue.url %}[{{ issue.ref }}]({{ issue.url }}){% else %}{{ issue.ref }}{% endif %}{% if not loop.last %}, {% endif -%}
{%- endfor -%}{%- endif -%}
{%- for trailer_name, trailer_value in commit.trailers.items() -%}
{%- if trailer_value|is_url %} [{{ trailer_name }}]({{ trailer_value }})
{%- else %} {{ trailer_name }}: {{ trailer_value }}{% endif %}
{%- if not loop.last %},{% endif %}
{%- endfor -%}
{%- endmacro -%}

{#- macro: render_section -#}
{%- macro render_section(section) -%}
### {{ section.type or "Misc" }}

{% for commit in section.commits|sort(attribute='author_date',reverse=true)|unique(attribute='subject') -%}
{{ render_commit(commit) }}
{% endfor %}
{%- endmacro -%}

{%- macro render_version(version) -%}
{% for type in changelog.sections %}
{%- if type in version.sections_dict %}
{%- with section = version.sections_dict[type] %}
{{ render_section(section) }}
{%- endwith %}
{%- endif %}
{%- endfor %}
{% endmacro -%}

{#- template -#}
{% for version in changelog.versions_list -%}
{{ render_version(version) }}
{%- endfor -%}
4 changes: 4 additions & 0 deletions .git-changelog.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
convention = "conventional"
output = "NOTES.md"
template = "path:.NOTES.jinja"
sections = "feat,fix,docs,style,refactor,perf,test"
2 changes: 1 addition & 1 deletion .github/workflows/build-tool-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
python-version: ${{ matrix.python }}
- name: Get distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: package-${{ inputs.version }}
path: dist
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/release-cally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Build distribution
run: python -m build
- name: Save dist files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: package-${{ steps.set-version.outputs.version }}
path: dist
Expand All @@ -50,7 +50,7 @@ jobs:
id-token: write
steps:
- name: Get distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: package-${{ needs.build-artifact.outputs.version }}
path: dist
Expand All @@ -61,16 +61,29 @@ jobs:
runs-on: ubuntu-latest
needs: build-artifact
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install git-changelog
run: pip install git-changelog
- name: Prepare release notes
run: |
PREVIOUS=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))
git-changelog --filter-commits ${PREVIOUS}..v${{ needs.build-artifact.outputs.version }}
- name: Get distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: package-${{ needs.build-artifact.outputs.version }}
path: dist
- uses: "marvinpinto/action-automatic-releases@latest"
- name: Release
uses: softprops/action-gh-release@v2
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
draft: false
body_path: NOTES.md
files: |
dist/cally-${{ needs.build-artifact.outputs.version }}.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Releasing
NOTES.md

0 comments on commit 4c55bd2

Please sign in to comment.