diff --git a/INSTALL.md b/INSTALL.md index 5cc3b65..e2be125 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -34,6 +34,15 @@ uv tool install https://github.com/shadoll/moma/releases/download/v0.9.1/moma-0. uv tool install moma ``` +#### Reinstall / Upgrade moma +```bash +# Reinstall (same URL — force overwrite) +uv tool install --force https://github.com/shadoll/moma/releases/latest/download/moma-latest.tar.gz + +# Upgrade to a newer specific version +uv tool install --force https://github.com/shadoll/moma/releases/download/v0.9.1/moma-0.9.1-py3-none-any.whl +``` + #### Usage ```bash moma # Scan current directory diff --git a/justfile b/justfile index c015ebb..b2aea9f 100644 --- a/justfile +++ b/justfile @@ -29,6 +29,78 @@ release: bump test: uv run pytest +# Tag the current version from pyproject.toml and push to origin +git-release: + #!/usr/bin/env python3 + import re + import subprocess + import sys + + def read_version(): + with open('pyproject.toml', 'r') as f: + content = f.read() + m = re.search(r'version = "(\d+\.\d+\.\d+)"', content) + return m.group(1) if m else None + + def tag_exists(tag): + local = subprocess.run(['git', 'tag', '-l', tag], capture_output=True, text=True) + if local.stdout.strip(): + return True + remote = subprocess.run(['git', 'ls-remote', '--tags', 'origin', f'refs/tags/{tag}'], capture_output=True, text=True) + return bool(remote.stdout.strip()) + + def do_bump(): + with open('pyproject.toml', 'r') as f: + content = f.read() + m = re.search(r'version = "(\d+)\.(\d+)\.(\d+)"', content) + if not m: + print('Version not found in pyproject.toml') + sys.exit(1) + old = m.group(0).split('"')[1] + major, minor, patch = map(int, m.groups()) + new = f'{major}.{minor}.{patch + 1}' + with open('pyproject.toml', 'w') as f: + f.write(content.replace(m.group(0), f'version = "{new}"')) + with open('INSTALL.md', 'r') as f: + install = f.read() + with open('INSTALL.md', 'w') as f: + f.write(install.replace(old, new)) + print(f'Version bumped to {new}') + return new + + version = read_version() + if not version: + print('Could not read version from pyproject.toml') + sys.exit(1) + + tag = f'v{version}' + + if tag_exists(tag): + print(f'Tag {tag} already exists.') + print(' [c] Cancel') + print(' [b] Bump version and continue') + print(' [r] Replace tag (delete and re-create)') + choice = input('Your choice (c/b/r): ').strip().lower() + if choice == 'c' or choice == '': + print('Cancelled.') + sys.exit(0) + elif choice == 'b': + version = do_bump() + tag = f'v{version}' + elif choice == 'r': + print(f'Deleting tag {tag} locally and on origin...') + subprocess.run(['git', 'tag', '-d', tag]) + subprocess.run(['git', 'push', 'origin', f':refs/tags/{tag}']) + else: + print('Unknown choice, cancelling.') + sys.exit(1) + + print(f'Creating tag {tag}...') + subprocess.run(['git', 'tag', tag], check=True) + print(f'Pushing tag {tag} to origin...') + subprocess.run(['git', 'push', 'origin', tag], check=True) + print(f'Done! Tag {tag} pushed.') + # Run the application run *ARGS: uv run moma {{ARGS}} diff --git a/pyproject.toml b/pyproject.toml index c99a5b9..88dfc34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,15 @@ dev = [ ] [project.scripts] -moma = "main:main" +moma = "src.main:main" + +[build-system] +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["."] +include = ["src*"] [tool.uv] package = true