diff --git a/.changelog-config.yaml b/.changelog-config.yaml new file mode 100644 index 0000000..63d980b --- /dev/null +++ b/.changelog-config.yaml @@ -0,0 +1,123 @@ +# For more configuration information, please see https://callowayproject.github.io/generate-changelog/ + +# User variables for reference in other parts of the configuration. +variables: + changelog_filename: CHANGELOG.md + +# Pipeline to find the most recent tag for incremental changelog generation. +# Leave empty to always start at first commit. +starting_tag_pipeline: + - action: ReadFile + kwargs: + filename: '{{ changelog_filename }}' + - action: FirstRegExMatch + kwargs: + pattern: (?im)^## (?P\d+\.\d+(?:\.\d+)?)\s+\(\d+-\d{2}-\d{2}\)$ + named_subgroup: rev + +# Used as the version title of the changes since the last valid tag. +unreleased_label: Unreleased + +# Process the commit's first line for use in the changelog. +summary_pipeline: + - action: strip_spaces + - action: Strip + comment: Get rid of any periods so we don't get double periods + kwargs: + chars: . + - action: SetDefault + args: + - no commit message + - action: capitalize + - action: append_dot + +# Process the commit's body for use in the changelog. +body_pipeline: + - action: ParseTrailers + comment: Parse the trailers into metadata. + kwargs: + commit_metadata: save_commit_metadata + +# Process and store the full or partial changelog. +output_pipeline: + - action: IncrementalFileInsert + kwargs: + filename: '{{ changelog_filename }}' + last_heading_pattern: (?im)^## \d+\.\d+(?:\.\d+)?\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)$ + +# Full or relative paths to look for output generation templates. +template_dirs: + - .github/changelog_templates/ + +# Group the commits within a version by these commit attributes. +group_by: + - metadata.category + +# Only tags matching this regular expression are used for the changelog. +# tag_pattern: ^[0-9]+\.[0-9]+(?:\.[0-9]+)?$ +# tag_pattern: ^v[0-9]+\.[0-9]+(?:\.[0-9]+)?$ +# Version tags RegEx from https://regex101.com/r/vkijKf/1/ preceeded by v +tag_pattern: ^(v0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ + +# Tells ``git-log`` whether to include merge commits in the log. +include_merges: true + +# Ignore commits whose summary line matches any of these regular expression patterns. +ignore_patterns: + - '[@!]minor' + - '[@!]cosmetic' + - '[@!]refactor' + - '[@!]wip' + - ^$ + - ^Merge branch + - ^Merge pull + +# Set the commit's category metadata to the first classifier that returns ``True``. +commit_classifiers: + - action: SummaryRegexMatch + category: New + kwargs: + pattern: (?i)^(?:new|add)[^\n]*$ + - action: SummaryRegexMatch + category: Updates + kwargs: + pattern: (?i)^(?:update|change|rename|remove|delete|improve|refactor|chg|modif)[^\n]*$ + - action: SummaryRegexMatch + category: Fixes + kwargs: + pattern: (?i)^(?:fix)[^\n]*$ + - action: + category: Other + +# Tokens in git commit trailers that indicate authorship. +valid_author_tokens: + - author + - based-on-a-patch-by + - based-on-patch-by + - co-authored-by + - co-committed-by + - contributions-by + - from + - helped-by + - improved-by + - original-patch-by + +# Rules applied to commits to determine the type of release to suggest. +release_hint_rules: + - match_result: dev + branch: ^((?!master|main).)*$ + - match_result: patch + grouping: Other + branch: master|main + - match_result: patch + grouping: Fixes + branch: master|main + - match_result: minor + grouping: Updates + branch: master|main + - match_result: minor + grouping: New + branch: master|main + - match_result: major + grouping: Breaking Changes + branch: master|main diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 71b9a12..8b6b630 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: [ push, pull_request ] jobs: - dump-contexts: + dump-context: runs-on: ubuntu-latest steps: - name: Dump context "GitHub" @@ -14,10 +14,6 @@ jobs: build-test: runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest ] - python_version: [ '3.x' ] if: startsWith(github.ref, 'refs/tags/') steps: - name: Check out the repository @@ -25,7 +21,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python_version }} + python-version: [ '3.x' ] - name: Install dependencies run: | python -m pip install --upgrade pip @@ -67,7 +63,7 @@ jobs: name: python-package-distributions path: dist/ - build-publish-testpypi: + publish-testpypi: runs-on: ubuntu-latest needs: build-distribution environment: @@ -93,7 +89,7 @@ jobs: # user: __token__ # password: ${{ secrets.TEST_PYPI_SECRECT }} - build-publish-pypi: + publish-pypi: runs-on: ubuntu-latest needs: [ build-distribution, build-publish-testpypi ] environment: @@ -110,11 +106,47 @@ jobs: name: python-package-distributions path: dist/ - name: Publish 📦 to PyPI - # if: startsWith(github.ref, 'refs/heads/main') uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist/ - # url = "https://upload.pypi.org/legacy/" + # repository-url = "https://upload.pypi.org/legacy/" verbose: true # user: __token__ # password: ${{ secrets.PYPI_SECRECT }} + + github-release: + runs-on: ubuntu-latest + needs: publish-pypi + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Sign the Python 🐍 distribution 📦 with Sigstore + uses: sigstore/gh-action-sigstore-python@v3.0.0 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 4bb777b..048842b 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -23,7 +23,7 @@ defaults: jobs: - dump-contexts: + dump-context: runs-on: ubuntu-latest steps: - name: Dump context "GitHub" diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml index 42e3952..faa2711 100644 --- a/.github/workflows/draft.yml +++ b/.github/workflows/draft.yml @@ -7,7 +7,7 @@ on: jobs: - dump-contexts: + dump-context: runs-on: ubuntu-latest steps: - name: Dump context "GitHub" diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 9a90676..b5f7321 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - master permissions: actions: read @@ -14,7 +13,7 @@ permissions: jobs: - dump-contexts: + dump-context: runs-on: ubuntu-latest steps: - name: Dump context "GitHub" @@ -31,3 +30,4 @@ jobs: uses: crazy-max/ghaction-github-labeler@v5.0.0 with: skip-delete: true + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 285ab1a..8c03082 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ defaults: jobs: - dump-contexts: + dump-context: runs-on: ubuntu-latest steps: - name: Dump context "GitHub" diff --git a/CHANGELOG.md b/CHANGELOG.md index cd28ae5..efe513c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,24 @@ -# Changelog +# CHANGELOG -## Version 0.0.1 (development) -- First pre-alpha -- ... +## v0.0.9 (2024-12-11) + + +## v0.0.8 (2024-11-24) + + +## v0.0.7 (2024-11-24) + + +## v0.0.6 (2024-11-24) + + +## v0.0.4 (2024-11-24) + + +## v0.0.3 (2024-11-24) + + +## v0.0.2 (2024-11-24) + +- Initial Release diff --git a/pyproject.toml b/pyproject.toml index 113ad36..c736bf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ fibonacci = "pytestdornech.skeleton:app" [project.urls] # important URLs for this project # ToDo: Modify according to your needs! -Documentation = "https://github.com/dornech/pytestdornech" +Documentation = "https://dornech.github.io/pytestdornech" Source = "https://github.com/dornech/pytestdornech" # Tracker = "https://github.com/dornech/pytestdornech/issues" # Sponsor = "https://github.com/sponsors/dornech" @@ -76,6 +76,72 @@ exclude = [ "/.github", ] +[tool.semantic_release] +assets = [] +build_command = "pip install hatch && hatch build" +build_command_env = [] +commit_message = "{version}\n\nAutomatically generated by python-semantic-release" +commit_parser = "angular" +logging_use_named_masks = false +major_on_zero = true +allow_zero_version = true +no_git_verify = false +tag_format = "v{version}" +version_variable = [] +version_toml = [] +version_pattern = [] + +[tool.semantic_release.branches.main] +match = "(main|master)" +prerelease = false +prerelease_token = "rc" + +[tool.semantic_release.changelog] +exclude_commit_patterns = [] +mode = "init" +insertion_flag = "" + +[tool.semantic_release.changelog.default_templates] +changelog_file = "CHANGELOG.md" +output_format = "md" +mask_initial_release = true + +[tool.semantic_release.changelog.environment] +block_start_string = "{%" +block_end_string = "%}" +variable_start_string = "{{" +variable_end_string = "}}" +comment_start_string = "{#" +comment_end_string = "#}" +trim_blocks = false +lstrip_blocks = false +newline_sequence = "\n" +keep_trailing_newline = false +extensions = [] +autoescape = false + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " + +[tool.semantic_release.commit_parser_options] +minor_tags = ["feat"] +patch_tags = ["fix", "perf"] +other_allowed_tags = ["build", "chore", "ci", "docs", "style", "refactor", "test"] +allowed_tags = ["feat", "fix", "perf", "build", "chore", "ci", "docs", "style", "refactor", "test"] +default_bump_level = 0 + +[tool.semantic_release.remote] +name = "origin" +type = "github" +token = { env = "GH_TOKEN" } +ignore_token_for_push = false +insecure = false + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true + ################## # External Tools # ################## diff --git a/src/pytestdornech/__init__.py b/src/pytestdornech/__init__.py index 2728f01..bdb9469 100644 --- a/src/pytestdornech/__init__.py +++ b/src/pytestdornech/__init__.py @@ -3,7 +3,8 @@ Notion-API: https://developers.notion.com/reference/intro """ -# from importlib.metadata import PackageNotFoundError, version + +# import # # try: # __version__ = version('pytestdornech') @@ -17,12 +18,21 @@ # https://github.com/maresb/hatch-vcs-footgun-example/blob/main/hatch_vcs_footgun_example/__init__.py # Define the variable '__version__': try: - # If setuptools_scm is installed (e.g. in a development environment with - # an editable install), then use it to determine the version dynamically. - from setuptools_scm import get_version - # This will fail with LookupError if the package is not installed in - # editable mode or if Git is not installed. - __version__ = get_version(root="..\..", relative_to=__file__) + + # # If setuptools_scm is installed (e.g. in a development environment with + # # an editable install), then use it to determine the version dynamically. + # from setuptools_scm import get_version + # # This will fail with LookupError if the package is not installed in + # # editable mode or if Git is not installed. + # __version__ = get_version(root="..\..", relative_to=__file__) + + # own developed alternative overcoming problem of ignored setuptools_scm settings from hatch-based pyproject.toml + # libraries + from hatch.cli import hatch + from click.testing import CliRunner + # determine version via hatch + __version__ = CliRunner().invoke(hatch, ["version"]).output.strip() + except (ImportError, LookupError): # As a fallback, use the version that is hard-coded in the file. try: diff --git a/src/pytestdornech/skeleton.py b/src/pytestdornech/skeleton.py index 1424132..8d9455d 100644 --- a/src/pytestdornech/skeleton.py +++ b/src/pytestdornech/skeleton.py @@ -79,5 +79,11 @@ def main( if __name__ == '__main__': + + from semantic_release.cli.commands.main import main + from click.testing import CliRunner + cli_cmd = ["semantic-release", "-vv", "--noop", "version", "--print"] + result = CliRunner().invoke(main, cli_cmd[1:]) + print(f"My version is '{__version__}'.\n") app()