How to use tag_release_commit method in tox

Best Python code snippet using tox_python

release.py

Source:release.py Github

copy

Full Screen

...12 if repo.is_dirty():13 raise RuntimeError("Current repository is dirty. Please commit any changes and try again.")14 upstream, release_branch = create_release_branch(repo, version)15 release_commit = release_changelog(repo, version)16 tag = tag_release_commit(release_commit, repo, version)17 print("push release commit")18 repo.git.push(upstream.name, release_branch)19 print("push release tag")20 repo.git.push(upstream.name, tag)21 print("All done! ✨ 🍰 ✨")22def create_release_branch(repo: Repo, version: Version) -> Tuple[Remote, Head]:23 print("create release branch from upstream master")24 upstream = get_upstream(repo)25 upstream.fetch()26 branch_name = f"release-{version}"27 release_branch = repo.create_head(branch_name, upstream.refs.master, force=True)28 upstream.push(refspec=f"{branch_name}:{branch_name}", force=True)29 release_branch.set_tracking_branch(repo.refs[f"{upstream.name}/{branch_name}"])30 release_branch.checkout()31 return upstream, release_branch32def get_upstream(repo: Repo) -> Remote:33 for remote in repo.remotes:34 for url in remote.urls:35 if url.endswith("tox-dev/tox.git"):36 return remote37 raise RuntimeError("could not find tox-dev/tox.git remote")38def release_changelog(repo: Repo, version: Version) -> Commit:39 print("generate release commit")40 check_call(["towncrier", "--yes", "--version", version.public], cwd=str(ROOT_SRC_DIR))41 release_commit = repo.index.commit(f"release {version}")42 return release_commit43def tag_release_commit(release_commit, repo, version) -> TagReference:44 print("tag release commit")45 existing_tags = [x.name for x in repo.tags]46 if version in existing_tags:47 print("delete existing tag {}".format(version))48 repo.delete_tag(version)49 print("create tag {}".format(version))50 tag = repo.create_tag(version, ref=release_commit, force=True)51 return tag52if __name__ == "__main__":53 import argparse54 parser = argparse.ArgumentParser(prog="release")55 parser.add_argument("--version", required=True)56 options = parser.parse_args()57 main(options.version)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful