Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
misc: add releas flow for python packages
angrybayblade committed
Jun 17, 2025 at 13:40 UTC
05fa5ace9cce22321683eb8447c1646f751d8d65
4 files changed
+196
-2
.github/workflows/py.release.yml
new
+36
@@ -0,0 +1,36 @@
1
+name: Releaase Python Packages
2
+on:
3
+ release:
4
+ types: [published]
5
+ workflow_dispatch:
6
+ inputs:
7
+ skip_tests:
8
+ description: "Skip running tests"
9
+ required: false
10
+ type: boolean
11
+ default: false
12
+
13
+jobs:
14
+ publish-core:
15
+ name: Build and release SDK
16
+ defaults:
17
+ run:
18
+ working-directory: ./python
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.10"
25
+
26
+ - name: Build Artifacts
27
+ run: |
28
+ make build
29
+
30
+ - name: Publish Artifacts
31
+ if: github.event_name == 'release'
32
+ uses: pypa/gh-action-pypi-publish@release/v1
33
+ with:
34
+ user: ${{ secrets.PYPI_USERNAME }}
35
+ password: ${{ secrets.PYPI_PASSWORD }}
36
+ skip-existing: true
\ No newline at end of file
.gitignore
+3
-1
@@ -54,4 +54,6 @@ __pycache__/
54
55
# wrangler
56
.wrangler
57
-.dev.vars
\ No newline at end of file
57
+.dev.vars
58
+
59
+temp/
\ No newline at end of file
python/noxfile.py
+1
-1
@@ -5,7 +5,7 @@ from nox.sessions import Session
5
nox.options.default_venv_backend = "uv"
6
7
# TODO: Add providers
8
-modules = ["composio/", "tests/", "examples/"]
8
+modules = ["composio/", "tests/", "examples/", "scripts/"]
9
10
ruff = ["ruff", "--config", "config/ruff.toml"]
11
python/scripts/bump.py
new
+156
@@ -0,0 +1,156 @@
1
+import readline
2
+import typing as t
3
+from enum import Enum
4
+from itertools import chain
5
+from pathlib import Path
6
+
7
+import click
8
+import tomli
9
+from semver import VersionInfo
10
+
11
+CWD = Path.cwd()
12
+SKIPDIR = (".venv",)
13
+PYPROJECT = "pyproject.toml"
14
+SETUP = "setup.py"
15
+
16
+BumpTypes = {
17
+ "M": "major",
18
+ "m": "minor",
19
+ "p": "patch",
20
+ "c": "pre",
21
+ "b": "post",
22
+ "s": "skip",
23
+}
24
+BumpTypesPrompt = " | ".join([f"{k}-{v.title()}" for k, v in BumpTypes.items()])
25
+
26
+
27
+class BumpType(Enum):
28
+ MAJOR = "major"
29
+ MINOR = "minor"
30
+ PATCH = "patch"
31
+ PRE = "pre"
32
+ POST = "post"
33
+
34
+
35
+def _get_bumped_version(current: VersionInfo, bump_type: BumpType) -> VersionInfo:
36
+ if bump_type == BumpType.MAJOR:
37
+ return current.next_version("major")
38
+
39
+ if bump_type == BumpType.MINOR:
40
+ return current.next_version("minor")
41
+
42
+ if bump_type == BumpType.PATCH:
43
+ return current.next_version("patch")
44
+
45
+ if bump_type == BumpType.PRE:
46
+ return current.next_version("prerelease")
47
+
48
+ return current.bump_build(token="post")
49
+
50
+
51
+def _skip(file: Path) -> bool:
52
+ return any(skipdir in file.parts for skipdir in SKIPDIR)
53
+
54
+
55
+def _find_packages():
56
+ files = []
57
+ for file in chain(CWD.glob(f"**/{PYPROJECT}"), CWD.glob(f"**/{SETUP}")):
58
+ if _skip(file=file):
59
+ continue
60
+ files.append(file)
61
+ return files
62
+
63
+
64
+def _get_version_update(package: str, version: str) -> t.Optional[str]:
65
+ pre = None
66
+ if "rc" in version:
67
+ version, marker, number = version.partition("rc")
68
+ pre = f"{marker}{number}"
69
+
70
+ # TODO: Add support for post builds
71
+ current_version = VersionInfo.parse(version=version)
72
+ current_version._prerelease = pre
73
+
74
+ bump_type_input = click.prompt(f"* Bump {package}@{version} -> {BumpTypesPrompt}")
75
+ if bump_type_input == "s":
76
+ return None
77
+
78
+ try:
79
+ bump_type = BumpType(BumpTypes[bump_type_input])
80
+ except (ValueError, KeyError) as e:
81
+ raise click.ClickException(f"Invalid bump type: {e}")
82
+ return str(_get_bumped_version(current=current_version, bump_type=bump_type))
83
+
84
+
85
+def _bump_setup_py(file: Path):
86
+ # Load config
87
+ content = file.read_text(encoding="utf-8")
88
+ _, _, arguments = content.partition("setup(")
89
+
90
+ package, version = None, None
91
+ for line in arguments.split("\n"):
92
+ if "=" not in line:
93
+ continue
94
+
95
+ arg, val = line.strip().split("=", maxsplit=1)
96
+ val = val.replace('"', "").replace(",", "").strip()
97
+ if arg == "name":
98
+ package = val
99
+
100
+ if arg == "version":
101
+ version = val
102
+
103
+ # Skip the main setup.py
104
+ if package == "composio":
105
+ return
106
+
107
+ if package is None or version is None:
108
+ raise ValueError(f"Package or version not found in {file}")
109
+
110
+ # Bump version
111
+ next_version = _get_version_update(package=package, version=version)
112
+ if next_version is None:
113
+ click.echo(f"* Skipping {package}")
114
+ return
115
+
116
+ click.echo(f"* Bumping {package} -> {next_version}")
117
+ content = content.replace(f'version="{version}"', f'version="{next_version}"')
118
+ file.write_text(content, encoding="utf-8")
119
+
120
+
121
+def _bump_pyproject_toml(file: Path):
122
+ # Load config
123
+ content = file.read_text(encoding="utf-8")
124
+ config = tomli.loads(content)
125
+ project = t.cast(dict, config["project"])
126
+
127
+ # Extract meta
128
+ package = project["name"]
129
+ version = project["version"]
130
+
131
+ # Bump version
132
+ next_version = _get_version_update(package=package, version=version)
133
+ if next_version is None:
134
+ click.echo(f"* Skipping {package}")
135
+ return
136
+
137
+ click.echo(f"* Bumping {package} -> {next_version}")
138
+ content = content.replace(f'version = "{version}"', f'version = "{next_version}"')
139
+ file.write_text(content, encoding="utf-8")
140
+
141
+
142
+def _bump_package(file: Path):
143
+ if file.name == PYPROJECT:
144
+ return _bump_pyproject_toml(file=file)
145
+ return _bump_setup_py(file=file)
146
+
147
+
148
+@click.command("bump")
149
+def bump():
150
+ packages = _find_packages()
151
+ for package in packages:
152
+ _bump_package(file=package)
153
+
154
+
155
+if __name__ == "__main__":
156
+ bump()