Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Codacy Analysis

on:
push:
branches:
- main
# push:
# branches:
# - main
pull_request:
branches:
- main
Expand Down
28 changes: 25 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- "v*"

permissions:
contents: write

jobs:
publish-package:
runs-on: ubuntu-latest
Expand All @@ -14,7 +17,7 @@ jobs:
uses: actions/checkout@v4.2.2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5.3.0
with:
python-version: "3.11"

Expand All @@ -28,7 +31,7 @@ jobs:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4.2.0
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -41,7 +44,26 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
run: poetry install --no-interaction --only-root

- name: Build package
run: |
poetry build

- name: Generate changelog for latest tag
uses: orhun/git-cliff-action@v4.4.2
with:
config: cliff.toml
args: --latest
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- name: Create release
uses: softprops/action-gh-release@v2.1.0
with:
files: dist/*
body_path: CHANGELOG.md

- name: Publish package
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build
poetry publish
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.1.1] - 2025-01-01

### 🥱 Miscellaneous Tasks

- Post-release fixes by [@dtomlinson91](https://github.com/dtomlinson91) in [#2](https://github.com/dtomlinson91/python-snaptime/pull/2)

post-release fixes


## [v0.1.0] - 2025-01-01

### ✨ Features

- Initial release by [@dtomlinson91](https://github.com/dtomlinson91) in [#1](https://github.com/dtomlinson91/python-snaptime/pull/1)

[v0.1.1]: https://github.com/dtomlinson91/python-snaptime/compare/v0.1.0..v0.1.1
108 changes: 108 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[remote.github]
owner = "dtomlinson91"
repo = "python-snaptime"
# token = ""

[changelog]
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.

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="4,v") | trim_start_matches(pat="5,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 %}
- {% if commit.breaking %}💥 **BREAKING CHANGE**: {% endif %}{{ commit.message | upper_first -}}\
{% 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 }}) \
{%- endif -%}
{% if commit.body %}
\n{% for line in commit.body | split(pat="\n") %}
{{- line | indent(prefix=" ", first=true) }}
{% endfor -%}
{% endif -%}
{% endfor %}
{% endfor %}\n
"""

# template for the changelog footer
footer = """
{% for release in releases -%}
{% if release.version -%}
{% if release.previous.version -%}
[{{ release.version | trim_start_matches(pat="4,v") | trim_start_matches(pat="5,v") }}]: \
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}\
/compare/{{ release.previous.version }}..{{ release.version }}
{% endif -%}
{% else -%}
[unreleased]: https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}\
/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 conventional
filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false


# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "✨ Features" },
{ message = "^fix", group = "🐛 Bug Fixes" },
{ message = "^doc", group = "📘 Documentation" },
{ message = "^perf", group = "🏎 Performance" },
{ message = "^refactor", group = "🛠 Refactor/Improvement" },
{ message = "^style", group = "🎨 Styling", skip = true },
{ message = "^test", group = "🧪 Testing", skip = true },
{ message = "^build", group = "🧱 Build", skip = true },
{ body = ".*security", group = "🔐 Security", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore|^ci", group = "🥱 Miscellaneous Tasks", skip = false },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = true
# filter out the commits that are not matched by commit parsers
filter_commits = true
# regex for matching git tags
tag_pattern = "^(v[0-9]+.[0-9]+.[0-9]+)$"
# tag_pattern = "^(v[0-9]+.[0-9]+.[0-9]+)(?:.dev[0-9]+)?$"
# regex for skipping tags
skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
ignore_tags = ""
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"

commit_preprocessors = [
# remove issue numbers from commits
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
]
6 changes: 5 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: lint test
.PHONY: lint test changelog

lint:
@echo "Linting the code"
Expand All @@ -13,3 +13,7 @@ test:
@echo "Running tests"
poetry run pytest --cov=python_snaptime
poetry run coverage html

changelog:
@echo "Generating changelog"
git cliff > CHANGELOG.md
Loading