def create_repo() -> Monorepo: if not confirm("Do you want to create a new project ?"): sys.exit(0) run("poetry init") repo = Monorepo(Path.cwd()) repo.set_include_packages([]) return repo
def install_deps(become: bool = typer.Option( False, "-b", "--become", help="perform installation as root user using sudo")) -> None: """Install release dependencies""" deps = [ "semantic-release", "@semantic-release/commit-analyzer", "@semantic-release/changelog", "@semantic-release/exec", "conventional-changelog-conventionalcommits", ] cmd = "npm i -g " + " ".join(deps) if become: cmd = "sudo " + cmd console.print(f"Running command: {quote(style_str(cmd, 'bold'))}") run(cmd)
def prepare_release( version: str = VERSION, branch: str = BRANCH, ) -> None: """Prepare the release.""" # Make sure to start from given branch run(f"git checkout {branch}") # Update version using command defined above run(f"k bump {version}") # At this point semantic release already performed a commit run("git add .") # Commit changes to the current branch run(f"git commit -m 'chore(release): bumped to version {version}'")
def run_prof( script: Optional[str] = typer.Argument(None, help="Script to run"), module: Optional[str] = typer.Option(None, "-m", "--module", help="Module to run"), output: str = typer.Option(None, "-o", "--output", help="Output file"), ) -> None: out_opt = f" -o {output}" if output else "" if module: rest = " -m " + module elif script: rest = " " + quote(script) script = script else: console.print( "Wrong usage: Either [bold]-m[/bold]/[bold]--module[/bold] option or a [bold]positional argument[/bold] must be present", style="red", ) raise typer.Exit(1) cmd = f"python -m cProfile {out_opt} {rest}" console.print(f"[bold blue]Profiling[/bold blue] with command: {cmd}") run(cmd)
def on_success(branch: str = BRANCH) -> None: """Merge changes back into next on success on stable releases only.""" if branch == STABLE_BRANCH_NAME: # Checkout release candidate branch ("next" by default) run(f"git switch -c {RC_BRANCH_NAME} 2>/dev/null || git checkout {RC_BRANCH_NAME}" ) # Merge changes from stable branch run(f"git merge --no-ff origin/{branch} -m 'chore(release): merge from stable branch [skip ci]'" ) # Push changes into release candidate branch ("next" by default) run(f"git push origin {RC_BRANCH_NAME}")
def commit() -> None: """Commit changes to git repository.""" with current_directory(repo.root): run("cz commit")
def coverage() -> None: """Start HTML server displaying code coverage.""" with current_directory(repo.root): run("python -m http.server --bind 127.0.0.1 --directory coverage-report")
def viz_prof(profile_report: Path = typer.Argument( ..., help="Path to .prof file")) -> None: run(f"snakeviz {profile_report}")
def dry_run() -> None: """Perform a release dry-run.""" with ensure_config(): run("semantic-release --dry-run --debug")
def publish_release(branch: str = BRANCH) -> None: """Perform the release.""" # Checkout target branch run(f"git checkout {branch}") # Push changes into target branch run(f"git push origin {branch}")
def do_release() -> None: """Perform a release.""" with ensure_config(): run("semantic-release --debug")