Metadata-Version: 2.3
Name: release_by_changelog
Version: 0.2.3
Summary: Release a new version of a software based on CHANGELOG.md file.
Project-URL: Bug Tracker, https://lab.frogg.it/swepy/release-by-changelog/-/issues
Project-URL: Homepage, https://lab.frogg.it/swepy/release-by-changelog
Author-email: Dorian Turba <releasebychangelog.rjsts@simplelogin.com>
License-File: AUTHORS.rst
License-File: LICENCE
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: python-gitlab
Requires-Dist: typer[all]
Provides-Extra: all
Requires-Dist: bump-my-version; extra == 'all'
Requires-Dist: coverage; extra == 'all'
Requires-Dist: pip-tools; extra == 'all'
Requires-Dist: pre-commit; extra == 'all'
Requires-Dist: pyright; extra == 'all'
Requires-Dist: pytest; extra == 'all'
Requires-Dist: pytest-mock; extra == 'all'
Requires-Dist: ruff>=0.3.3; extra == 'all'
Requires-Dist: toml-sort; extra == 'all'
Provides-Extra: dev
Requires-Dist: bump-my-version; extra == 'dev'
Requires-Dist: pip-tools; extra == 'dev'
Provides-Extra: quality
Requires-Dist: pre-commit; extra == 'quality'
Requires-Dist: pyright; extra == 'quality'
Requires-Dist: ruff>=0.3.3; extra == 'quality'
Requires-Dist: toml-sort; extra == 'quality'
Provides-Extra: test
Requires-Dist: coverage; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-mock; extra == 'test'
Description-Content-Type: text/markdown

# Release by Changelog

[![Pipeline](https://lab.frogg.it/swepy/release-by-changelog/badges/main/pipeline.svg)](https://lab.frogg.it/swepy/release-by-changelog/-/pipelines?ref=main)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)


Release a new version of a software based on CHANGELOG.md file.

Detect the latest version in the CHANGELOG.md file and create a new release in the 
repository. 

Release by Changelog rely on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) 
format and [Semantic Versioning](https://semver.org/spec/v2.0.0.html), following those 
two norms is required.

## Installation

```bash
pip install --upgrade pip
pip install release-by-changelog
```

## Usage

In a Gitlab CI pipeline, you can use the following command to release a new version of
your software based on the CHANGELOG.md file.

```bash
release-by-changelog
```

It's recommended to add a `rules` section to run this command only on the default 
branch.

Here is an example of a `.gitlab-ci.yml` file using `release-by-changelog`:

```yaml
release:
    stage: deploy
    script:
        - pip install release-by-changelog 
        - release-by-changelog
    rules:
        -   if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
```

`release-by-changelog` will read the CHANGELOG.md file and create a new tag based on the
latest version found in the file. The release will be pushed to the repository. 

`release-by-changelog` rely on the following predefined CI/CD variables to authenticate 
with the GitLab API:

- `CI_PROJECT_ID`: Used to identify the project,
- `CI_COMMIT_SHA`: Used to identify the reference,
- `CI_JOB_TOKEN`: Used to authenticate with the GitLab API.
- `CI_SERVER_HOST`: Used to identify the GitLab host.

### Local usage

You can also use this command locally to release a new version of your software.

```bash
release-by-changelog --token <token> <project> <ref>
```

* project: Path or id on host. [required]
* ref: Can be a branch, tag, or commit SHA. [required]

The token is required to authenticate with the GitLab API.
You can authenticate with the GitLab API in several ways:

- [OAuth 2.0 tokens](https://docs.gitlab.com/ee/api/rest/#oauth-20-tokens)
- [Personal access tokens](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)
- [Project access tokens](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html)
- [Group access tokens](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html)

### Using environment variables

You can also use environment variables to avoid passing the token each time. A token
passed as an argument will always take precedence over the environment variable.

```bash
export PRIVATE_TOKEN=<token>
release-by-changelog <project> <ref>
```
