From 61b416954fe51fe78a84ce17902a62ae512ecfea Mon Sep 17 00:00:00 2001 From: Dzmitry Pryskoka Date: Sun, 1 Oct 2023 18:19:12 +0300 Subject: [PATCH] Add publish workflow --- .editorconfig | 9 ++++++ .github/workflows/publish.yml | 57 +++++++++++++++++++++++++++++++++ .github/workflows/run-tests.yml | 4 +-- README.md | 1 + changelog.md | 3 ++ src/kataloger/__init__.py | 3 ++ src/kataloger/__main__.py | 3 +- 7 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/publish.yml create mode 100644 changelog.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f3425b9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +insert_final_newline = true +indent_style = space + +[*.{yml,yaml}] +indent_size = 2 +ij_yaml_indent_sequence_value = false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..964b578 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,57 @@ +name: Publish package + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + name: Publish kataloger to PyPI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Build package + run: python -m build + + - name: Publish package + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: + twine upload dist/* + + create-release: + name: Create GitHub release + needs: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: SebRollen/toml-action@v1.0.2 + id: read_version + with: + file: pyproject.toml + field: project.version + + - uses: softprops/action-gh-release@v1 + name: Create release + with: + body_path: ${{ github.workspace }}/changelog.md + name: v${{ steps.read_version.outputs.value }} + tag_name: v${{ steps.read_version.outputs.value }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8c3b4a6..cec9df0 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,9 +1,9 @@ name: Run tests -on: [push, pull_request] +on: [ push, pull_request ] jobs: - build: + run-tests: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 0a53da3..abaf45d 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,4 @@ Cataloger has convenient API (I did my best), so you can install it from pip and - [ ] Support check multiple catalogs - [ ] Support all notations in version catalog - [ ] Support advanced update configuration +- [ ] Support Python <3.11 diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..eb469ad --- /dev/null +++ b/changelog.md @@ -0,0 +1,3 @@ +### Changelog + +* Initial release!🚀 diff --git a/src/kataloger/__init__.py b/src/kataloger/__init__.py index e69de29..22b3916 100644 --- a/src/kataloger/__init__.py +++ b/src/kataloger/__init__.py @@ -0,0 +1,3 @@ +from importlib.metadata import version + +__version__ = version(__package__ or __name__) diff --git a/src/kataloger/__main__.py b/src/kataloger/__main__.py index 4d6e358..1851b01 100644 --- a/src/kataloger/__main__.py +++ b/src/kataloger/__main__.py @@ -5,6 +5,7 @@ import asyncio +from kataloger import __version__ as kataloger_version from kataloger.catalog_updater_builder import CatalogUpdaterBuilder from kataloger.data.kataloger_configuration import KatalogerConfiguration from kataloger.execptions.kataloger_configuration_exception import KatalogerConfigurationException @@ -58,7 +59,7 @@ def parse_arguments() -> KatalogerConfiguration: parser.add_argument( "--version", action="version", - version=f"%(prog)s 0.0.1", # TODO: to be read from single-source + version=f"%(prog)s {kataloger_version}", ) arguments = parser.parse_args()