Create and push a version tag on main branch. Run this after the version bump PR has been merged. Automatically detects version from __version__ in packages. Args: dry_run: Show what would be done without making changes. no_edit: Skip editing release notes.
(dry_run: bool, no_edit: bool)
| 2030 | ) |
| 2031 | @click.option("--no-edit", is_flag=True, help="Skip editing release notes") |
| 2032 | def tag(dry_run: bool, no_edit: bool) -> None: |
| 2033 | """Create and push a version tag on main branch. |
| 2034 | |
| 2035 | Run this after the version bump PR has been merged. |
| 2036 | Automatically detects version from __version__ in packages. |
| 2037 | |
| 2038 | Args: |
| 2039 | dry_run: Show what would be done without making changes. |
| 2040 | no_edit: Skip editing release notes. |
| 2041 | """ |
| 2042 | console.print( |
| 2043 | "\n[yellow]Note:[/yellow] [bold]devtools tag[/bold] only tags and creates " |
| 2044 | "a GitHub release for this repo. It will not bump versions, publish to " |
| 2045 | "PyPI, or release enterprise.\n" |
| 2046 | "If you want a full end-to-end release, run " |
| 2047 | "[bold]devtools release <version>[/bold] instead." |
| 2048 | ) |
| 2049 | if not Confirm.ask("Continue with tag only?", default=True): |
| 2050 | sys.exit(0) |
| 2051 | |
| 2052 | try: |
| 2053 | cwd = Path.cwd() |
| 2054 | lib_dir = cwd / "lib" |
| 2055 | |
| 2056 | packages = get_packages(lib_dir) |
| 2057 | |
| 2058 | with console.status("[cyan]Validating package versions..."): |
| 2059 | versions = {} |
| 2060 | for pkg in packages: |
| 2061 | version_files = find_version_files(pkg) |
| 2062 | for vfile in version_files: |
| 2063 | content = vfile.read_text() |
| 2064 | for line in content.splitlines(): |
| 2065 | if line.strip().startswith("__version__"): |
| 2066 | ver = line.split("=")[1].strip().strip('"').strip("'") |
| 2067 | versions[vfile.relative_to(cwd)] = ver |
| 2068 | break |
| 2069 | |
| 2070 | if not versions: |
| 2071 | console.print( |
| 2072 | "[red]✗[/red] Validated package versions: Could not find __version__ in any package" |
| 2073 | ) |
| 2074 | sys.exit(1) |
| 2075 | |
| 2076 | unique_versions = set(versions.values()) |
| 2077 | if len(unique_versions) > 1: |
| 2078 | console.print( |
| 2079 | "[red]✗[/red] Validated package versions: Version mismatch detected" |
| 2080 | ) |
| 2081 | for file, ver in versions.items(): |
| 2082 | console.print(f" {file}: {ver}") |
| 2083 | sys.exit(1) |
| 2084 | |
| 2085 | version = unique_versions.pop() |
| 2086 | console.print(f"[green]✓[/green] Validated packages @ [bold]{version}[/bold]") |
| 2087 | tag_name = version |
| 2088 | |
| 2089 | if not dry_run: |
nothing calls this directly
no test coverage detected