Merge 703d809387114745b79af0918b7715efc703a294 into 5cdc9019d7b5a69cde6bb15a657f26e9bd7b2e3f

This commit is contained in:
Lucas de Sousa Rosa 2025-04-07 17:08:47 +02:00 committed by GitHub
commit 09f849f019
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 53 additions and 4 deletions

10
.git-hooks/post-commit Executable file
View File

@ -0,0 +1,10 @@
#! /bin/bash
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/pyproject.toml | grep -m 1 '^\+.*version' | sed -s 's/[^A-Z0-9\.\-]//g'`
if [[ ! $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(\-[A-Z]+\.[0-9]+)?$ ]]; then
echo -e "Skip tag: invalid version '$version'"
exit 1
fi
git tag -a "v$version" -m "`git log -1 --format=%s`"
echo "Created a new tag, v$version"

View File

@ -0,0 +1,32 @@
name: Create and publish a release
on:
push:
tags:
- 'v*.*.*'
jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref_name }}
makeLatest: true
publish_to_pypi:
name: Publish to PyPI
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and publish to PyPI
uses: JRubics/poetry-publish@v1.17
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
ignore_dev_requirements: "yes"

View File

@ -66,14 +66,19 @@ Ready to contribute? Here's how to set up `pipreqs` for local development.
3. Pipreqs is developed using Poetry. Refer to the `documentation <https://python-poetry.org/docs/>`_ to install Poetry in your local environment. Next, you should install pipreqs's dependencies:: 3. Pipreqs is developed using Poetry. Refer to the `documentation <https://python-poetry.org/docs/>`_ to install Poetry in your local environment. Next, you should install pipreqs's dependencies::
$ poetry install --with dev $ poetry install --with dev
$ poetry self add poetry-bumpversion
4. Create a branch for local development:: 4. Configure `./git-hooks/` directory so that it becomes visible to git hooks (this hook depends on `bash`, `sed` and `grep` - tools usually included in any linux distribution)::
$ git config core.hooksPath .git-hooks
5. Create a branch for local development::
$ git checkout -b name-of-your-bugfix-or-feature $ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally. Now you can make your changes locally.
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: 6. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
$ poetry run flake8 pipreqs tests $ poetry run flake8 pipreqs tests
$ poetry run python -m unittest discover $ poetry run python -m unittest discover
@ -81,13 +86,13 @@ Ready to contribute? Here's how to set up `pipreqs` for local development.
To test all versions of python using tox you need to have them installed and for this two options are recommended: `pyenv` or `asdf`. To test all versions of python using tox you need to have them installed and for this two options are recommended: `pyenv` or `asdf`.
6. Commit your changes and push your branch to GitHub:: 7. Commit your changes and push your branch to GitHub::
$ git add . $ git add .
$ git commit -m "Your detailed description of your changes." $ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature $ git push origin name-of-your-bugfix-or-feature
7. Submit a pull request through the GitHub website. 8. Submit a pull request through the GitHub website.
Pull Request Guidelines Pull Request Guidelines
----------------------- -----------------------

View File

@ -37,6 +37,8 @@ tox = "^4.11.3"
coverage = "^7.3.2" coverage = "^7.3.2"
sphinx = { version = "^7.2.6", python = ">=3.9" } sphinx = { version = "^7.2.6", python = ">=3.9" }
[tool.poetry_bumpversion.file."pipreqs/__init__.py"]
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"