From 53e1abbe3c3abd69e462993462ded5313b6054db Mon Sep 17 00:00:00 2001 From: DeadNews Date: Mon, 8 Apr 2024 22:41:42 +0200 Subject: [PATCH] docs(changelog): add `git-cliff` (#149) --- .github/workflows/main.yml | 32 ++++++++++++-- .typos.toml | 3 ++ CHANGELOG.md | 87 ++++++++++++++++++++++++++++++++++++++ Makefile | 30 ++++++++++--- README.md | 7 +-- cliff.toml | 85 +++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 7 files changed, 231 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 cliff.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 636836b..0770709 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,10 +3,10 @@ name: Main on: push: branches: [main] + tags: + - "v*" pull_request: branches: [main] - release: - types: [created] permissions: contents: read @@ -36,11 +36,11 @@ jobs: publish-pypi: name: Release to PyPI - if: github.event_name == 'release' && github.event.action == 'created' + if: github.ref_type == 'tag' needs: [lint] + environment: pypi permissions: id-token: write - environment: pypi runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -57,3 +57,27 @@ jobs: - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 + + github-deploy: + name: Release to GitHub + if: github.ref_type == 'tag' + needs: [lint] + environment: github-releases + permissions: + contents: write + env: + CHANGELOG: https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md + PRERELEASE: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Create GitHub Release + run: | + gh release create ${{ github.ref_name }} \ + --title ${{ github.ref_name }} \ + --notes="See [the CHANGELOG](${{ env.CHANGELOG }}) for more details." \ + --draft=${{ env.PRERELEASE }} \ + --prerelease=${{ env.PRERELEASE }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.typos.toml b/.typos.toml index 6f495c3..eff36ef 100644 --- a/.typos.toml +++ b/.typos.toml @@ -1,2 +1,5 @@ +[files] +extend-exclude = ["CHANGELOG.md"] + [default.extend-words] hav = "hav" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..136e896 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,87 @@ +# Changelog + +## [0.0.6-alpha.5](https://github.com/DeadNews/dnfunc/compare/v0.0.5...v0.0.6-alpha.5) - 2024-04-08 + +### ๐Ÿšœ Refactor + +- imports and type aliases - ([d42cdbb](https://github.com/DeadNews/dnfunc/commit/d42cdbbb5536bcb7e8afb3725e238d67a55cc528)) + +### ๐Ÿ“š Documentation + +- _(changelog)_ add `git-cliff` - ([8ccc357](https://github.com/DeadNews/dnfunc/commit/8ccc3576ca248b2694c9f1c53b7b034f78722706)) +- _(changelog)_ add `git-cliff` - ([47fb52a](https://github.com/DeadNews/dnfunc/commit/47fb52acdd055e925eca2c75f24ff186120a6b25)) +- _(changelog)_ add `git-cliff` - ([7f76aad](https://github.com/DeadNews/dnfunc/commit/7f76aadd21530659aae81d64b10dd432f3cbff28)) +- update docstrings ([#139](https://github.com/DeadNews/dnfunc/issues/139)) - ([5ee9cd7](https://github.com/DeadNews/dnfunc/commit/5ee9cd785d33cb215f48c363aec8ab8d411c9ffe)) + +### ๐ŸŽจ Styling + +- update `ruff` settings ([#134](https://github.com/DeadNews/dnfunc/issues/134)) - ([9139b18](https://github.com/DeadNews/dnfunc/commit/9139b1808c980d8bedcd3744a9235ad3a0c76c97)) + +### ๐Ÿงน Chores + +- _(makefile)_ update commands - ([4435085](https://github.com/DeadNews/dnfunc/commit/4435085ef497a7c14ed30fa7a475fef22d691d79)) +- _(makefile)_ update commands - ([78ba320](https://github.com/DeadNews/dnfunc/commit/78ba320ba2341c4cbd7c4d02c6db736691000338)) +- _(makefile)_ update commands - ([330d6be](https://github.com/DeadNews/dnfunc/commit/330d6be790d70d1b81ded8eb338612ed78b3eaf3)) +- update `ruff` settings - ([d437f96](https://github.com/DeadNews/dnfunc/commit/d437f96f8ddc10659d4d4e0f88f9216824965fe2)) + +### โš™๏ธ CI/CD + +- _(pre-commit)_ add `checkmake` hook - ([7b47d89](https://github.com/DeadNews/dnfunc/commit/7b47d89e5c12db6a6b17b0a74eb8df80d8a6b63b)) + +## [0.0.5](https://github.com/DeadNews/dnfunc/compare/v0.0.4...v0.0.5) - 2023-11-18 + +### ๐Ÿงน Chores + +- rename `poe` task - ([e87871a](https://github.com/DeadNews/dnfunc/commit/e87871a084f69eb7431ef22fac610bec65b0d739)) +- reorder `poe` tasks - ([5defe08](https://github.com/DeadNews/dnfunc/commit/5defe081e008d991ba85b6056a419313bbbd5273)) +- replace `black` with `ruff` ([#118](https://github.com/DeadNews/dnfunc/issues/118)) - ([020efe8](https://github.com/DeadNews/dnfunc/commit/020efe8df9d1bbabacb03ba5d4c9a70980d43d1d)) + +### โš™๏ธ CI/CD + +- use `pypi` deploy environment - ([17a3179](https://github.com/DeadNews/dnfunc/commit/17a3179250461bbab2e1972309d2c738313faece)) +- move `pytest` command - ([07aa81f](https://github.com/DeadNews/dnfunc/commit/07aa81fddaaefb3516a11066332ff2ad6094a208)) + +### โฌ†๏ธ Dependencies + +- _(deps)_ update dependency lvsfunc to v0.8.1 ([#115](https://github.com/DeadNews/dnfunc/issues/115)) - ([c207d76](https://github.com/DeadNews/dnfunc/commit/c207d76afc75d3ba7e0a3dc6eebe2c2397e73b9d)) +- _(deps)_ update ([#111](https://github.com/DeadNews/dnfunc/issues/111)) - ([9de9ff9](https://github.com/DeadNews/dnfunc/commit/9de9ff95b7e4a918be2cb836cf735e4653c10a03)) + +## [0.0.4](https://github.com/DeadNews/dnfunc/compare/v0.0.3...v0.0.4) - 2023-07-16 + +### ๐Ÿšœ Refactor + +- move code from `__init__` ([#93](https://github.com/DeadNews/dnfunc/issues/93)) - ([4a6b004](https://github.com/DeadNews/dnfunc/commit/4a6b00424ea5e734843a5953e81cc06f98c5eb6a)) + +### ๐Ÿ“š Documentation + +- fix `workflow` name - ([eae41cf](https://github.com/DeadNews/dnfunc/commit/eae41cffb861d03bce5eea6e3aef441191c4a4b9)) + +### ๐Ÿงน Chores + +- ignore `PLR0913` ruff rule - ([3c3f1e1](https://github.com/DeadNews/dnfunc/commit/3c3f1e1ccc00d764a197022a69fcc7ad13ebe019)) +- rename poetry `group` - ([c998dfd](https://github.com/DeadNews/dnfunc/commit/c998dfd845b0efe2355919d769753e626c3aed1a)) + +### โš™๏ธ CI/CD + +- _(pre-commit)_ add `typos` hook - ([dedeef2](https://github.com/DeadNews/dnfunc/commit/dedeef2d1179098a8220a28fa9f4ee34f07412b8)) +- _(renovate)_ adjust schedule - ([95a56d3](https://github.com/DeadNews/dnfunc/commit/95a56d3b27bc4557ff05bf3e851a6d0913509615)) +- use `digest pinning` - ([81d14c5](https://github.com/DeadNews/dnfunc/commit/81d14c5e2eee9b4983deee4cefac9aa91b3838fa)) +- update `workflows` ([#70](https://github.com/DeadNews/dnfunc/issues/70)) - ([5b04284](https://github.com/DeadNews/dnfunc/commit/5b042845e83bfc587567f49c1dc7c2e8ae11398d)) + +### โฌ†๏ธ Dependencies + +- _(deps)_ update dependency vstools to v2.2.1 ([#87](https://github.com/DeadNews/dnfunc/issues/87)) - ([735c434](https://github.com/DeadNews/dnfunc/commit/735c434ca1b8a4bf767d6b4ba837807fbafbc187)) +- _(deps)_ update dependency lvsfunc to ^0.8.0 ([#86](https://github.com/DeadNews/dnfunc/issues/86)) - ([a3113be](https://github.com/DeadNews/dnfunc/commit/a3113be70192b6022ec3e5cab94f2070525aded1)) + +## [0.0.3] - 2023-05-06 + +### ๐Ÿš€ Features + +- dev pr ([#64](https://github.com/DeadNews/dnfunc/issues/64)) - ([eb74ceb](https://github.com/DeadNews/dnfunc/commit/eb74cebf9b55eb1fcf98f0ef79f2e05f2a4fb088)) + +### ๐Ÿ“š Documentation + +- _(README)_ format - ([28e7fbe](https://github.com/DeadNews/dnfunc/commit/28e7fbeeead6600c311aa821e2ef52ab8759cdc3)) +- _(README)_ add deps link - ([06c3c4b](https://github.com/DeadNews/dnfunc/commit/06c3c4b91ef12378cfa371f08edab8972cc7611f)) + + diff --git a/Makefile b/Makefile index 7cbd1c0..df3e502 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,20 @@ -.PHONY: all clean test checks +.PHONY: all clean default install lock update checks pc test docs run -install-all: install pc-install +default: checks install: + pre-commit install poetry install --sync -pc-install: - pre-commit install +lock: + poetry lock --no-update -update-latest: +update: poetry up --latest -checks: pc-run install lint +checks: pc install lint -pc-run: +pc: pre-commit run -a lint: @@ -21,3 +22,18 @@ lint: test: poetry run pytest + +bumped: + git cliff --bumped-version + +# make release-tag_name +# make release-$(git cliff --bumped-version)-alpha.0 +release-%: checks + git cliff -o CHANGELOG.md --tag $* + pre-commit run --files CHANGELOG.md || pre-commit run --files CHANGELOG.md + git add CHANGELOG.md + git commit -m "chore(release): prepare for $*" + git push + git tag -a $* -m "chore(release): $*" + git push origin $* + git tag --verify $* diff --git a/README.md b/README.md index 385dd61..2a47d03 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ > A collection of Vapoursynth functions and wrappers -[![PyPI version](https://img.shields.io/pypi/v/dnfunc)](https://pypi.org/project/dnfunc) -[![Main](https://github.com/DeadNews/dnfunc/actions/workflows/main.yml/badge.svg)](https://github.com/DeadNews/dnfunc/actions/workflows/main.yml) -[![pre-commit.ci](https://results.pre-commit.ci/badge/github/DeadNews/dnfunc/main.svg)](https://results.pre-commit.ci/latest/github/DeadNews/dnfunc/main) +[![PyPI: Version](https://img.shields.io/pypi/v/dnfunc?logo=pypi&logoColor=white)](https://pypi.org/project/dnfunc) +[![GitHub: Release](https://img.shields.io/github/v/release/deadnews/dnfunc?logo=github&logoColor=white)](https://github.com/deadnews/dnfunc/releases/latest) +[![CI: Main](https://img.shields.io/github/actions/workflow/status/deadnews/dnfunc/main.yml?branch=main&logo=github&logoColor=white&label=main)](https://github.com/deadnews/dnfunc/actions/workflows/main.yml) +[![CI: pre-commit](https://results.pre-commit.ci/badge/github/DeadNews/dnfunc/main.svg)](https://results.pre-commit.ci/latest/github/deadnews/dnfunc/main) ## Deps diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..d617e8a --- /dev/null +++ b/cliff.toml @@ -0,0 +1,85 @@ +# git-cliff ~ configuration file +# https://git-cliff.org/docs/configuration + +[changelog] +header = """ +# Changelog\n +""" +postprocessors = [ + { pattern = '', replace = "https://github.com/DeadNews/dnfunc" }, +] +body = """ +{%- macro remote_url() -%} + https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} +{%- endmacro -%} + +{% macro print_commit(commit) -%} + - {% if commit.scope %}_({{ commit.scope }})_ {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message }} - \ + ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\ +{% endmacro -%} + +{% if version %}\ + {% if previous.version %}\ + ## [{{ version | trim_start_matches(pat="v") }}]\ + ({{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% endif %}\ +{% else %}\ + ## [unreleased] +{% endif %}\ + +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + {{ self::print_commit(commit=commit) }} + {%- endfor -%} + {% raw %}\n{% endraw %}\ + {%- for commit in commits %} + {%- if not commit.scope -%} + {{ self::print_commit(commit=commit) }} + {% endif -%} + {% endfor -%} +{% endfor %}\n +""" +footer = """ + +""" +trim = true + +[git] +conventional_commits = true # parse the commits based on https://www.conventionalcommits.org +filter_unconventional = true # filter out the commits that are not conventional +split_commits = false # process each line of a commit as an individual commit +commit_preprocessors = [ + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))" }, # Replace github issue numbers + { pattern = " +", replace = " " }, # Remove multiple whitespaces +] +commit_parsers = [ + { message = "^(ci|build|chore)\\(deps.*\\)", skip = true }, + { message = "^chore\\(release\\)", skip = true }, + { message = "^fix\\(deps.*\\)", group = "โฌ†๏ธ Dependencies" }, + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix", group = "๐Ÿ› Bug fixes" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore", group = "๐Ÿงน Chores" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^build", group = "๐Ÿ‘ท Build" }, + { message = "^ci", group = "โš™๏ธ CI/CD" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, +] +protect_breaking_commits = true +filter_commits = false # filter out the commits that are not matched by commit parsers +tag_pattern = "v[0-9].*" # regex for matching git tags +skip_tags = "" # drop commits from the changelog +ignore_tags = "rc|beta|alpha" # include ignored commits into the next tag +topo_order = false # sort the tags topologically +sort_commits = "newest" # sort the commits inside sections by oldest/newest order diff --git a/pyproject.toml b/pyproject.toml index 636dad6..bdcde18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "poetry_dynamic_versioning.backend" name = "dnfunc" version = "0.0.0" description = "A collection of Vapoursynth functions and wrappers" -authors = ["DeadNews "] +authors = ["DeadNews "] license = "MIT" readme = "README.md" homepage = "https://github.com/DeadNews/dnfunc"