{"id":20915780,"url":"https://github.com/brainelectronics/changelog2version","last_synced_at":"2025-05-13T10:33:35.989Z","repository":{"id":50664040,"uuid":"519767452","full_name":"brainelectronics/changelog2version","owner":"brainelectronics","description":"Update version info file with latest changelog version entry","archived":false,"fork":false,"pushed_at":"2024-11-14T17:39:55.000Z","size":272,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-14T17:52:14.316Z","etag":null,"topics":["changelog","changelog-parser","changelogs","python","python-package","python3","semver","semver-convention","semver-syntax","version","versioning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brainelectronics.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-07-31T12:16:38.000Z","updated_at":"2024-11-14T17:39:08.000Z","dependencies_parsed_at":"2023-01-22T02:00:34.674Z","dependency_job_id":null,"html_url":"https://github.com/brainelectronics/changelog2version","commit_stats":{"total_commits":246,"total_committers":50,"mean_commits":4.92,"dds":0.5121951219512195,"last_synced_commit":"37070e4f9d84df7e2c0dde3a00b127ba472e0a97"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fchangelog2version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fchangelog2version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fchangelog2version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fchangelog2version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brainelectronics","download_url":"https://codeload.github.com/brainelectronics/changelog2version/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225206833,"owners_count":17438200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["changelog","changelog-parser","changelogs","python","python-package","python3","semver","semver-convention","semver-syntax","version","versioning"],"created_at":"2024-11-18T16:18:19.165Z","updated_at":"2024-11-18T16:18:19.858Z","avatar_url":"https://github.com/brainelectronics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Changelog2version\n\n[![Downloads](https://pepy.tech/badge/changelog2version)](https://pepy.tech/project/changelog2version)\n![Release](https://img.shields.io/github/v/release/brainelectronics/changelog2version?include_prereleases\u0026color=success)\n![Python](https://img.shields.io/badge/Python-3.9%20|%203.10%20|%203.11-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/github/brainelectronics/changelog2version/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/changelog2version)\n\nUpdate version info file with latest changelog version entry\n\n---------------\n\n## General\n\nCreate version info files based on the latest changelog entry.\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Available default template files](#available-default-template-files)\n        - [C header file](#c-header-file)\n        - [Python package file](#python-package-file)\n        - [JSON output](#json-output)\n            - [Console](#console)\n            - [File](#file)\n    - [Validate generated file](#validate-generated-file)\n- [Advanced](#advanced)\n    - [Custom regular expressions](#custom-regular-expressions)\n    - [Custom template file](#custom-template-file)\n    - [Additional version info content](#additional-version-info-content)\n- [Contributing](#contributing)\n    - [Unittests](#unittests)\n- [Credits](#credits)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\n## Installation\n\n```bash\npip install changelog2version\n```\n\n## Usage\n\nThis example shows you how to parse the [repo's changelog](changelog.md) and\nupdate the [package version file][ref-package-version-file] with that\nversion.\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version.py \\\n    --debug\n```\n\n### Available default template files\n\nBy default a Python version file is generated. Check the table below and the\nexample usage for further details and supported template files\n\n| Type   | Parameter | Description |\n| ------ | --------- | ----------- |\n| Python | `py`      | See [example package version][ref-package-version-file] |\n| C/CPP  | `c`       | Header file with available version info |\n\n#### C header file\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version_info.h \\\n    --version_file_type c \\\n    --debug\n```\n\n```\n//\n//  version_info.h\n//\n//  Created automatically by script\n//\n\n#ifndef version_info_h\n#define version_info_h\n\n#define MAJOR_VERSION   0     //\u003c major software version\n#define MINOR_VERSION   4     //\u003c minor software version\n#define PATCH_VERSION   0     //\u003c patch software version\n\n#endif\n```\n\n#### Python package file\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version.py \\\n    --version_file_type py \\\n    --debug\n```\n\n```\n#!/usr/bin/env python3\n# -*- coding: UTF-8 -*-\n\n__version_info__ = (\"0\", \"4\", \"0\")\n__version__ = '.'.join(__version_info__)\n\n```\n\n#### JSON output\n\nThe additional, optional argument `--pretty` will output the JSON data with an\nindentation of 4 in order to provide the data in an easy to read format.\n\n##### Console\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --print \\\n    --debug\n```\n\n```json\n{\"info\":{\"version\":\"0.12.0\",\"description\":\"\u003c!-- meta = {'type': 'feature', 'scope': ['all'], 'affected': ['all']} --\u003e\\n\\nAdd parser for meta data comment in changelog entry. The parsed data is available via the `meta_data` property of `ExtractVersion` after running `parse_changelog_completely` and is added to the `changelog.json` file. See #28\\n\\n- bump `snippets2changelog` to 1.3.0 to have the snippets meta data added to the changelog entries\\n\\n[0.12.0]: https://github.com/brainelectronics/snippets2changelog/tree/0.12.0\\n\",\"meta\":{\"type\":\"feature\",\"scope\":[\"all\"],\"affected\":[\"all\"]}},\"releases\":{\"0.12.0\":[{\"upload_time\":\"2024-10-04T11:26:10\"}],\"0.11.0\":[{\"upload_time\":\"2024-10-04T10:53:11\"}],\"0.10.1\":[{\"upload_time\":\"2024-10-02\"}],\"0.10.0\":[{\"upload_time\":\"2023-07-08\"}],\"0.9.0\":[{\"upload_time\":\"2022-11-12\"}],\"0.8.0\":[{\"upload_time\":\"2022-11-11\"}],\"0.7.0\":[{\"upload_time\":\"2022-11-11\"}],\"0.6.0\":[{\"upload_time\":\"2022-10-26\"}],\"0.5.0\":[{\"upload_time\":\"2022-10-20\"}],\"0.4.0\":[{\"upload_time\":\"2022-08-07\"}],\"0.3.0\":[{\"upload_time\":\"2022-08-05\"}],\"0.2.0\":[{\"upload_time\":\"2022-08-03\"}],\"0.1.1\":[{\"upload_time\":\"2022-07-31\"}],\"0.1.0\":[{\"upload_time\":\"2022-07-31\"}]}}\n```\n\nTo get the latest version and description in the console as environment\nvariables use the following call\n\n```bash\nLATEST_VERSION=$(changelog2version --changelog_file changelog.md --print | python -c \"import sys, json; print(json.load(sys.stdin)['info']['version'])\")\nLATEST_CHANGE=$(changelog2version --changelog_file changelog.md --print | python -c \"import sys, json; print(json.load(sys.stdin)['info']['description'])\")\n\necho \"The latest version extracted from the changelog is ${LATEST_VERSION}\"\n# The latest version extracted from the changelog is 0.7.0\n\necho \"Description of the latest change\"\necho \"${LATEST_CHANGE}\"\n# ### Added\n# - Changelog parsed as JSON contains a new key `description` like the PyPi package JSON info, compare to `https://pyp\n# i.org/pypi/changelog2version/json`, with the description/content of the latest change, see #19, relates to #18\n# - Increase unittest coverage above 95%\n\n# ### Changed\n# - Line breaks are no longer used in this changelog for enumerations\n# - Issues are referenced as `#123` instead of `[#123][ref-issue-123]` to avoid explicit references at the bottom or s\n# ome other location in the file\n# - Output of `changelog2version` call with `--print` but without `--debug` option is JSON compatible\n```\n\n##### File\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --output changelog.json \\\n    --pretty \\\n    --debug\n```\n\nSee [example JSON file][ref-example-json-file]\n\n### Validate generated file\n\nTo validate an already generated version file agains the latest available\nchangelog the `--validate` option can be used.\n\nThe following command will exit with a non-zero code in case of a difference\nbetween the generated version file (`examples/version.py`) and the latest\nchangelog content.\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version.py \\\n    --validate \\\n    --debug\n```\n\nBy default a Python version file is assumed, for a C header version file the\ncall has to be extended with the `version_file_type` option\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version_info.h \\\n    --version_file_type c \\\n    --validate \\\n    --debug\n```\n\n## Advanced\n\n### Custom regular expressions\n\nTo extract a version line from a given changelog file with an alternative\nregex, the `version_line_regex` argument can be used as shown below. The\nexpression is validated during the CLI argument parsing\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file src/changelog2version/version.py \\\n    --version_line_regex \"^\\#\\# \\[\\d{1,}[.]\\d{1,}[.]\\d{1,}\\]\" \\\n    --debug\n```\n\nSame applies for a custom semver line regex in order to extract the semantic\nversion part from a full version line, use the `semver_line_regex` argument to\nadjust the regular expression to your needs.\n\n### Custom template file\n\nBeside the default supported [template files][ref-templates-folder] users can\nalso provide custom template files.\n\nThis is the list of currently available variables\n\n| Name                          | Description                                               |\n| ----------------------------- | --------------------------------------------------------- |\n| `major_version`               | Major version, incompatible API changes                   |\n| `minor_version`               | Minor version, add functionality (backwards-compatible)   |\n| `patch_version`               | Patch version, bug fixes (backwards-compatible)           |\n| `prerelease_data`             | pre-release data, if available                            |\n| `build_data`                  | Build metadata, if available                              |\n| `file_name`                   | User specified name of rendered file                      |\n| `file_name_without_suffix`    | User specified name of rendered file without suffix       |\n| `template_name`               | Name of rendered template file                            |\n| `template_name_without_suffix`| Name of rendered template file without suffix             |\n| Custom keyword                | Provided by the user via `--additional_template_data`     |\n\n```bash\nadditional_data=\"{\\\"creation_datetime\\\": \\\"$(date +\"%Y-%m-%dT%H:%M:%S\")\\\", \\\"machine_name\\\": \\\"$(whoami)\\\"}\"\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version_info.c \\\n    --template_file examples/version_info.c.template \\\n    --additional_template_data \"${additional_data}\" \\\n    --debug\n\n# or less fancy\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version_info.c \\\n    --template_file examples/version_info.c.template \\\n    --additional_template_data '{\"creation_datetime\": \"2022-08-05T21:11:12\", \"machine_name\": \"Death Star\"}' \\\n    --debug\n```\n\nExecuting the created example file `examples/version_info.c` will print the\nfollowing content (datetime and creator might be different)\n\n```\nScript version is (major.minor.patch): 0.4.0\nPrerelease data: None\nPrerelease data: None\nCreation datetime: 2022-08-05T21:11:12\nCreated by Death Star\n```\n\n### Additional version info content\n\nTo create custom release candidate packages the python version file variable\n`__version__` can be exended with a custom string.\n\nChoose the additional version info content carefully as not everything is\nsupported by PyPi, see the\n[Python Core metadata specifications][ref-py-core-metadata-spec] and\n[PEP440][ref-pep440]\n\n```bash\nchangelog2version \\\n    --changelog_file changelog.md \\\n    --version_file examples/version.py \\\n    --version_file_type py \\\n    --additional_version_info=\"rc1234\" \\\n    --debug\n```\n\n```\n#!/usr/bin/env python3\n# -*- coding: UTF-8 -*-\n\n__version_info__ = (\"0\", \"5\", \"0\")\n__version__ = '.'.join(__version_info__) + '-rc1234'\n\n```\n\n## Contributing\n\n### Unittests\n\nRun the unittests locally with the following command after installing this\npackage in a virtual environment or by using `tox` to create one on each run.\n\n```bash\n# install the package with all its development dependencies\npip install .[dev]\n\n# run all tests\nnose2 --config tests/unittest.cfg\n\n# run only one specific tests\nnose2 tests.test_extract_version.TestExtractVersion.test_version_line_regex\n```\n\nGenerate the coverage files with\n\n```bash\npython create_report_dirs.py\ncoverage html\n```\n\nThe coverage report is placed at `reports/coverage/html/index.html`\n\n## Credits\n\nBased on the [PyPa sample project][ref-pypa-sample]. Also a big thank you to\nthe creators and maintainers of [SemVer.org][ref-semver] for their\ndocumentation and [regex example][ref-semver-regex-example]\n\n\u003c!-- Links --\u003e\n[ref-package-version-file]: src/changelog2version/version.py\n[ref-templates-folder]: src/changelog2version/templates\n[ref-example-json-file]: examples/changelog.json\n[ref-py-core-metadata-spec]: https://packaging.python.org/specifications/core-metadat\n[ref-pep440]: https://peps.python.org/pep-0440/\n[ref-pypa-sample]: https://github.com/pypa/sampleproject\n[ref-semver]: https://semver.org/\n[ref-semver-regex-example]: https://regex101.com/r/Ly7O1x/3/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainelectronics%2Fchangelog2version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainelectronics%2Fchangelog2version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainelectronics%2Fchangelog2version/lists"}