diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-03-02 14:28:33 +0100 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-03-02 16:28:39 +0100 |
commit | ed86e96d158600fb4555d23066dec5db822b73ef (patch) | |
tree | 028d576552e10bf5248ab6b8bc1cba5fbcab4960 | |
parent | workflows/ci: test w/ Python 3.11 also (diff) | |
download | cgitize-ed86e96d158600fb4555d23066dec5db822b73ef.tar.gz cgitize-ed86e96d158600fb4555d23066dec5db822b73ef.zip |
add runtime version information
-rw-r--r-- | .github/workflows/ci.yml | 8 | ||||
-rw-r--r-- | cgitize/main.py | 3 | ||||
-rw-r--r-- | cgitize/version.py | 10 | ||||
-rw-r--r-- | pyproject.toml | 7 |
4 files changed, 25 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1db5b0..4dc1af7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: @@ -27,8 +29,10 @@ jobs: run: | git config --global user.name 'John Doe' git config --global user.email 'John.Doe@example.com' - - name: Install dependencies + - name: 'Install package & dependencies' run: pip install -q -e . + - name: Verify that cgitize can be run + run: cgitize --version - name: Integration test (local) run: ./test/integration/local/test.sh - name: Unit tests @@ -135,6 +139,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 - name: Verify package can be installed diff --git a/cgitize/main.py b/cgitize/main.py index e787861..879e07d 100644 --- a/cgitize/main.py +++ b/cgitize/main.py @@ -10,6 +10,7 @@ import sys from cgitize.cgit import CGitRepositories, CGitServer from cgitize.config import Config from cgitize.utils import setup_logging +from cgitize.version import __version__ def parse_args(argv=None): @@ -26,6 +27,8 @@ def parse_args(argv=None): help='overwrite existing repositories') parser.add_argument('--verbose', '-v', action='store_true', help='verbose log output') + parser.add_argument('--version', '-V', action='version', + version=f'%(prog)s {__version__}') return parser.parse_args(argv) diff --git a/cgitize/version.py b/cgitize/version.py new file mode 100644 index 0000000..5543f34 --- /dev/null +++ b/cgitize/version.py @@ -0,0 +1,10 @@ +try: + import importlib.metadata as metadata +except ImportError: + import importlib_metadata as metadata + + +try: + __version__ = metadata.version('cgitize') +except Exception: + __version__ = 'unknown' diff --git a/pyproject.toml b/pyproject.toml index 89da158..5d7e0bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,19 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=61.0", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "cgitize" description = "Self-host your repositories using cgit" license = {text = "MIT"} -version = "4.0.9" +dynamic = ["version"] authors = [{name = "Egor Tensin", email = "Egor.Tensin@gmail.com"}] readme = "README.md" requires-python = ">=3.6" dependencies = [ "atlassian-python-api ~= 3.28.0", + 'importlib-metadata ~= 4.0 ; python_version < "3.8"', "PyGithub ~= 1.0", "python-gitlab ~= 2.0", "tomli ~= 1.0", @@ -34,3 +35,5 @@ cgitize = "cgitize.main:main" [tool.setuptools.packages] find = {} + +[tool.setuptools_scm] |